- buildutils: Replace sintable[] use within Build with bsin()/bcos(), using bsinf()/bcosf() where appropriate.

* Includes a few header include shuffles to make it all come together.
This commit is contained in:
Mitchell Richters 2020-11-14 20:00:37 +11:00 committed by Christoph Oelckers
parent b2c42d5d03
commit 32a1796728
9 changed files with 49 additions and 54 deletions

View file

@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "misc.h"
#include "printf.h"
#include "v_text.h"
#include "binaryangle.h"
#include "seqcb.h"
BEGIN_BLD_NS

View file

@ -23,11 +23,20 @@ static_assert('\xff' == 255, "Char must be unsigned!");
#include "palette.h"
#include "pragmas.h"
//Make all variables in BUILD.H defined in the ENGINE,
//and externed in GAME
#ifdef engine_c_
# define EXTERN
#else
# define EXTERN extern
#endif
EXTERN int16_t sintable[2048];
#include "buildtiles.h"
#include "c_cvars.h"
#include "cmdlib.h"
#include "m_fixed.h"
#include "binaryangle.h"
#include "mathutil.h"
typedef int64_t coord_t;
@ -102,14 +111,6 @@ enum {
RS_CENTERORIGIN = (1<<30),
};
//Make all variables in BUILD.H defined in the ENGINE,
//and externed in GAME
#ifdef engine_c_
# define EXTERN
#else
# define EXTERN extern
#endif
enum {
SPR_XFLIP = 4,
@ -264,7 +265,6 @@ EXTERN int16_t numsectors, numwalls;
EXTERN int32_t display_mirror;
EXTERN int32_t randomseed;
EXTERN int16_t sintable[2048];
EXTERN int16_t numshades;
EXTERN uint8_t paletteloaded;

View file

@ -649,8 +649,8 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
if (clipinsideboxline(cent.x, cent.y, p1.x, p1.y, p2.x, p2.y, rad) != 0)
{
vec2_t v = { mulscale14(sintable[(spr->ang+256+512) & 2047], walldist),
mulscale14(sintable[(spr->ang+256) & 2047], walldist) };
vec2_t v = { mulscale14(bcos(spr->ang + 256), walldist),
mulscale14(bsin(spr->ang + 256), walldist) };
if ((p1.x-pos->x) * (p2.y-pos->y) >= (p2.x-pos->x) * (p1.y-pos->y)) // Front
addclipline(p1.x+v.x, p1.y+v.y, p2.x+v.y, p2.y-v.x, (int16_t)j+49152, false);
@ -685,8 +685,8 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int
get_floorspr_points((uspriteptr_t) spr, 0, 0, &rxi[0], &rxi[1], &rxi[2], &rxi[3],
&ryi[0], &ryi[1], &ryi[2], &ryi[3]);
vec2_t v = { mulscale14(sintable[(spr->ang-256+512)&2047], walldist),
mulscale14(sintable[(spr->ang-256)&2047], walldist) };
vec2_t v = { mulscale14(bcos(spr->ang - 256), walldist),
mulscale14(bsin(spr->ang - 256), walldist) };
if ((rxi[0]-pos->x) * (ryi[1]-pos->y) < (rxi[1]-pos->x) * (ryi[0]-pos->y))
{
@ -934,8 +934,8 @@ int pushmove(vec3_t *const vect, int16_t *const sectnum,
if (j != 0)
{
j = getangle(wall[wal->point2].x-wal->x, wall[wal->point2].y-wal->y);
int32_t dx = (sintable[(j+1024)&2047]>>11);
int32_t dy = (sintable[(j+512)&2047]>>11);
int32_t dx = -bsin(j, -11);
int32_t dy = bcos(j, -11);
int bad2 = 16;
do
{
@ -1140,8 +1140,8 @@ void getzrange(const vec3_t *pos, int16_t sectnum,
get_floorspr_points((uspriteptr_t) &sprite[j], pos->x, pos->y, &v1.x, &v2.x, &v3.x, &v4.x,
&v1.y, &v2.y, &v3.y, &v4.y);
vec2_t const da = { mulscale14(sintable[(sprite[j].ang - 256 + 512) & 2047], walldist + 4),
mulscale14(sintable[(sprite[j].ang - 256) & 2047], walldist + 4) };
vec2_t const da = { mulscale14(bcos(sprite[j].ang - 256), walldist + 4),
mulscale14(bsin(sprite[j].ang - 256), walldist + 4) };
v1.x += da.x; v2.x -= da.y; v3.x -= da.x; v4.x += da.y;
v1.y += da.y; v2.y += da.x; v3.y -= da.y; v4.y -= da.x;

View file

@ -1647,9 +1647,8 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang)
zoome <<= 8;
vec2_t const bakgvect = { divscale28(sintable[(1536 - ang) & 2047], zoome),
divscale28(sintable[(2048 - ang) & 2047], zoome) };
vec2_t const vect = { mulscale8(sintable[(2048 - ang) & 2047], zoome), mulscale8(sintable[(1536 - ang) & 2047], zoome) };
vec2_t const bakgvect = { divscale28(-bcos(ang), zoome), divscale28(-bsin(ang), zoome) };
vec2_t const vect = { mulscale8(-bsin(ang), zoome), mulscale8(-bcos(ang), zoome) };
vec2_t const vect2 = { mulscale16(vect.x, yxaspect), mulscale16(vect.y, yxaspect) };
int32_t sortnum = 0;
@ -2396,8 +2395,8 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
{
int16_t tempshortcnt, tempshortnum;
const int32_t vx = mulscale14(sintable[(ange+2560)&2047],neartagrange);
const int32_t vy = mulscale14(sintable[(ange+2048)&2047],neartagrange);
const int32_t vx = mulscale14(bcos(ange), neartagrange);
const int32_t vy = mulscale14(bsin(ange), neartagrange);
vec3_t hitv = { xs+vx, ys+vy, 0 };
const vec3_t sv = { xs, ys, zs };
@ -2445,7 +2444,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
{
if (good&1) *neartagsector = nextsector;
if (good&2) *neartagwall = z;
*neartaghitdist = dmulscale14(intx-xs,sintable[(ange+2560)&2047],inty-ys,sintable[(ange+2048)&2047]);
*neartaghitdist = dmulscale14(intx-xs, bcos(ange), inty-ys, bsin(ange));
hitv.x = intx; hitv.y = inty; hitv.z = intz;
}
@ -2477,8 +2476,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange,
if (try_facespr_intersect(spr, sv, vx, vy, 0, &hitv, 1))
{
*neartagsprite = z;
*neartaghitdist = dmulscale14(hitv.x-xs, sintable[(ange+2560)&2047],
hitv.y-ys, sintable[(ange+2048)&2047]);
*neartaghitdist = dmulscale14(hitv.x-xs, bcos(ange), hitv.y-ys, bsin(ange));
}
}
}
@ -2884,8 +2882,8 @@ void updatesectorneighborz(int32_t const x, int32_t const y, int32_t const z, in
//
void rotatepoint(vec2_t const pivot, 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];
int const dacos = bcos(daang);
int const dasin = bsin(daang);
p.x -= pivot.x;
p.y -= pivot.y;
p2->x = dmulscale14(p.x, dacos, -p.y, dasin) + pivot.x;

View file

@ -196,8 +196,8 @@ static inline void get_wallspr_points(T const * const spr, int32_t *x1, int32_t
if (spr->cstat&4)
xoff = -xoff;
dax = sintable[ang&2047]*xrepeat;
day = sintable[(ang+1536)&2047]*xrepeat;
dax = bsin(ang) * xrepeat;
day = -bcos(ang) * xrepeat;
l = tileWidth(tilenum);
k = (l>>1)+xoff;
@ -217,8 +217,8 @@ static inline void get_floorspr_points(T const * const spr, int32_t px, int32_t
int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4)
{
const int32_t tilenum = spr->picnum;
const int32_t cosang = sintable[(spr->ang+512)&2047];
const int32_t sinang = sintable[spr->ang&2047];
const int32_t cosang = bcos(spr->ang);
const int32_t sinang = bsin(spr->ang);
vec2_t const span = { tileWidth(tilenum), tileHeight(tilenum)};
vec2_t const repeat = { spr->xrepeat, spr->yrepeat };

View file

@ -1197,8 +1197,8 @@ void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float
k0 = ((float)(tspr->x+spriteext[tspr->owner].position_offset.x-globalposx))*f*(1.f/1024.f);
k1 = ((float)(tspr->y+spriteext[tspr->owner].position_offset.y-globalposy))*f*(1.f/1024.f);
k4 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+1024)&2047] * (1.f/16384.f);
k5 = (float)sintable[(tspr->ang+spriteext[tspr->owner].angoff+ 512)&2047] * (1.f/16384.f);
k4 = -bsinf(tspr->ang+spriteext[tspr->owner].angoff, -14);
k5 = bcosf(tspr->ang+spriteext[tspr->owner].angoff, -14);
k2 = k0*(1-k4)+k1*k5;
k3 = k1*(1-k4)-k0*k5;
k6 = - gsinang;
@ -1403,10 +1403,10 @@ static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr)
if ((sext->pivot_offset.z) && !(tspr->clipdist & TSPR_FLAGS_MDHACK)) // Compare with SCREEN_FACTORS above
a0.z = (float)sext->pivot_offset.z / (gxyaspect * fxdimen * (65536.f/128.f) * (m0.z+m1.z));
k0 = (float)sintable[(sext->pitch+512)&2047] * (1.f/16384.f);
k1 = (float)sintable[sext->pitch&2047] * (1.f/16384.f);
k2 = (float)sintable[(sext->roll+512)&2047] * (1.f/16384.f);
k3 = (float)sintable[sext->roll&2047] * (1.f/16384.f);
k0 = bcosf(sext->pitch, -14);
k1 = bsinf(sext->pitch, -14);
k2 = bcosf(sext->roll, -14);
k3 = bsinf(sext->roll, -14);
}
VSMatrix imat = 0;

View file

@ -2235,7 +2235,7 @@ void polymost_scansector(int32_t sectnum)
{
if ((spr->cstat&(64+48))!=(64+16) ||
(r_voxels && tiletovox[spr->picnum] >= 0 && voxmodels[tiletovox[spr->picnum]]) ||
dmulscale6(sintable[(spr->ang+512)&2047],-s.x, sintable[spr->ang&2047],-s.y) > 0)
dmulscale6(bcos(spr->ang), -s.x, bsin(spr->ang), -s.y) > 0)
if (renderAddTsprite(z, sectnum))
break;
}
@ -3088,13 +3088,13 @@ void polymost_drawsprite(int32_t snum)
if (spriteext[spritenum].flags & SPREXT_AWAY1)
{
pos.x += (sintable[(tspr->ang + 512) & 2047] >> 13);
pos.y += (sintable[(tspr->ang) & 2047] >> 13);
pos.x += bcos(tspr->ang, -13);
pos.y += bsin(tspr->ang, -13);
}
else if (spriteext[spritenum].flags & SPREXT_AWAY2)
{
pos.x -= (sintable[(tspr->ang + 512) & 2047] >> 13);
pos.y -= (sintable[(tspr->ang) & 2047] >> 13);
pos.x -= bcos(tspr->ang, -13);
pos.y -= bsin(tspr->ang, -13);
}
vec2_t tsiz;
@ -3125,7 +3125,7 @@ void polymost_drawsprite(int32_t snum)
float foffs2 = TSPR_OFFSET(tspr);
if (fabs(foffs2) < fabs(foffs)) foffs = foffs2;
vec2f_t const offs = { (float)(sintable[(ang + 512) & 2047] >> 6)* foffs, (float) (sintable[(ang) & 2047] >> 6) * foffs };
vec2f_t const offs = { float(bcosf(ang, -6) * foffs), float(bsinf(ang, -6) * foffs) };
vec2f_t s0 = { (float)(tspr->x - globalposx) + offs.x,
(float)(tspr->y - globalposy) + offs.y};
@ -3227,8 +3227,8 @@ void polymost_drawsprite(int32_t snum)
if (globalorientation & 8)
off.y = -off.y;
vec2f_t const extent = { (float)tspr->xrepeat * (float)sintable[(tspr->ang) & 2047] * (1.0f / 65536.f),
(float)tspr->xrepeat * (float)sintable[(tspr->ang + 1536) & 2047] * (1.0f / 65536.f) };
vec2f_t const extent = { float(tspr->xrepeat * bsinf(tspr->ang, -16)),
float(tspr->xrepeat * -bcosf(tspr->ang, -16)) };
float f = (float)(tsiz.x >> 1) + (float)off.x;
@ -3273,8 +3273,7 @@ void polymost_drawsprite(int32_t snum)
{
int32_t const ang = getangle(wall[w].x - POINT2(w).x, wall[w].y - POINT2(w).y);
float const foffs = TSPR_OFFSET(tspr);
vec2f_t const offs = { (float)(sintable[(ang + 1024) & 2047] >> 6) * foffs,
(float)(sintable[(ang + 512) & 2047] >> 6) * foffs};
vec2d_t const offs = { -bsinf(ang, -6) * foffs, bcosf(ang, -6) * foffs };
vec0.x -= offs.x;
vec0.y -= offs.y;
@ -3423,8 +3422,8 @@ void polymost_drawsprite(int32_t snum)
p1 = { (float)((tsiz.x >> 1) + off.x) * tspr->xrepeat,
(float)((tsiz.y >> 1) + off.y) * tspr->yrepeat };
float const c = sintable[(tspr->ang + 512) & 2047] * (1.0f / 65536.f);
float const s = sintable[tspr->ang & 2047] * (1.0f / 65536.f);
float const c = bcosf(tspr->ang, -16);
float const s = bsinf(tspr->ang, -16);
vec2f_t pxy[6];

View file

@ -1031,8 +1031,8 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr)
if ((sprite[tspr->owner].cstat&48)==16)
{
f *= 1.25f;
a0.y -= tspr->xoffset*sintable[(spriteext[tspr->owner].angoff+512)&2047]*(1.f/(64.f*16384.f));
a0.x += tspr->xoffset*sintable[(spriteext[tspr->owner].angoff)&2047]*(1.f/(64.f*16384.f));
a0.y -= tspr->xoffset * bcosf(spriteext[tspr->owner].angoff, -20);
a0.x += tspr->xoffset * bsinf(spriteext[tspr->owner].angoff, -20);
}
if (globalorientation&8) { m0.z = -m0.z; a0.z = -a0.z; } //y-flipping

View file

@ -12,7 +12,6 @@
#include "i_time.h"
#include "palentry.h"
#include "pragmas.h"
#include "binaryangle.h"
extern FString currentGame;
extern FString LumpFilter;