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

This commit is contained in:
Mitchell Richters 2020-11-15 20:41:01 +11:00 committed by Christoph Oelckers
parent c2c49bd0b9
commit e60747a913

View file

@ -350,7 +350,7 @@ DoShadows(tspriteptr_t tsp, int viewz, bool mirror)
else else
{ {
int const camang = mirror ? NORM_ANGLE(2048 - Player[screenpeek].siang) : Player[screenpeek].siang; int const camang = mirror ? NORM_ANGLE(2048 - Player[screenpeek].siang) : Player[screenpeek].siang;
vec2_t const ofs = { sintable[NORM_ANGLE(camang+512)]>>11, sintable[NORM_ANGLE(camang)]>>11}; vec2_t const ofs = { bcos(camang, -11), bsin(camang, -11) };
New->x += ofs.x; New->x += ofs.x;
New->y += ofs.y; New->y += ofs.y;
@ -947,8 +947,8 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
ang = nang->asbuild() + pp->view_outside_dang; ang = nang->asbuild() + pp->view_outside_dang;
// Calculate the vector (nx,ny,nz) to shoot backwards // Calculate the vector (nx,ny,nz) to shoot backwards
vx = (sintable[NORM_ANGLE(ang + 1536)] >> 3); vx = -bcos(ang, -3);
vy = (sintable[NORM_ANGLE(ang + 1024)] >> 3); vy = -bsin(ang, -3);
vz = q16horiz >> 8; vz = q16horiz >> 8;
// Player sprite of current view // Player sprite of current view
@ -986,7 +986,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x, daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x,
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y); wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)]; i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (klabs(vx) > klabs(vy))
hx -= mulscale28(vx, i); hx -= mulscale28(vx, i);
else else
@ -1021,7 +1021,7 @@ BackView(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q16hor
// same as wall calculation // same as wall calculation
daang = NORM_ANGLE(sp->ang-512); daang = NORM_ANGLE(sp->ang-512);
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)]; i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (klabs(vx) > klabs(vy))
hx -= mulscale28(vx, i); hx -= mulscale28(vx, i);
else else
@ -1071,8 +1071,8 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
ang = *nang + buildang(pp->circle_camera_ang); ang = *nang + buildang(pp->circle_camera_ang);
// Calculate the vector (nx,ny,nz) to shoot backwards // Calculate the vector (nx,ny,nz) to shoot backwards
vx = (sintable[NORM_ANGLE(ang.asbuild() + 1536)] >> 4); vx = -ang.bcos(-4);
vy = (sintable[NORM_ANGLE(ang.asbuild() + 1024)] >> 4); vy = -ang.bsin(-4);
// lengthen the vector some // lengthen the vector some
vx += DIV2(vx); vx += DIV2(vx);
@ -1108,7 +1108,7 @@ CircleCamera(int *nx, int *ny, int *nz, short *vsect, binangle *nang, fixed_t q1
daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x, daang = getangle(wall[wall[hitinfo.wall].point2].x - wall[hitinfo.wall].x,
wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y); wall[wall[hitinfo.wall].point2].y - wall[hitinfo.wall].y);
i = vx * sintable[daang] + vy * sintable[NORM_ANGLE(daang + 1536)]; i = vx * bsin(daang) + vy * -bcos(daang);
if (klabs(vx) > klabs(vy)) if (klabs(vx) > klabs(vy))
hx -= mulscale28(vx, i); hx -= mulscale28(vx, i);
else else
@ -1315,8 +1315,8 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, short *tsectnum, binangle
pp->last_camera_sp = sp; pp->last_camera_sp = sp;
xvect = sintable[NORM_ANGLE(ang.asbuild() + 512)] >> 3; xvect = ang.bcos(-3);
yvect = sintable[NORM_ANGLE(ang.asbuild())] >> 3; yvect = ang.bsin(-3);
zdiff = sp->z - *tz; zdiff = sp->z - *tz;
if (labs(sp->x - *tx) > 1000) if (labs(sp->x - *tx) > 1000)
@ -1893,8 +1893,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
bool sprisplayer = false; bool sprisplayer = false;
short txt_x, txt_y; short txt_x, txt_y;
xvect = sintable[(2048 - cang) & 2047] * czoom; xvect = -bsin(cang) * czoom;
yvect = sintable[(1536 - cang) & 2047] * czoom; yvect = -bcos(cang) * czoom;
xvect2 = mulscale16(xvect, yxaspect); xvect2 = mulscale16(xvect, yxaspect);
yvect2 = mulscale16(yvect, yxaspect); yvect2 = mulscale16(yvect, yxaspect);
@ -1984,8 +1984,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
xoff = -xoff; xoff = -xoff;
k = spr->ang; k = spr->ang;
l = spr->xrepeat; l = spr->xrepeat;
dax = sintable[k & 2047] * l; dax = bsin(k) * l;
day = sintable[(k + 1536) & 2047] * l; day = -bcos(k) * l;
l = tileWidth(tilenum); l = tileWidth(tilenum);
k = (l >> 1) + xoff; k = (l >> 1) + xoff;
x1 -= mulscale16(dax, k); x1 -= mulscale16(dax, k);
@ -2019,8 +2019,8 @@ bool GameInterface::DrawAutomapPlayer(int cposx, int cposy, int czoom, int cang)
yoff = -yoff; yoff = -yoff;
k = spr->ang; k = spr->ang;
cosang = sintable[(k + 512) & 2047]; cosang = bcos(k);
sinang = sintable[k]; sinang = bsin(k);
xspan = tileWidth(tilenum); xspan = tileWidth(tilenum);
xrepeat = spr->xrepeat; xrepeat = spr->xrepeat;
yspan = tileHeight(tilenum); yspan = tileHeight(tilenum);