From ebb63499e031f277062a7b8a382ffc54d956651b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustaf=20Alh=C3=A4ll?= Date: Mon, 4 Nov 2024 21:07:15 +0100 Subject: [PATCH] Fix polyobject midtextures being stretched into infinity --- src/hardware/hw_main.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 4741c6a46..e58b62113 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -954,6 +954,7 @@ static boolean HWR_BlendMidtextureSurface(FSurfaceInfo *pSurf) static void HWR_RenderMidtexture(INT32 gl_midtexture, float cliplow, float cliphigh, fixed_t worldtop, fixed_t worldbottom, fixed_t worldhigh, fixed_t worldlow, fixed_t worldtopslope, fixed_t worldbottomslope, fixed_t worldhighslope, fixed_t worldlowslope, UINT32 lightnum, FOutVector *inWallVerts) { + sector_t *front, *back; FOutVector wallVerts[4]; FSurfaceInfo Surf; @@ -963,6 +964,16 @@ static void HWR_RenderMidtexture(INT32 gl_midtexture, float cliplow, float cliph if (!HWR_BlendMidtextureSurface(&Surf)) return; + if (gl_linedef->frontsector->heightsec != -1) + front = §ors[gl_linedef->frontsector->heightsec]; + else + front = gl_linedef->frontsector; + + if (gl_linedef->backsector->heightsec != -1) + back = §ors[gl_linedef->backsector->heightsec]; + else + back = gl_linedef->backsector; + fixed_t texheight = FixedDiv(textureheight[gl_midtexture], abs(gl_sidedef->scaley_mid)); INT32 repeats; @@ -972,15 +983,15 @@ static void HWR_RenderMidtexture(INT32 gl_midtexture, float cliplow, float cliph { fixed_t high, low; - if (gl_frontsector->ceilingheight > gl_backsector->ceilingheight) - high = gl_backsector->ceilingheight; + if (front->ceilingheight > back->ceilingheight) + high = back->ceilingheight; else - high = gl_frontsector->ceilingheight; + high = front->ceilingheight; - if (gl_frontsector->floorheight > gl_backsector->floorheight) - low = gl_frontsector->floorheight; + if (front->floorheight > back->floorheight) + low = front->floorheight; else - low = gl_backsector->floorheight; + low = back->floorheight; repeats = (high - low) / texheight; if ((high - low) % texheight) @@ -1007,8 +1018,8 @@ static void HWR_RenderMidtexture(INT32 gl_midtexture, float cliplow, float cliph if (gl_curline->polyseg) { // Change this when polyobjects support slopes - popentop = popentopslope = gl_curline->backsector->ceilingheight; - popenbottom = popenbottomslope = gl_curline->backsector->floorheight; + popentop = popentopslope = back->ceilingheight; + popenbottom = popenbottomslope = back->floorheight; } else {