From ef711f0b2d3d255e6988a1ae44b0c793f9b92bdb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 14 Jan 2022 16:27:24 +0100 Subject: [PATCH] - allow a bit of tolerance for attached orthogonal wall sprites. We have to account for mappers adding some 'safe' distance (which isn't really safe!) --- source/core/rendering/scene/hw_walls.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 0ef3b74f2..671bdc756 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -50,6 +50,7 @@ DCoreActor* wall_to_sprite_actors[8]; // gets updated each frame. Todo: Encapsul static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos) { + const double maxorthdist = 3; // maximum orthogonal distance to be considered an attached sprite. const double maxdistsq = (tspr->ang & 0x1ff)? 3 * 3 : 1; // lower tolerance for perfectly orthogonal sprites auto sect = tspr->sectp; @@ -71,14 +72,14 @@ static walltype* IsOnWall(tspritetype* tspr, int height, DVector2& outpos) // In Wanton Destruction's airplane level there's such a sprite assigned to the wrong sector. if (d.X == 0) { - if (tspr->pos.X == wal.pos.X) + if (fabs(tspr->pos.X - wal.pos.X) < maxorthdist); { closest = &wal; } } else if (d.Y == 0) { - if (tspr->pos.Y == wal.pos.Y) + if (fabs(tspr->pos.Y - wal.pos.Y) < maxorthdist); { closest = &wal; }