DecalGroups: precache decal groups up front to avoid loading and frames where decals are white/invisible.
This commit is contained in:
parent
f2c41e3def
commit
b847316ec0
6 changed files with 37 additions and 3 deletions
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue