- fixed alignment of sloped sprites.

The offset fields are not valid for them so thwy may not be used for offsetting.
This commit is contained in:
Christoph Oelckers 2021-12-31 11:55:25 +01:00
parent 717dd123e5
commit 1849fe541e
2 changed files with 13 additions and 5 deletions

View file

@ -78,7 +78,12 @@ static inline void get_floorspr_points(DCoreActor *spr, int32_t px, int32_t py,
vec2_t const span = { tileWidth(tilenum), tileHeight(tilenum)};
vec2_t const repeat = { spr->spr.xrepeat, spr->spr.yrepeat };
vec2_t adjofs = { tileLeftOffset(tilenum) + spr->spr.xoffset, tileTopOffset(tilenum) + spr->spr.yoffset };
vec2_t adjofs = { tileLeftOffset(tilenum), tileTopOffset(tilenum) };
if (heinum == 0)
{
adjofs.X += spr->spr.xoffset;
adjofs.Y += spr->spr.yoffset;
}
int32_t const ratio = ksqrt(heinum * heinum + 4096 * 4096);

View file

@ -282,19 +282,22 @@ void TGetFlatSpritePosition(const spritetypebase* spr, vec2_t pos, vec2_t* out,
int width, height, leftofs, topofs;
int ratio = ksqrt(heinum * heinum + 4096 * 4096);
int xo = heinum ? 0 : spr->xoffset;
int yo = heinum ? 0 : spr->yoffset;
if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize)
{
width = TileFiles.tiledata[spr->picnum].hiofs.xsize * spr->xrepeat;
height = TileFiles.tiledata[spr->picnum].hiofs.ysize * spr->yrepeat;
leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset) * spr->xrepeat;
topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + spr->yoffset) * spr->yrepeat;
leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + xo) * spr->xrepeat;
topofs = (TileFiles.tiledata[spr->picnum].hiofs.yoffs + yo) * spr->yrepeat;
}
else
{
width = (int)tex->GetDisplayWidth() * spr->xrepeat;
height = (int)tex->GetDisplayHeight() * spr->yrepeat;
leftofs = ((int)tex->GetDisplayLeftOffset() + spr->xoffset) * spr->xrepeat;
topofs = ((int)tex->GetDisplayTopOffset() + spr->yoffset) * spr->yrepeat;
leftofs = ((int)tex->GetDisplayLeftOffset() + xo) * spr->xrepeat;
topofs = ((int)tex->GetDisplayTopOffset() + yo) * spr->yrepeat;
}
if (spr->cstat & CSTAT_SPRITE_XFLIP) leftofs = -leftofs;