Commit f89ca040 authored by Richard Gobeille's avatar Richard Gobeille

engine: shitcan zerovec and add rotatevec()

parent 2c94362a
......@@ -1307,6 +1307,15 @@ static FORCE_INLINE int32_t logapproach(int32_t const val, int32_t const targetv
}
void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * const p2) ATTRIBUTE((nonnull(4)));
static inline void rotatevec(vec2_t p, int16_t const daang, vec2_t * const p2)
{
int const dacos = sintable[(daang+2560)&2047];
int const dasin = sintable[(daang+2048)&2047];
*p2 = { dmulscale14(p.x, dacos, -p.y, dasin), dmulscale14(p.y, dacos, p.x, dasin) };
}
int32_t lastwall(int16_t point);
int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction);
......@@ -1624,8 +1633,6 @@ static FORCE_INLINE void renderEnableFog(void)
#endif
}
static vec2_t const zerovec = { 0, 0 };
static FORCE_INLINE CONSTEXPR int inside_p(int32_t const x, int32_t const y, int const sectnum) { return (sectnum >= 0 && inside(x, y, sectnum) == 1); }
#define SET_AND_RETURN(Lval, Rval) \
......
......@@ -632,7 +632,7 @@ void editorGet2dScreenCoordinates(int32_t *xres, int32_t *yres, int32_t x, int32
vec2_t coord = { x, y };
if (m32_sideview)
rotatepoint(zerovec, coord, m32_sideang, &coord);
rotatevec(coord, m32_sideang, &coord);
*xres = mulscale14(coord.x, zoome);
*yres = scalescreeny(mulscale14(coord.y, zoome));
......@@ -660,7 +660,7 @@ int32_t getinvdisplacement(int32_t *dx, int32_t *dy, int32_t dz)
vec2_t v[2] = { { 0, dz },{ *dx, *dy } };
rotatepoint(zerovec, v[0], -m32_sideang, &v[1]);
rotatevec(v[0], -m32_sideang, &v[1]);
*dx = v[1].x;
*dy = v[1].y;
......@@ -684,7 +684,7 @@ void editorSetup2dSideView(void)
m32_sidesin = sintable[m32_sideelev&2047];
m32_sidecos = sintable[(m32_sideelev+512)&2047];
rotatepoint(zerovec, m32_viewplane.vec2, -m32_sideang, &m32_viewplane.vec2);
rotatevec(m32_viewplane.vec2, -m32_sideang, &m32_viewplane.vec2);
m32_viewplane.x = mulscale14(m32_viewplane.x, m32_sidecos);
m32_viewplane.y = mulscale14(m32_viewplane.y, m32_sidecos);
m32_viewplane.z = m32_sidesin>>5;
......
......@@ -1478,7 +1478,7 @@ void editinput(void)
vec2_t da = { 16384, divscale14(searchx-(xdim>>1), xdim>>1) };
rotatepoint(zerovec, da, ang, &da);
rotatevec(da, ang, &da);
#ifdef USE_OPENGL
if (videoGetRenderMode() == REND_POLYMOST)
......@@ -8681,7 +8681,7 @@ void getpoint(int32_t searchxe, int32_t searchye, int32_t *x, int32_t *y)
{
if (m32_sidesin!=0)
svec.y = divscale14(svec.y, m32_sidesin);
rotatepoint(zerovec, svec, -m32_sideang, &svec);
rotatevec(svec, -m32_sideang, &svec);
}
*x = pos.x + divscale14(svec.x,zoom);
......
......@@ -734,7 +734,7 @@ int32_t clipsprite_initindex(int32_t curidx, uspriteptr_t const curspr, int32_t
{
wal->x *= flipx;
wal->y *= flipy;
rotatepoint(zerovec, wal->pos, rotang, &wal->pos);
rotatevec(wal->pos, rotang, &wal->pos);
}
wal->x += curspr->x;
......
......@@ -878,7 +878,7 @@ static int32_t move_rotfixed_sprite(int32_t spriteNum, int32_t pivotSpriteNum, i
A_CheckSpriteFlags(spriteNum, SFLAG_ROTFIXED))) &&
actor[spriteNum].t_data[7] == (ROTFIXSPR_MAGIC | pivotSpriteNum))
{
rotatepoint(zerovec, *(vec2_t *)&actor[spriteNum].t_data[8], pivotAngle & 2047, &sprite[spriteNum].pos.vec2);
rotatevec(*(vec2_t *)&actor[spriteNum].t_data[8], pivotAngle & 2047, &sprite[spriteNum].pos.vec2);
sprite[spriteNum].x += sprite[pivotSpriteNum].x;
sprite[spriteNum].y += sprite[pivotSpriteNum].y;
return 0;
......@@ -906,7 +906,7 @@ void A_MoveSector(int spriteNum)
{
vec2_t const origin = g_origins[originIdx];
vec2_t result;
rotatepoint(zerovec, origin, rotateAngle & 2047, &result);
rotatevec(origin, rotateAngle & 2047, &result);
dragpoint(wallNum, pSprite->x + result.x, pSprite->y + result.y, 0);
originIdx++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment