From 5bb438b817ce9d03eb4850375406a8bc789d527a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 16 May 2021 12:17:26 +0200 Subject: [PATCH] - new renderer: fixed bad positioning when a y-flipped wall sprite had to be clipped to floor or ceiling. --- source/core/rendering/scene/hw_walls.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index c673c26de..499459c2a 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -1088,10 +1088,17 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, spritetype* spr, sectortype* sect zbottom[0] = zbottom[1] = (sprz) * (1 / -256.); ztop[0] = ztop[1] = (sprz - ((height * spr->yrepeat) << 2)) * (1 / -256.); + if (zbottom[0] > ztop[0]) + { + // reorder coordinates to make the clipping code below behave. + auto zz = zbottom[0]; + zbottom[0] = zbottom[1] = ztop[0]; + ztop[0] = ztop[1] = zz; + } // Clip sprites to ceilings/floors - float origz = ztop[0]; - float polyh = (zbottom[0] - origz); + float origz = zbottom[0]; + float polyh = (ztop[0] - origz); if (!(sector->ceilingstat & CSTAT_SECTOR_SKY)) { float ceilingz = sector->ceilingz * (1 / -256.f);