From 4158c4e2c293bb8c3ff3c2cd0e3a1e5859e7e196 Mon Sep 17 00:00:00 2001 From: havoc Date: Wed, 22 Jan 2020 09:25:29 +0000 Subject: [PATCH] Fix drawflag handling in Mod_Mesh_GetTexture by duplicating texture_t when drawflag overrides differ (it still uses the same skinframe_t so it's not duplicating the actual texture). This fixes a menu issue in Steel Storm: Burning Retribution where the black text over a hover button was being rendered as MATERIALFLAG_ADD due to DRAWFLAG_ADD being used earlier in the frame on the same font image, which made the text invisible. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@12505 d7cf8633-e32d-0410-b094-e92efae38249 --- model_shared.c | 8 +++++--- model_shared.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/model_shared.c b/model_shared.c index 73d87d2d..1e546719 100644 --- a/model_shared.c +++ b/model_shared.c @@ -4398,9 +4398,10 @@ texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdra { int i; texture_t *t; - for (i = 0; i < mod->num_textures; i++) - if (!strcmp(mod->data_textures[i].name, name)) - return mod->data_textures + i; + int drawflag = defaultdrawflags & DRAWFLAG_MASK; + for (i = 0, t = mod->data_textures; i < mod->num_textures; i++, t++) + if (!strcmp(t->name, name) && t->drawflag == drawflag) + return t; if (mod->max_textures <= mod->num_textures) { texture_t *oldtextures = mod->data_textures; @@ -4412,6 +4413,7 @@ texture_t *Mod_Mesh_GetTexture(dp_model_t *mod, const char *name, int defaultdra } t = &mod->data_textures[mod->num_textures++]; Mod_LoadTextureFromQ3Shader(mod->mempool, mod->name, t, name, false, true, defaulttexflags, defaultmaterialflags); + t->drawflag = drawflag; switch (defaultdrawflags & DRAWFLAG_MASK) { case DRAWFLAG_ADDITIVE: diff --git a/model_shared.h b/model_shared.h index 0b377c2c..64c3c7d7 100644 --- a/model_shared.h +++ b/model_shared.h @@ -631,6 +631,9 @@ typedef struct texture_s // diffuse and ambient float rtlightambient; + + // used by Mod_Mesh_GetTexture for drawflag overrides, to disambiguate the same texture with different drawflags + int drawflag; } texture_t; -- 2.39.2