Skip to content

Commit

Permalink
- fixed: rollsprites now 'unstretch' properly in regular y-billboarding
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed Apr 24, 2024
1 parent a3e61ce commit 586e899
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/rendering/hwrenderer/scene/hw_sprites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 586e899

Please sign in to comment.