From 82ff1dbd06d1298e3a31522d6cb5839f6ee643b7 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Thu, 7 Apr 2016 21:39:23 -0600 Subject: [PATCH] light: don't save lightmaps for "trigger" texture --- light/ltface.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/light/ltface.c b/light/ltface.c index 89d3643b..7d5edadc 100644 --- a/light/ltface.c +++ b/light/ltface.c @@ -1698,6 +1698,17 @@ void LightFaceShutdown(struct ltface_ctx *ctx) free(ctx); } +static const char * +Face_TextureName(const bsp2_t *bsp, const bsp2_dface_t *face) +{ + int texnum = bsp->texinfo[face->texinfo].miptex; + const dmiptexlump_t *miplump = bsp->dtexdata.header; + if (!miplump->dataofs[texnum]) + return ""; //sometimes the texture just wasn't written. including its name. + const miptex_t *miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[texnum]); + return miptex->name; +} + /* * ============ * LightFace @@ -1715,7 +1726,8 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, const bsp2_t *bsp = ctx->bsp; lightmap_t *lightmaps = ctx->lightmaps; lightsurf_t *lightsurf = &ctx->lightsurf; - + const char *texname = Face_TextureName(bsp, face); + /* One extra lightmap is allocated to simplify handling overflow */ /* some surfaces don't need lightmaps */ @@ -1733,29 +1745,29 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, } if (bsp->texinfo[face->texinfo].flags & TEX_SPECIAL) { - int texnum = bsp->texinfo[face->texinfo].miptex; - dmiptexlump_t *miplump = bsp->dtexdata.header; - miptex_t *miptex; int turbtype; if (!lightturb) - return; - if (!miplump->dataofs[texnum]) + return; + if (*texname == '\0') return; //sometimes the texture just wasn't written. including its name. - miptex = (miptex_t*)(bsp->dtexdata.base + miplump->dataofs[texnum]); - if (*miptex->name != '*') + if (*texname != '*') return; //non-water surfaces should still not be lit //texture name starts with a *, so light it anyway. - if (!Q_strncasecmp(miptex->name, "*tele", 5)) + if (!Q_strncasecmp(texname, "*tele", 5)) turbtype = 3; - else if (!Q_strncasecmp(miptex->name, "*lava", 5)) + else if (!Q_strncasecmp(texname, "*lava", 5)) turbtype = 2; - else if (!Q_strncasecmp(miptex->name, "*slime", 6)) + else if (!Q_strncasecmp(texname, "*slime", 6)) turbtype = 1; else turbtype = 0; if (!(lightturb & (1u<