- Fixed: ROLLCENTER was always being applied even when the flag wasn't present.

This commit is contained in:
Major Cooke 2024-03-13 14:47:37 -05:00 committed by Ricardo Luís Vaz Silva
parent 341c1bbede
commit fe0de5053a

View file

@ -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);
}