DecalGroups: precache decal groups up front to avoid loading and frames where decals are white/invisible.

This commit is contained in:
Marco Cawthorne 2023-07-14 18:08:29 -07:00
parent f2c41e3def
commit b847316ec0
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
6 changed files with 37 additions and 3 deletions

View File

@ -99,6 +99,7 @@ var bool g_net_debug = false;
#define PRINT_CHAT 3
var bool g_dlight_cached = false;
var bool g_client_world_loaded = false;
const float MASK_GLOWS = 16;
var bool g_focus;

View File

@ -575,6 +575,11 @@ CSQC_WorldLoaded(void)
ent.Respawn();
}
g_client_world_loaded = true;
/* wad files will most likely have loaded now */
DecalGroups_Precache();
print("Client world initialized.\n");
}

View File

@ -90,3 +90,7 @@ decal_pickwall(entity dself, vector vpos)
decal Decals_Next(vector pos);
void Decals_Place(vector pos, string dname);
#ifdef CLIENT
string Decal_Precache(string decalTex);
#endif

View File

@ -144,9 +144,7 @@ decal::BuildShader(void)
if (!m_strTexture || !m_strTexture)
return;
m_strShader = sprintf("decal_%s", m_strTexture);
shader_buff = sprintf(g_decal_shader, m_strTexture);
shaderforname(m_strShader, shader_buff);
m_strShader = Decal_Precache(m_strTexture);
}
#endif
@ -276,6 +274,16 @@ void Decals_Place(vector pos, string dname)
}
#ifdef CLIENT
string
Decal_Precache(string decalTex)
{
string shaderName = sprintf("decal_%s", decalTex);
string shaderBuff = sprintf(g_decal_shader, decalTex);
precache_pic(decalTex); /* precache */
shaderforname(shaderName, shaderBuff);
return shaderName;
}
void
Decal_Reload(void)
{

View File

@ -32,5 +32,6 @@ void DecalGroups_Place(string group, vector org);
int DecalGroups_NumForName(string group);
#ifdef CLIENT
void DecalGroups_Precache(void);
void DecalGroups_Receive(void);
#endif

View File

@ -149,6 +149,21 @@ DecalGroups_Init(void)
}
#ifdef CLIENT
void
DecalGroups_Precache(void)
{
if (g_client_world_loaded == false)
return;
for (int i = 0; i < g_decalgroup_count; i++) {
int c = tokenizebyseparator(g_decalgroup[i].materials, ";");
for (int x = 0; x < c; x++) {
Decal_Precache(argv(x));
}
}
}
void
DecalGroups_PlaceGroupID(int index, vector org)
{