Skip to content

Commit

Permalink
- make roll and flat sprites square
Browse files Browse the repository at this point in the history
  • Loading branch information
madame-rachelle committed May 3, 2024
1 parent bcad040 commit 7ef6fa9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/rendering/hwrenderer/scene/hw_sprites.cpp
Expand Up @@ -355,11 +355,7 @@ 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;
float pixelstretch = di->Level->pixelstretch;

FVector3 center = FVector3((x1 + x2) * 0.5, (y1 + y2) * 0.5, (z1 + z2) * 0.5);
const auto& HWAngles = di->Viewpoint.HWAngles;
Expand Down Expand Up @@ -1005,6 +1001,13 @@ void HWSprite::Process(HWDrawInfo *di, AActor* thing, sector_t * sector, area_t

r.Scale(sprscale.X, isSpriteShadow ? sprscale.Y * 0.15 : sprscale.Y);

if (thing->renderflags & (RF_ROLLSPRITE|RF_FLATSPRITE))
{
double ps = di->Level->pixelstretch;
double mult = 2 * ps / (ps * ps + 1); // shrink slightly
r.Scale(mult * ps, mult);
}

float rightfac = -r.left;
float leftfac = rightfac - r.width;
z1 = z - r.top;
Expand Down Expand Up @@ -1521,6 +1524,13 @@ void HWSprite::AdjustVisualThinker(HWDrawInfo* di, DVisualThinker* spr, sector_t
auto r = spi.GetSpriteRect();
r.Scale(spr->Scale.X, spr->Scale.Y);

if (spr->PT.flags & SPF_ROLL)
{
double ps = di->Level->pixelstretch;
double mult = 2 * ps / (ps * ps + 1); // shrink slightly
r.Scale(mult * ps, mult);
}

if (spr->bXFlip)
{
std::swap(ul,ur);
Expand Down

0 comments on commit 7ef6fa9

Please sign in to comment.