- fixed: rollsprites now 'unstretch' properly in regular y-billboarding

This commit is contained in:
Rachael Alexanderson 2024-04-23 20:30:44 -04:00
parent a3e61ce33b
commit 586e89954a
No known key found for this signature in database
GPG key ID: 26A8ACCE97115EE0

View file

@ -355,6 +355,12 @@ void HandleSpriteOffsets(Matrix3x4 *mat, const FRotator *HW, FVector2 *offset, b
bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
{
float pixelstretch = 1.2;
if (actor && actor->Level)
pixelstretch = actor->Level->pixelstretch;
else if (particle && particle->subsector && particle->subsector->sector && particle->subsector->sector->Level)
pixelstretch = particle->subsector->sector->Level->pixelstretch;
FVector3 center = FVector3((x1 + x2) * 0.5, (y1 + y2) * 0.5, (z1 + z2) * 0.5);
const auto& HWAngles = di->Viewpoint.HWAngles;
Matrix3x4 mat;
@ -421,12 +427,6 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
// [Nash] check for special sprite drawing modes
if (drawWithXYBillboard || isWallSprite)
{
float pixelstretch = 1.2;
if (actor && actor->Level)
pixelstretch = actor->Level->pixelstretch;
else if (particle && particle->subsector && particle->subsector->sector && particle->subsector->sector->Level)
pixelstretch = particle->subsector->sector->Level->pixelstretch;
mat.MakeIdentity();
mat.Translate(center.X, center.Z, center.Y); // move to sprite center
mat.Scale(1.0, 1.0/pixelstretch, 1.0); // unstretch sprite by level aspect ratio
@ -509,9 +509,11 @@ bool HWSprite::CalculateVertices(HWDrawInfo* di, FVector3* v, DVector3* vp)
float rollDegrees = Angles.Roll.Degrees();
mat.Translate(center.X, center.Z, center.Y);
mat.Scale(1.0, 1.0/pixelstretch, 1.0); // unstretch sprite by level aspect ratio
if (useOffsets) mat.Translate(xx, zz, yy);
mat.Rotate(cos(angleRad), 0, sin(angleRad), rollDegrees);
if (useOffsets) mat.Translate(-xx, -zz, -yy);
mat.Scale(1.0, pixelstretch, 1.0); // stretch sprite by level aspect ratio
mat.Translate(-center.X, -center.Z, -center.Y);
}