From 1345c8e7b43f4828b39da5555c7c43be40f85359 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 29 Apr 2018 19:28:13 +0200 Subject: [PATCH] - fixed: NewDecal should not be called unless it is guaranteed that the decal will be rendered. This left partially initialized items in the render list. --- src/hwrenderer/scene/hw_decal.cpp | 58 ++++++++++++++++--------------- 1 file changed, 30 insertions(+), 28 deletions(-) diff --git a/src/hwrenderer/scene/hw_decal.cpp b/src/hwrenderer/scene/hw_decal.cpp index 3dd2972c8f..423d112764 100644 --- a/src/hwrenderer/scene/hw_decal.cpp +++ b/src/hwrenderer/scene/hw_decal.cpp @@ -112,34 +112,9 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal) zpos = decal->Z + frontsector->GetPlaneTexZ(sector_t::ceiling); } } + FMaterial *tex = FMaterial::ValidateTexture(texture, true); - GLDecal &gldecal = *di->AddDecal(type == RENDERWALL_MIRRORSURFACE); - gldecal.gltexture = FMaterial::ValidateTexture(texture, true); - gldecal.wall = this; - gldecal.decal = decal; - - if (decal->RenderFlags & RF_FULLBRIGHT) - { - gldecal.light = 255; - gldecal.rel = 0; - } - else - { - gldecal.light = lightlevel; - gldecal.rel = rellight + getExtraLight(); - } - - gldecal.colormap = Colormap; - - if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) - { - gldecal.colormap.Decolorize(); - } - - gldecal.a = decal->Alpha; - // now clip the decal to the actual polygon - FMaterial *tex = gldecal.gltexture; float decalwidth = tex->TextureWidth() * decal->ScaleX; float decalheight = tex->TextureHeight() * decal->ScaleY; @@ -178,13 +153,15 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal) right = decalpixpos + decalwidth; righttex = decalwidth; } - if (right <= left) return; // nothing to draw + if (right <= left) + return; // nothing to draw + // one texture unit on the wall as vector float vx = (glseg.x2 - glseg.x1) / linelength; float vy = (glseg.y2 - glseg.y1) / linelength; - DecalVertex *dv = gldecal.dv; + DecalVertex dv[4]; dv[1].x = dv[0].x = glseg.x1 + vx * left; dv[1].y = dv[0].y = glseg.y1 + vy * left; @@ -251,7 +228,32 @@ void GLWall::ProcessDecal(HWDrawInfo *di, DBaseDecal *decal) for (i = 0; i < 4; i++) dv[i].v = vb - dv[i].v; } + GLDecal &gldecal = *di->AddDecal(type == RENDERWALL_MIRRORSURFACE); + gldecal.gltexture = tex; + gldecal.wall = this; + gldecal.decal = decal; + + if (decal->RenderFlags & RF_FULLBRIGHT) + { + gldecal.light = 255; + gldecal.rel = 0; + } + else + { + gldecal.light = lightlevel; + gldecal.rel = rellight + getExtraLight(); + } + + gldecal.colormap = Colormap; + + if (level.flags3 & LEVEL3_NOCOLOREDSPRITELIGHTING) + { + gldecal.colormap.Decolorize(); + } + + gldecal.a = decal->Alpha; gldecal.zcenter = zpos - decalheight * 0.5f; + memcpy(gldecal.dv, dv, sizeof(dv)); auto verts = di->AllocVertices(4); gldecal.vertindex = verts.second;