From 7bac42f9b2c501e4ced4d50e9946d74fa605e310 Mon Sep 17 00:00:00 2001 From: Hannu Hanhi Date: Sat, 11 Apr 2020 16:16:31 +0300 Subject: [PATCH] Don't repeatedly look for texture files that don't exist. This fixes performance issues with models. --- src/hardware/hw_data.h | 2 ++ src/hardware/hw_md2.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_data.h b/src/hardware/hw_data.h index 4bbc578e..4bb06eb4 100644 --- a/src/hardware/hw_data.h +++ b/src/hardware/hw_data.h @@ -84,6 +84,8 @@ struct GLPatch_s UINT16 wadnum; // the software patch lump num for when the hardware patch UINT16 lumpnum; // was flushed, and we need to re-create it 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; diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index d217f409..f5d37be1 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -389,7 +389,10 @@ static void md2_loadTexture(md2_t *model) #endif grpatch->mipmap.grInfo.format = PCX_Load(filename, &w, &h, grpatch); if (grpatch->mipmap.grInfo.format == 0) + { + grpatch->notfound = true;// mark it so its not searched for again repeatedly return; + } grpatch->mipmap.downloaded = 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); if (grpatch->mipmap.grInfo.format == 0) { + grpatch->notfound = true;// mark it so its not searched for again repeatedly Z_Free(filename); return; } @@ -971,12 +975,14 @@ void HWR_DrawMD2(gr_vissprite_t *spr) finalscale = md2->scale; //Hurdler: arf, I don't like that implementation at all... too much crappy 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); 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 - && (!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); 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