fix zero division in HWR_SplitSprite

same fix as HWR_SplitWall
this may throw nan texture uv coords into gl which may be uncool
This commit is contained in:
alufolie91 committed 2026-11-19 14:44:52 +01:00
1 parent 033e0cd416
commit 67bac0aa88
1 file changed
+13 -4
+13 -4
View File
@@ -1280,7 +1280,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
// To avoid division by zero, which would result in a NaN, we check if the vertical difference
// between the two vertices is not zero.
if (std::fpclassify(diff) == FP_ZERO)
pegmul = 0.0;
pegmul = 0.0f;
else
pegmul = (pegb - pegt) / diff;
@@ -1292,7 +1292,7 @@ static void HWR_SplitWall(sector_t *sector, FOutVector *wallVerts, INT32 texnum,
endpegb = wallVerts[1].t;
if (std::fpclassify(diff) == FP_ZERO)
endpegmul = 0.0;
endpegmul = 0.0f;
else
endpegmul = (endpegb - endpegt) / diff;
@@ -3856,7 +3856,16 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
realbot = bot = baseWallVerts[0].y;
towtop = baseWallVerts[3].t;
towbot = baseWallVerts[0].t;
towmult = (towbot - towtop) / (top - bot);
float diff = (top - bot);
// If both heights of a side lay on the same position, then this sprite is a triangle.
// To avoid division by zero, which would result in a NaN, we check if the vertical difference
// between the two vertices is not zero.
if (std::fpclassify(diff) == FP_ZERO)
towmult = 0.0f;
else
towmult = (towbot - towtop) / diff;
endrealtop = endtop = baseWallVerts[2].y;
endrealbot = baseWallVerts[1].y;
@@ -4027,7 +4036,7 @@ static void HWR_SplitSprite(gl_vissprite_t *spr, const boolean papersprite)
if ((endtop <= endrealbot) && (top <= realbot))
return;
// If we're ever down here, somehow the above loop hasn't draw all the light levels of sprite
// If we're ever down here, somehow the above loop hasn't drawn all the light levels of sprite
wallVerts[3].t = towtop + ((realtop - top) * towmult);
wallVerts[2].t = towtop + ((endrealtop - endtop) * towmult);
wallVerts[0].t = towtop + ((realtop - bot) * towmult);