diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index a0f3fe6a8..dfba4ae6f 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -8500,6 +8500,15 @@ void initspritelists(void) } +void set_globalang(int16_t ang) +{ + globalang = ang&2047; + cosglobalang = sintable[(globalang+512)&2047]; + singlobalang = sintable[globalang&2047]; + cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); + sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); +} + // // drawrooms // @@ -8515,7 +8524,7 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, indrawroomsandmasks = 1; globalposx = daposx; globalposy = daposy; globalposz = daposz; - globalang = (daang&2047); + set_globalang(daang); global100horiz = dahoriz; @@ -8557,11 +8566,6 @@ int32_t drawrooms(int32_t daposx, int32_t daposy, int32_t daposz, globalcursectnum = dacursectnum; totalclocklock = totalclock; - cosglobalang = sintable[(globalang+512)&2047]; - singlobalang = sintable[globalang&2047]; - cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); - sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); - if ((xyaspect != oxyaspect) || (xdimen != oxdimen) || (viewingrange != oviewingrange)) dosetaspect(); diff --git a/polymer/eduke32/build/src/engine_priv.h b/polymer/eduke32/build/src/engine_priv.h index 2aaf6d699..fd0b205f4 100644 --- a/polymer/eduke32/build/src/engine_priv.h +++ b/polymer/eduke32/build/src/engine_priv.h @@ -87,6 +87,8 @@ void calc_and_apply_fog_factor(int32_t shade, int32_t vis, int32_t pal, float fa int32_t wallfront(int32_t l1, int32_t l2); int32_t animateoffs(int16_t tilenum, int16_t fakevar); +void set_globalang(int16_t ang); + #define DO_TILE_ANIM(Picnum, Fakevar) do { \ if (picanm[Picnum].sf&PICANM_ANIMTYPE_MASK) Picnum += animateoffs(Picnum, Fakevar); \ } while (0) diff --git a/polymer/eduke32/build/src/polymer.c b/polymer/eduke32/build/src/polymer.c index 6a255fe68..74fe0fd42 100644 --- a/polymer/eduke32/build/src/polymer.c +++ b/polymer/eduke32/build/src/polymer.c @@ -1087,11 +1087,7 @@ void polymer_drawrooms(int32_t daposx, int32_t daposy, int32_t da // build globals used by rotatesprite viewangle = daang; - globalang = (daang&2047); - cosglobalang = sintable[(globalang+512)&2047]; - singlobalang = sintable[globalang&2047]; - cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); - sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); + set_globalang(daang); // polymost globals used by polymost_dorotatesprite gcosang = ((double)cosglobalang)/262144.0; @@ -1953,11 +1949,7 @@ static void polymer_displayrooms(int16_t dacursectnum) if (depth) { - // drawmasks needs these - cosglobalang = sintable[(viewangle+512)&2047]; - singlobalang = sintable[viewangle&2047]; - cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); - sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); + set_globalang(viewangle); if (mirrors[depth - 1].plane) display_mirror = 1; @@ -5554,8 +5546,6 @@ static inline void polymer_culllight(int16_t lighti) static void polymer_prepareshadows(void) { int16_t oviewangle, oglobalang; - int32_t ocosglobalang, osinglobalang; - int32_t ocosviewingrangeglobalang, osinviewingrangeglobalang; int32_t i, j, k; int32_t gx, gy, gz; int32_t oldoverridematerial; @@ -5567,10 +5557,6 @@ static void polymer_prepareshadows(void) // build globals used by drawmasks oviewangle = viewangle; oglobalang = globalang; - ocosglobalang = cosglobalang; - osinglobalang = singlobalang; - ocosviewingrangeglobalang = cosviewingrangeglobalang; - osinviewingrangeglobalang = sinviewingrangeglobalang; i = j = k = 0; @@ -5607,11 +5593,7 @@ static void polymer_prepareshadows(void) // build globals used by rotatesprite viewangle = prlights[i].angle; - globalang = (prlights[i].angle&2047); - cosglobalang = sintable[(globalang+512)&2047]; - singlobalang = sintable[globalang&2047]; - cosviewingrangeglobalang = mulscale16(cosglobalang,viewingrange); - sinviewingrangeglobalang = mulscale16(singlobalang,viewingrange); + set_globalang(prlights[i].angle); oldoverridematerial = overridematerial; // smooth model shadows @@ -5646,11 +5628,7 @@ static void polymer_prepareshadows(void) globalposz = gz; viewangle = oviewangle; - globalang = oglobalang; - cosglobalang = ocosglobalang; - singlobalang = osinglobalang; - cosviewingrangeglobalang = ocosviewingrangeglobalang; - sinviewingrangeglobalang = osinviewingrangeglobalang; + set_globalang(oglobalang); } // RENDER TARGETS