From fe0de5053a42beac7c4433e9543488243b34d8a0 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Wed, 13 Mar 2024 14:47:37 -0500 Subject: [PATCH] - Fixed: ROLLCENTER was always being applied even when the flag wasn't present. --- src/rendering/hwrenderer/scene/hw_sprites.cpp | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index 3fa433133f..37b4d1a29b 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -415,18 +415,13 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER); FVector2 offset = FVector2( offx, offy ); - - // Account for +ROLLCENTER flag. Takes the embedded image offsets and adds them in with SpriteOffsets. - if (drawRollSpriteActor && useOffsets) - { - offset.X += center.X - x; - offset.Y += center.Z - z; - } - + float xx = -center.X + x; + float yy = -center.Y + y; + float zz = -center.Z + z; // [Nash] check for special sprite drawing modes if (drawWithXYBillboard || isWallSprite) { - // Compute center of sprite + mat.MakeIdentity(); mat.Translate(center.X, center.Z, center.Y); // move to sprite center @@ -461,16 +456,21 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) mat.Rotate(0, 1, 0, 0); if (drawRollSpriteActor) { + + if (useOffsets) mat.Translate(xx, zz, yy); mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); } } else if (doRoll) { + if (useOffsets) mat.Translate(xx, zz, yy); if (drawWithXYBillboard) { mat.Rotate(-sin(angleRad), 0, cos(angleRad), -HWAngles.Pitch.Degrees()); } mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); } else if (drawWithXYBillboard) { @@ -503,7 +503,9 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp) float rollDegrees = Angles.Roll.Degrees(); mat.Translate(center.X, center.Z, center.Y); + if (useOffsets) mat.Translate(xx, zz, yy); mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); + if (useOffsets) mat.Translate(-xx, -zz, -yy); mat.Translate(-center.X, -center.Z, -center.Y); }