- 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); const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER);
FVector2 offset = FVector2( offx, offy ); FVector2 offset = FVector2( offx, offy );
float xx = -center.X + x;
// Account for +ROLLCENTER flag. Takes the embedded image offsets and adds them in with SpriteOffsets. float yy = -center.Y + y;
if (drawRollSpriteActor && useOffsets) float zz = -center.Z + z;
{
offset.X += center.X - x;
offset.Y += center.Z - z;
}
// [Nash] check for special sprite drawing modes // [Nash] check for special sprite drawing modes
if (drawWithXYBillboard || isWallSprite) if (drawWithXYBillboard || isWallSprite)
{ {
// Compute center of sprite
mat.MakeIdentity(); mat.MakeIdentity();
mat.Translate(center.X, center.Z, center.Y); // move to sprite center 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); mat.Rotate(0, 1, 0, 0);
if (drawRollSpriteActor) if (drawRollSpriteActor)
{ {
if (useOffsets) mat.Translate(xx, zz, yy);
mat.Rotate(yawvecX, 0, yawvecY, rollDegrees); mat.Rotate(yawvecX, 0, yawvecY, rollDegrees);
if (useOffsets) mat.Translate(-xx, -zz, -yy);
} }
} }
else if (doRoll) else if (doRoll)
{ {
if (useOffsets) mat.Translate(xx, zz, yy);
if (drawWithXYBillboard) if (drawWithXYBillboard)
{ {
mat.Rotate(-sin(angleRad), 0, cos(angleRad), -HWAngles.Pitch.Degrees()); mat.Rotate(-sin(angleRad), 0, cos(angleRad), -HWAngles.Pitch.Degrees());
} }
mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees);
if (useOffsets) mat.Translate(-xx, -zz, -yy);
} }
else if (drawWithXYBillboard) else if (drawWithXYBillboard)
{ {
@ -503,7 +503,9 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
float rollDegrees = Angles.Roll.Degrees(); float rollDegrees = Angles.Roll.Degrees();
mat.Translate(center.X, center.Z, center.Y); mat.Translate(center.X, center.Z, center.Y);
if (useOffsets) mat.Translate(xx, zz, yy);
mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees); mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees);
if (useOffsets) mat.Translate(-xx, -zz, -yy);
mat.Translate(-center.X, -center.Z, -center.Y); mat.Translate(-center.X, -center.Z, -center.Y);
} }