mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
- floatified GetWallSpritePosition and redirected get_wallspr_points to use it.
This commit is contained in:
parent
129457044c
commit
91f305125e
4 changed files with 24 additions and 43 deletions
|
@ -37,28 +37,10 @@ inline uint8_t bitmap_test(uint8_t const* const ptr, int const n) { return ptr[n
|
|||
// rest x/y: out
|
||||
static inline void get_wallspr_points(DCoreActor* actor, int32_t *x1, int32_t *x2, int32_t *y1, int32_t *y2)
|
||||
{
|
||||
//These lines get the 2 points of the rotated sprite
|
||||
//Given: (x1, y1) starts out as the center point
|
||||
|
||||
const int32_t tilenum=actor->spr.picnum, ang=actor->int_ang();
|
||||
const int32_t xrepeat = actor->spr.xrepeat;
|
||||
int32_t xoff = tileLeftOffset(tilenum) + actor->spr.xoffset;
|
||||
int32_t k, l, dax, day;
|
||||
|
||||
if (actor->spr.cstat & CSTAT_SPRITE_XFLIP)
|
||||
xoff = -xoff;
|
||||
|
||||
dax = bsin(ang) * xrepeat;
|
||||
day = -bcos(ang) * xrepeat;
|
||||
|
||||
l = tileWidth(tilenum);
|
||||
k = (l>>1)+xoff;
|
||||
|
||||
*x1 -= MulScale(dax,k, 16);
|
||||
*x2 = *x1 + MulScale(dax,l, 16);
|
||||
|
||||
*y1 -= MulScale(day,k, 16);
|
||||
*y2 = *y1 + MulScale(day,l, 16);
|
||||
DVector2 out[2];
|
||||
GetWallSpritePosition(&actor->spr, DVector2(*x1 * inttoworld, *y1 * inttoworld), out);
|
||||
*x1 = int(out[0].X * worldtoint); *y1 = int(out[0].Y * worldtoint);
|
||||
*x2 = int(out[1].X * worldtoint); *y2 = int(out[1].Y * worldtoint);
|
||||
}
|
||||
|
||||
// x1, y1: in/out
|
||||
|
|
|
@ -287,33 +287,32 @@ double SquareDistToSector(double px, double py, const sectortype* sect, DVector2
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void GetWallSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, bool render)
|
||||
void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVector2* out, bool render)
|
||||
{
|
||||
auto tex = tileGetTexture(spr->picnum);
|
||||
|
||||
int width, leftofs;
|
||||
double width, xoffset;
|
||||
if (render && hw_hightile && TileFiles.tiledata[spr->picnum].hiofs.xsize)
|
||||
{
|
||||
width = TileFiles.tiledata[spr->picnum].hiofs.xsize;
|
||||
leftofs = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset);
|
||||
xoffset = (TileFiles.tiledata[spr->picnum].hiofs.xoffs + spr->xoffset);
|
||||
}
|
||||
else
|
||||
{
|
||||
width = (int)tex->GetDisplayWidth();
|
||||
leftofs = ((int)tex->GetDisplayLeftOffset() + spr->xoffset);
|
||||
width = tex->GetDisplayWidth();
|
||||
xoffset = tex->GetDisplayLeftOffset() + spr->xoffset;
|
||||
}
|
||||
|
||||
int x = bsin(spr->int_ang()) * spr->xrepeat;
|
||||
int y = -bcos(spr->int_ang()) * spr->xrepeat;
|
||||
double x = spr->angle.Sin() * spr->xrepeat * (1. / 64.);
|
||||
double y = -spr->angle.Cos() * spr->xrepeat * (1. / 64.);
|
||||
|
||||
int xoff = leftofs;
|
||||
if (spr->cstat & CSTAT_SPRITE_XFLIP) xoff = -xoff;
|
||||
int origin = (width >> 1) + xoff;
|
||||
if (spr->cstat & CSTAT_SPRITE_XFLIP) xoffset = -xoffset;
|
||||
double origin = (width * 0.5) + xoffset;
|
||||
|
||||
out[0].X = pos.X - MulScale(x, origin, 16);
|
||||
out[0].Y = pos.Y - MulScale(y, origin, 16);
|
||||
out[1].X = out[0].X + MulScale(x, width, 16);
|
||||
out[1].Y = out[0].Y + MulScale(y, width, 16);
|
||||
out[0].X = pos.X - x * origin;
|
||||
out[0].Y = pos.Y - y * origin;
|
||||
out[1].X = out[0].X + x * width;
|
||||
out[1].Y = out[0].Y + y * width;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -265,7 +265,7 @@ int getslopeval(sectortype* sect, int x, int y, int z, int planez);
|
|||
|
||||
|
||||
void setWallSectors();
|
||||
void GetWallSpritePosition(const tspritetype* spr, vec2_t pos, vec2_t* out, bool render = false);
|
||||
void GetWallSpritePosition(const spritetypebase* spr, const DVector2& pos, DVector2* out, bool render = false);
|
||||
void GetFlatSpritePosition(DCoreActor* spr, const DVector2& pos, DVector2* out, bool render = false);
|
||||
void GetFlatSpritePosition(const tspritetype* spr, const DVector2& pos, DVector2* out, double* outz, bool render = false);
|
||||
void checkRotatedWalls();
|
||||
|
|
|
@ -1127,14 +1127,14 @@ void HWWall::ProcessWallSprite(HWDrawInfo* di, tspritetype* spr, sectortype* sec
|
|||
|
||||
seg = nullptr;
|
||||
Sprite = spr;
|
||||
vec2_t pos[2];
|
||||
DVector2 pos[2];
|
||||
int sprz = spr->int_pos().Z;
|
||||
|
||||
GetWallSpritePosition(spr, spr->int_pos().vec2, pos, true);
|
||||
glseg.x1 = pos[0].X * (1 / 16.f);
|
||||
glseg.y1 = pos[0].Y * (1 / -16.f);
|
||||
glseg.x2 = pos[1].X * (1 / 16.f);
|
||||
glseg.y2 = pos[1].Y * (1 / -16.f);
|
||||
GetWallSpritePosition(spr, spr->pos.XY(), pos, true);
|
||||
glseg.x1 = pos[0].X;
|
||||
glseg.y1 = -pos[0].Y;
|
||||
glseg.x2 = pos[1].X;
|
||||
glseg.y2 = -pos[1].Y;
|
||||
|
||||
if (spr->cstat & CSTAT_SPRITE_ONE_SIDE)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue