Fix regressions in HWR_RenderExtraTexture

This commit is contained in:
Lactozilla 2024-01-27 17:35:10 -03:00
parent b888832114
commit 28f6188bfb

View file

@ -1515,12 +1515,34 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
UINT8 clipside = 0; UINT8 clipside = 0;
// If the wall begins or ends entirely outside of the visible area, it needs to be cut // If the wall begins or ends entirely outside of the visible area, it needs to be cut
if ((h > highcut && l > highcut) boolean clip_top = false, clip_bottom = false;
|| (hS > highcutslope && lS > highcutslope))
boolean cut_bottom = (h < lowcut && l < lowcut) || (hS < lowcutslope && lS < lowcutslope);
boolean cut_top = (h > highcut && l > highcut) || (hS > highcutslope && lS > highcutslope);
if (IS_BOTTOM_EDGE_TEXTURE(which))
{ {
polypos = FixedToFloat(l); polypos = FixedToFloat(l);
polyslope = FixedToFloat(lS); polyslope = FixedToFloat(lS);
if (cut_bottom)
clip_bottom = true;
else
clip_top = cut_top;
}
else
{
polypos = FixedToFloat(h);
polyslope = FixedToFloat(hS);
if (cut_top)
clip_top = true;
else
clip_bottom = cut_bottom;
}
if (clip_top)
{
cutf = FixedToFloat(highcut); cutf = FixedToFloat(highcut);
cutslopef = FixedToFloat(highcutslope); cutslopef = FixedToFloat(highcutslope);
@ -1528,13 +1550,11 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
clipside = 1; clipside = 1;
else else
clipside = 2; clipside = 2;
}
else if ((h < lowcut && l < lowcut)
|| (hS < lowcutslope && lS < lowcutslope))
{
polypos = FixedToFloat(l);
polyslope = FixedToFloat(lS);
clip_top = false;
}
else if (clip_bottom)
{
cutf = FixedToFloat(lowcut); cutf = FixedToFloat(lowcut);
cutslopef = FixedToFloat(lowcutslope); cutslopef = FixedToFloat(lowcutslope);
@ -1542,6 +1562,8 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
clipside = 1; clipside = 1;
else else
clipside = 2; clipside = 2;
clip_bottom = false;
} }
if (clipside != 0) if (clipside != 0)
@ -1604,8 +1626,25 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
// Now split this wall // Now split this wall
boolean clip_low = false; boolean clip_low = false;
if (hS > highcutslope || h > highcut // If the top of the texture is above the top of the wall cut_bottom = lS > highcutslope || l > highcut || lS < lowcutslope || l < lowcut;
|| hS < lowcutslope || h < lowcut) // If the top of the texture is under the bottom of the wall cut_top = hS > highcutslope || h > highcut || hS < lowcutslope || h < lowcut;
if (IS_TOP_EDGE_TEXTURE(which))
{
if (cut_bottom)
clip_bottom = true;
else
clip_top = cut_top;
}
else
{
if (cut_top)
clip_top = true;
else
clip_bottom = cut_bottom;
}
if (clip_top)
{ {
polypos = FixedToFloat(h); polypos = FixedToFloat(h);
polyslope = FixedToFloat(hS); polyslope = FixedToFloat(hS);
@ -1640,8 +1679,7 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
cutslopef = FixedToFloat(highcutslope); cutslopef = FixedToFloat(highcutslope);
} }
} }
else if (lS > highcutslope || l > highcut // If the bottom of the texture is under the top of the wall else if (clip_bottom)
|| lS < lowcutslope || l < lowcut) // If the bottom of the texture is under the bottom of the wall
{ {
polypos = FixedToFloat(l); polypos = FixedToFloat(l);
polyslope = FixedToFloat(lS); polyslope = FixedToFloat(lS);
@ -1714,20 +1752,14 @@ static void HWR_RenderExtraTexture(unsigned which, side_t *side, sector_t *sec_f
xcliplow = (float)(xcliphigh - (flength * (1.0f - t) * FRACUNIT)); xcliplow = (float)(xcliphigh - (flength * (1.0f - t) * FRACUNIT));
} }
h = polytop; GET_CLIP_HEIGHTS();
l = polybottom;
hS = polytopslope;
lS = polybottomslope;
} }
// If it didn't intersect, render it normally
else
{
h = max(lowcut, min(highcut, polytop)); h = max(lowcut, min(highcut, polytop));
l = min(highcut, max(polybottom, lowcut)); l = min(highcut, max(polybottom, lowcut));
hS = max(lowcutslope, min(highcutslope, polytopslope)); hS = max(lowcutslope, min(highcutslope, polytopslope));
lS = min(highcutslope, max(polybottomslope, lowcutslope)); lS = min(highcutslope, max(polybottomslope, lowcutslope));
} }
}
// PEGGING // PEGGING
fixed_t texturevpeg, texturevpegslope; fixed_t texturevpeg, texturevpegslope;