Don't repeatedly look for texture files that don't exist. This fixes performance issues with models.

This commit is contained in:
Hannu Hanhi 2020-04-11 16:16:31 +03:00 committed by Wolfy
parent 516a4994f5
commit 7bac42f9b2
2 changed files with 10 additions and 2 deletions

View file

@ -84,6 +84,8 @@ struct GLPatch_s
UINT16 wadnum; // the software patch lump num for when the hardware patch UINT16 wadnum; // the software patch lump num for when the hardware patch
UINT16 lumpnum; // was flushed, and we need to re-create it UINT16 lumpnum; // was flushed, and we need to re-create it
GLMipmap_t mipmap; GLMipmap_t mipmap;
boolean notfound; // if the texture file was not found, mark it here (used in model blend texture loading)
}; };
typedef struct GLPatch_s GLPatch_t; typedef struct GLPatch_s GLPatch_t;

View file

@ -389,7 +389,10 @@ static void md2_loadTexture(md2_t *model)
#endif #endif
grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap.grInfo.format == 0) if (grpatch->mipmap.grInfo.format == 0)
{
grpatch->notfound = true;// mark it so its not searched for again repeatedly
return; return;
}
grpatch->mipmap.downloaded = 0; grpatch->mipmap.downloaded = 0;
grpatch->mipmap.flags = 0; grpatch->mipmap.flags = 0;
@ -438,6 +441,7 @@ static void md2_loadBlendTexture(md2_t *model)
grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch);
if (grpatch->mipmap.grInfo.format == 0) if (grpatch->mipmap.grInfo.format == 0)
{ {
grpatch->notfound = true;// mark it so its not searched for again repeatedly
Z_Free(filename); Z_Free(filename);
return; return;
} }
@ -971,12 +975,14 @@ void HWR_DrawMD2(gr_vissprite_t *spr)
finalscale = md2->scale; finalscale = md2->scale;
//Hurdler: arf, I don't like that implementation at all... too much crappy //Hurdler: arf, I don't like that implementation at all... too much crappy
gpatch = md2->grpatch; gpatch = md2->grpatch;
if (!gpatch || !gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded) if (!gpatch || ((!gpatch->mipmap.grInfo.format || !gpatch->mipmap.downloaded) && !gpatch->notfound))
md2_loadTexture(md2); md2_loadTexture(md2);
gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture... gpatch = md2->grpatch; // Load it again, because it isn't being loaded into gpatch after md2_loadtexture...
if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available if ((gpatch && gpatch->mipmap.grInfo.format) // don't load the blend texture if the base texture isn't available
&& (!md2->blendgrpatch || !((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded)) && (!md2->blendgrpatch
|| ((!((GLPatch_t *)md2->blendgrpatch)->mipmap.grInfo.format || !((GLPatch_t *)md2->blendgrpatch)->mipmap.downloaded)
&& !((GLPatch_t *)md2->blendgrpatch)->notfound)))
md2_loadBlendTexture(md2); md2_loadBlendTexture(md2);
if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture if (gpatch && gpatch->mipmap.grInfo.format) // else if meant that if a texture couldn't be loaded, it would just end up using something else's texture