From 59f18f5fa791f005e19d21b008f3a08bd9961bfa Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 7 Apr 2021 12:31:47 +0200 Subject: [PATCH] - ensure that all HWSprites are oriented with z1 > z2. This is required by the sorting code to work as intended. --- source/core/rendering/scene/hw_sprites.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/source/core/rendering/scene/hw_sprites.cpp b/source/core/rendering/scene/hw_sprites.cpp index 1637c1854..888a8b429 100644 --- a/source/core/rendering/scene/hw_sprites.cpp +++ b/source/core/rendering/scene/hw_sprites.cpp @@ -437,6 +437,12 @@ void HWSprite::Process(HWDrawInfo* di, spritetype* spr, sectortype* sector, int z1 = z + yoff; z2 = z + height + yoff; + if (z1 < z2) + { + // Make sure that z1 is the higher one. Some utilities expect it to be oriented this way. + std::swap(z1, z2); + std::swap(vt, vb); + } } else {