- buildutils: Replace sintable[] use within SW's weapon.cpp with bsin()/bcos().

This commit is contained in:
Mitchell Richters 2020-11-15 21:53:47 +11:00 committed by Christoph Oelckers
parent a7a223c13d
commit feb6d023fa

View file

@ -3822,8 +3822,8 @@ AutoShrap:
shrap_ysize = u->sy = 12 + (RANDOM_P2(32<<8)>>8);
u->Counter = (RANDOM_P2(2048<<5)>>5);
nx = sintable[NORM_ANGLE(sp->ang+512)]>>6;
ny = sintable[sp->ang]>>6;
nx = bcos(sp->ang, -6);
ny = bsin(sp->ang, -6);
move_missile(SpriteNum, nx, ny, 0, Z(8), Z(8), CLIPMASK_MISSILE, MISSILEMOVETICS);
if (RANDOM_P2(1024)<700)
@ -3897,9 +3897,8 @@ DoVomit(short SpriteNum)
USERp u = User[SpriteNum];
u->Counter = NORM_ANGLE(u->Counter + (30*MISSILEMOVETICS));
sp->xrepeat = u->sx + ((12 * sintable[NORM_ANGLE(u->Counter+512)]) >> 14);
sp->yrepeat = u->sy + ((12 * sintable[u->Counter]) >> 14);
sp->xrepeat = u->sx + mulscale14(12, bcos(u->Counter));
sp->yrepeat = u->sy + mulscale14(12, bsin(u->Counter));
if (TEST(u->Flags, SPR_JUMPING))
{
DoJump(SpriteNum);
@ -3948,8 +3947,8 @@ DoVomit(short SpriteNum)
USERp u = User[SpriteNum];
u->Counter = NORM_ANGLE(u->Counter + (30*MISSILEMOVETICS));
sp->xrepeat = u->sx + ((12 * sintable[NORM_ANGLE(u->Counter+512)]) >> 14);
sp->yrepeat = u->sy + ((12 * sintable[u->Counter]) >> 14);
sp->xrepeat = u->sx + mulscale14(12, bcos(u->Counter));
sp->yrepeat = u->sy + mulscale14(12, bsin(u->Counter));
if (TEST(u->Flags, SPR_JUMPING))
{
@ -4684,9 +4683,9 @@ WeaponMoveHit(short SpriteNum)
// on walls, so look with hitscan
hitscan((vec3_t *)sp, sp->sectnum, // Start position
sintable[NORM_ANGLE(sp->ang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(sp->ang)], // Y vector of 3D ang
sp->zvel, // Z vector of 3D ang
bcos(sp->ang), // X vector of 3D ang
bsin(sp->ang), // Y vector of 3D ang
sp->zvel, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -8821,9 +8820,9 @@ void WallBounce(short SpriteNum, short ang)
u->bounce++;
//k = cos(ang) * sin(ang) * 2
k = mulscale13(sintable[NORM_ANGLE(ang+512)], sintable[ang]);
k = mulscale13(bcos(ang), bsin(ang));
//l = cos(ang * 2)
l = sintable[NORM_ANGLE((ang*2)+512)];
l = bcos(ang << 1);
dax = -u->xchange;
day = -u->ychange;
@ -8893,8 +8892,8 @@ bool SlopeBounce(short SpriteNum, bool *hit_wall)
// k is now the slope of the ceiling or floor
// normal vector of the slope
dax = mulscale14(slope, sintable[(daang)&2047]);
day = mulscale14(slope, sintable[(daang+1536)&2047]);
dax = mulscale14(slope, bsin(daang));
day = mulscale14(slope, -bcos(daang));
daz = 4096; // 4096 = 45 degrees
// reflection code
@ -11716,9 +11715,9 @@ InitMineShrap(short SpriteNum)
daz -= DIV2(Z(48)<<3);
FAFhitscan(sp->x, sp->y, sp->z - Z(30), sp->sectnum, // Start position
sintable[NORM_ANGLE(ang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(ang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(ang), // X vector of 3D ang
bsin(ang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -12310,8 +12309,8 @@ DoBloodWorm(int16_t Weapon)
ang = NORM_ANGLE(sp->ang + 512);
xvect = sintable[NORM_ANGLE(ang+512)];
yvect = sintable[ang];
xvect = bcos(ang);
yvect = bsin(ang);
bx = sp->x;
by = sp->y;
@ -12423,8 +12422,8 @@ DoBloodWorm(int16_t Weapon)
ang = NORM_ANGLE(sp->ang + 512);
xvect = sintable[NORM_ANGLE(ang+512)];
yvect = sintable[ang];
xvect = bcos(ang);
yvect = bsin(ang);
bx = sp->x;
by = sp->y;
@ -12825,8 +12824,8 @@ DoRing(int16_t Weapon)
sp->ang = NORM_ANGLE(sp->ang + (4 * RINGMOVETICS) + RINGMOVETICS);
// put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
sp->x += mulscale14(u->Dist, bcos(sp->ang));
sp->y += mulscale14(u->Dist, bsin(sp->ang));
if (User[sp->owner]->PlayerP)
sp->z += (u->Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9;
@ -12913,8 +12912,8 @@ InitSpellRing(PLAYERp pp)
//SET(u->Flags, SPR_XFLIP_TOGGLE);
// put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(sp->ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[sp->ang]) >> 14;
sp->x += mulscale14(u->Dist, bcos(sp->ang));
sp->y += mulscale14(u->Dist, bsin(sp->ang));
sp->z = pp->posz + Z(20) + ((u->Dist * (-pp->horizon.horiz.asq16() >> 9)) >> 9);
sp->ang = NORM_ANGLE(sp->ang + 512);
@ -12975,8 +12974,8 @@ DoSerpRing(int16_t Weapon)
sp->ang = NORM_ANGLE(sp->ang - (28 * RINGMOVETICS));
// put it out there
sp->x += ((int) u->Dist * (int) sintable[NORM_ANGLE(u->slide_ang + 512)]) >> 14;
sp->y += ((int) u->Dist * (int) sintable[u->slide_ang]) >> 14;
sp->x += mulscale14(u->Dist, bcos(u->slide_ang));
sp->y += mulscale14(u->Dist, bsin(u->slide_ang));
setsprite(Weapon, (vec3_t *)sp);
@ -13228,8 +13227,8 @@ InitSerpRing(short SpriteNum)
nu->spal = np->pal = 27; // Bright Green
// put it out there
np->x += ((int) nu->Dist * (int) sintable[NORM_ANGLE(np->ang + 512)]) >> 14;
np->y += ((int) nu->Dist * (int) sintable[np->ang]) >> 14;
np->x += mulscale14(nu->Dist, bcos(np->ang));
np->y += mulscale14(nu->Dist, bsin(np->ang));
np->z = SPRITEp_TOS(sp) + Z(20);
np->ang = NORM_ANGLE(np->ang + 512);
@ -13764,9 +13763,9 @@ InitSwordAttack(PLAYERp pp)
daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(daang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -13955,9 +13954,9 @@ InitFistAttack(PLAYERp pp)
daz = -mulscale16(pp->horizon.horiz.asq16(), 2000) + (RANDOM_RANGE(24000) - 12000);
FAFhitscan(pp->posx, pp->posy, pp->posz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(daang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -14461,8 +14460,8 @@ AimHitscanToTarget(SPRITEp sp, int *z, short *ang, int z_ratio)
{
zh = SPRITEp_UPPER(hp);
xvect = sintable[NORM_ANGLE(*ang + 512)];
yvect = sintable[NORM_ANGLE(*ang)];
xvect = bcos(*ang);
yvect = bsin(*ang);
if (hp->x - sp->x != 0)
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
@ -14523,8 +14522,8 @@ WeaponAutoAimHitscan(SPRITEp sp, int *z, short *ang, bool test)
{
zh = SPRITEp_TOS(hp) + DIV4(SPRITEp_SIZE_Z(hp));
xvect = sintable[NORM_ANGLE(*ang + 512)];
yvect = sintable[NORM_ANGLE(*ang)];
xvect = bcos(*ang);
yvect = bsin(*ang);
if (hp->x - sp->x != 0)
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
@ -14562,8 +14561,8 @@ WeaponHitscanShootFeet(SPRITEp sp, SPRITEp hp, int *zvect)
zh = SPRITEp_BOS(hp) + Z(20);
z = sp->z;
xvect = sintable[NORM_ANGLE(ang + 512)];
yvect = sintable[NORM_ANGLE(ang)];
xvect = bcos(ang);
yvect = bsin(ang);
if (hp->x - sp->x != 0)
//*z = xvect * ((zh - *z)/(hp->x - sp->x));
@ -14988,8 +14987,8 @@ InitShotgun(PLAYERp pp)
ndaang = NORM_ANGLE(daang + (RANDOM_RANGE(70) - 30));
}
xvect = sintable[NORM_ANGLE(ndaang + 512)];
yvect = sintable[NORM_ANGLE(ndaang)];
xvect = bcos(ndaang);
yvect = bsin(ndaang);
zvect = ndaz;
FAFhitscan(nx, ny, nz, nsect, // Start position
xvect, yvect, zvect,
@ -16105,9 +16104,9 @@ WallSpriteInsideSprite(SPRITEp wsp, SPRITEp sp)
xoff = -xoff;
// x delta
dax = sintable[wsp->ang] * wsp->xrepeat;
dax = bsin(wsp->ang) * wsp->xrepeat;
// y delta
day = sintable[NORM_ANGLE(wsp->ang + 1024 + 512)] * wsp->xrepeat;
day = -bcos(wsp->ang) * wsp->xrepeat;
xsiz = tilesiz[wsp->picnum].x;
mid_dist = DIV2(xsiz) + xoff;
@ -17081,8 +17080,8 @@ InitCoolgFire(short SpriteNum)
wu->ychange = MOVEy(wp->xvel, wp->ang);
wu->zchange = wp->zvel;
nx = ((int) 728 * (int) sintable[NORM_ANGLE(nang + 512)]) >> 14;
ny = ((int) 728 * (int) sintable[nang]) >> 14;
nx = mulscale14(728, bcos(nang));
ny = mulscale14(728, bsin(nang));
move_missile(w, nx, ny, 0L, wu->ceiling_dist, wu->floor_dist, 0, 3L);
@ -17734,9 +17733,9 @@ int SpawnWallHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_
sp->ang = NORM_ANGLE(wall_ang + 1024);
// int nx,ny;
//nx = (sintable[(512 + Player[0].angle.ang.asbuild()) & 2047] >> 7);
//ny = (sintable[Player[0].angle.ang.asbuild()] >> 7);
//int nx,ny;
//nx = Player[0].angle.ang.bcos(-7);
//ny = Player[0].angle.ang.bsin(-7);
//sp->x -= nx;
//sp->y -= ny;
@ -17764,12 +17763,12 @@ HitscanSpriteAdjust(short SpriteNum, short hit_wall)
#endif
#if 0
xvect = (sintable[(512 + ang) & 2047] >> 7);
yvect = (sintable[ang] >> 7);
xvect = bcos(ang, -7);
yvect = bsin(ang, -7);
move_missile(SpriteNum, xvect, yvect, 0L, CEILING_DIST, FLOOR_DIST, CLIPMASK_MISSILE, 4L);
#else
xvect = sintable[(512 + ang) & 2047] << 4;
yvect = sintable[ang] << 4;
xvect = bcos(ang, 4);
yvect = bsin(ang, 4);
clipmoveboxtracenum = 1;
@ -17848,8 +17847,8 @@ InitUzi(PLAYERp pp)
}
xvect = sintable[NORM_ANGLE(daang + 512)];
yvect = sintable[NORM_ANGLE(daang)];
xvect = bcos(daang);
yvect = bsin(daang);
zvect = daz;
FAFhitscan(pp->posx, pp->posy, nz, pp->cursectnum, // Start position
xvect,yvect,zvect,
@ -18034,9 +18033,9 @@ InitEMP(PLAYERp pp)
}
FAFhitscan(pp->posx, pp->posy, nz, pp->cursectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(daang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
j = SpawnSprite(STAT_MISSILE, EMP, s_EMPBurst, hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z, daang, 0);
@ -18585,9 +18584,9 @@ InitSobjMachineGun(short SpriteNum, PLAYERp pp)
}
FAFhitscan(nx, ny, nz, nsect, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(daang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -18997,8 +18996,8 @@ InitTurretMgun(SECTOR_OBJECTp sop)
}
}
xvect = sintable[NORM_ANGLE(daang + 512)];
yvect = sintable[NORM_ANGLE(daang)];
xvect = bcos(daang);
yvect = bsin(daang);
zvect = daz;
FAFhitscan(nx, ny, nz, nsect, // Start position
@ -19146,9 +19145,9 @@ InitEnemyUzi(short SpriteNum)
}
FAFhitscan(sp->x, sp->y, sp->z - zh, sp->sectnum, // Start position
sintable[NORM_ANGLE(daang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(daang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(daang), // X vector of 3D ang
bsin(daang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -19486,7 +19485,7 @@ InitMine(PLAYERp pp)
wu->xchange = MOVEx(wp->xvel, wp->ang);
wu->ychange = MOVEy(wp->xvel, wp->ang);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, sintable[NORM_ANGLE(pp->angle.ang.asbuild()+512)], sintable[pp->angle.ang.asbuild()]);
dot = DOT_PRODUCT_2D(pp->xvect, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
// don't adjust for strafing
if (labs(dot) > 10000)
@ -20632,8 +20631,8 @@ int QueueHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z)
sp->ang = wall_ang;
// move it back some
nx = sintable[(512 + sp->ang) & 2047]<<4;
ny = sintable[sp->ang]<<4;
nx = bcos(sp->ang, 4);
ny = bsin(sp->ang, 4);
sectnum = sp->sectnum;
@ -20876,9 +20875,9 @@ int QueueWallBlood(short hit_sprite, short ang)
dang = (ang+(RANDOM_P2(128<<5) >> 5)) - DIV2(128);
FAFhitscan(hsp->x, hsp->y, hsp->z - Z(30), hsp->sectnum, // Start position
sintable[NORM_ANGLE(dang + 512)], // X vector of 3D ang
sintable[NORM_ANGLE(dang)], // Y vector of 3D ang
daz, // Z vector of 3D ang
bcos(dang), // X vector of 3D ang
bsin(dang), // Y vector of 3D ang
daz, // Z vector of 3D ang
&hitinfo, CLIPMASK_MISSILE);
if (hitinfo.sect < 0)
@ -20951,8 +20950,8 @@ int QueueWallBlood(short hit_sprite, short ang)
sp->ang = wall_ang;
// move it back some
nx = sintable[(512 + sp->ang) & 2047]<<4;
ny = sintable[sp->ang]<<4;
nx = bcos(sp->ang, 4);
ny = bsin(sp->ang, 4);
sectnum = sp->sectnum;