mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- got rid of pow2char
This commit is contained in:
parent
d8627a2b3f
commit
8993095bc0
7 changed files with 15 additions and 128 deletions
|
@ -800,7 +800,7 @@ inline void tileUpdatePicnum(int* const tileptr, int const obj, int stat)
|
|||
|
||||
inline void setgotpic(int32_t tilenume)
|
||||
{
|
||||
gotpic[tilenume >> 3] |= pow2char[tilenume & 7];
|
||||
gotpic[tilenume >> 3] |= 1 << (tilenume & 7);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -148,15 +148,6 @@ using std::max;
|
|||
|
||||
////////// Bitfield manipulation //////////
|
||||
|
||||
// This once was a static array, requiring a memory acces where a shift would suffice.
|
||||
// Revert the above to a real bit shift through some C++ operator magic. That saves me from reverting all the code that uses this construct.
|
||||
// Note: Only occurs 25 times in the code, should be removed for good.
|
||||
static struct
|
||||
{
|
||||
constexpr uint8_t operator[](int index) const { return 1 << index; };
|
||||
} pow2char;
|
||||
|
||||
|
||||
static FORCE_INLINE void bitmap_set(uint8_t *const ptr, int const n) { ptr[n>>3] |= 1 << (n&7); }
|
||||
static FORCE_INLINE char bitmap_test(uint8_t const *const ptr, int const n) { return ptr[n>>3] & (1 << (n&7)); }
|
||||
|
||||
|
|
|
@ -125,7 +125,7 @@ static void addclipline(int32_t dax1, int32_t day1, int32_t dax2, int32_t day2,
|
|||
clipit[clipnum].x2 = dax2; clipit[clipnum].y2 = day2;
|
||||
clipobjectval[clipnum] = daoval;
|
||||
|
||||
uint32_t const mask = pow2char[clipnum&7];
|
||||
uint32_t const mask = (1 << (clipnum&7));
|
||||
uint8_t &value = clipignore[clipnum>>3];
|
||||
value = (value & ~mask) | (-nofix & mask);
|
||||
|
||||
|
|
|
@ -1282,7 +1282,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
break;
|
||||
default:
|
||||
if (framei >= 0 && framei<1024)
|
||||
usedframebitmap[framei>>3] |= pow2char[framei&7];
|
||||
usedframebitmap[framei>>3] |= (1 << (framei&7));
|
||||
}
|
||||
model_ok &= happy;
|
||||
}
|
||||
|
@ -1637,7 +1637,7 @@ static int32_t defsparser(scriptfile *script)
|
|||
}
|
||||
|
||||
case T_ROTATE:
|
||||
voxrotate[lastvoxid>>3] |= pow2char[lastvoxid&7];
|
||||
voxrotate[lastvoxid>>3] |= (1 << (lastvoxid&7));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -831,7 +831,7 @@ void vox_undefine(int32_t const tile)
|
|||
#endif
|
||||
|
||||
voxscale[voxindex] = 65536;
|
||||
voxrotate[voxindex>>3] &= ~pow2char[voxindex&7];
|
||||
voxrotate[voxindex>>3] &= ~(1 << (voxindex&7));
|
||||
tiletovox[tile] = -1;
|
||||
|
||||
// TODO: nextvoxid
|
||||
|
@ -1175,7 +1175,7 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
|
|||
if (x1 == x2 && y1 == y2)
|
||||
return (sect1 == sect2);
|
||||
|
||||
sectbitmap[sect1>>3] |= pow2char[sect1&7];
|
||||
sectbitmap[sect1>>3] |= (1 << (sect1&7));
|
||||
clipsectorlist[0] = sect1; danum = 1;
|
||||
|
||||
for (dacnt=0; dacnt<danum; dacnt++)
|
||||
|
@ -1223,16 +1223,16 @@ int32_t cansee(int32_t x1, int32_t y1, int32_t z1, int16_t sect1, int32_t x2, in
|
|||
if (z <= cfz[0] || z >= cfz[1])
|
||||
return 0;
|
||||
|
||||
if (!(sectbitmap[nexts>>3] & pow2char[nexts&7]))
|
||||
if (!(sectbitmap[nexts>>3] & (1 << (nexts&7))))
|
||||
{
|
||||
sectbitmap[nexts>>3] |= pow2char[nexts&7];
|
||||
sectbitmap[nexts>>3] |= (1 << (nexts&7));
|
||||
clipsectorlist[danum++] = nexts;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (sectbitmap[sect2>>3] & pow2char[sect2&7])
|
||||
if (sectbitmap[sect2>>3] & (1<<(sect2&7)))
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
|
@ -1368,7 +1368,7 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
|
|||
sector[wall[w].sector].dirty = 255;
|
||||
wall[w].x = dax;
|
||||
wall[w].y = day;
|
||||
walbitmap[w>>3] |= pow2char[w&7];
|
||||
walbitmap[w>>3] |= (1<<(w&7));
|
||||
|
||||
if (!clockwise) //search points CCW
|
||||
{
|
||||
|
@ -1398,7 +1398,7 @@ void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags)
|
|||
break;
|
||||
}
|
||||
|
||||
if ((walbitmap[w>>3] & pow2char[w&7]))
|
||||
if ((walbitmap[w>>3] & (1<<(w&7))))
|
||||
{
|
||||
if (clockwise)
|
||||
break;
|
||||
|
|
|
@ -257,110 +257,6 @@ int32_t md_defineanimation(int32_t modelid, const char *framestart, const char *
|
|||
return 0;
|
||||
}
|
||||
|
||||
#if 0
|
||||
// FIXME: CURRENTLY DISABLED: interpolation may access frames we consider 'unused'?
|
||||
int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap)
|
||||
{
|
||||
md3model_t *m;
|
||||
md3surf_t *s;
|
||||
mdanim_t *anm;
|
||||
int32_t i, surfi, sub, usedframes;
|
||||
static int16_t otonframe[1024];
|
||||
|
||||
if ((uint32_t)modelid >= (uint32_t)nextmodelid) return -1;
|
||||
m = (md3model_t *)models[modelid];
|
||||
if (m->mdnum != 3) return -2;
|
||||
|
||||
for (anm=m->animations; anm; anm=anm->next)
|
||||
{
|
||||
if (anm->endframe <= anm->startframe)
|
||||
{
|
||||
// Printf("backward anim %d-%d\n", anm->startframe, anm->endframe);
|
||||
return -3;
|
||||
}
|
||||
|
||||
for (i=anm->startframe; i<anm->endframe; i++)
|
||||
usedframebitmap[i>>3] |= pow2char[i&7];
|
||||
}
|
||||
|
||||
sub = 0;
|
||||
for (i=0; i<m->numframes; i++)
|
||||
{
|
||||
if (!(usedframebitmap[i>>3]&pow2char[i&7]))
|
||||
{
|
||||
sub++;
|
||||
otonframe[i] = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
otonframe[i] = i-sub;
|
||||
}
|
||||
|
||||
usedframes = m->numframes - sub;
|
||||
if (usedframes==0 || usedframes==m->numframes)
|
||||
return usedframes;
|
||||
|
||||
//// THIN OUT! ////
|
||||
|
||||
for (i=0; i<m->numframes; i++)
|
||||
{
|
||||
if (otonframe[i]>=0 && otonframe[i] != i)
|
||||
{
|
||||
if (m->muladdframes)
|
||||
memcpy(&m->muladdframes[2*otonframe[i]], &m->muladdframes[2*i], 2*sizeof(vec3f_t));
|
||||
memcpy(&m->head.frames[otonframe[i]], &m->head.frames[i], sizeof(md3frame_t));
|
||||
}
|
||||
}
|
||||
|
||||
for (surfi=0; surfi < m->head.numsurfs; surfi++)
|
||||
{
|
||||
s = &m->head.surfs[surfi];
|
||||
|
||||
for (i=0; i<m->numframes; i++)
|
||||
if (otonframe[i]>=0 && otonframe[i] != i)
|
||||
memcpy(&s->xyzn[otonframe[i]*s->numverts], &s->xyzn[i*s->numverts], s->numverts*sizeof(md3xyzn_t));
|
||||
}
|
||||
|
||||
////// tweak frame indices in various places
|
||||
|
||||
for (anm=m->animations; anm; anm=anm->next)
|
||||
{
|
||||
if (otonframe[anm->startframe]==-1 || otonframe[anm->endframe-1]==-1)
|
||||
Printf("md %d WTF: anm %d %d\n", modelid, anm->startframe, anm->endframe);
|
||||
|
||||
anm->startframe = otonframe[anm->startframe];
|
||||
anm->endframe = otonframe[anm->endframe-1];
|
||||
}
|
||||
|
||||
for (i=0; i<MAXTILES+EXTRATILES; i++)
|
||||
if (tile2model[i].modelid == modelid)
|
||||
{
|
||||
if (otonframe[tile2model[i].framenum]==-1)
|
||||
Printf("md %d WTF: tile %d, fr %d\n", modelid, i, tile2model[i].framenum);
|
||||
tile2model[i].framenum = otonframe[tile2model[i].framenum];
|
||||
}
|
||||
|
||||
////// realloc & change "numframes" everywhere
|
||||
|
||||
if (m->muladdframes)
|
||||
m->muladdframes = Xrealloc(m->muladdframes, 2*sizeof(vec3f_t)*usedframes);
|
||||
m->head.frames = Xrealloc(m->head.frames, sizeof(md3frame_t)*usedframes);
|
||||
|
||||
for (surfi=0; surfi < m->head.numsurfs; surfi++)
|
||||
{
|
||||
m->head.surfs[surfi].numframes = usedframes;
|
||||
// CAN'T do that because xyzn is offset from a larger block when loaded from md3:
|
||||
// m->head.surfs[surfi].xyzn = Xrealloc(m->head.surfs[surfi].xyzn, s->numverts*usedframes*sizeof(md3xyzn_t));
|
||||
}
|
||||
|
||||
m->head.numframes = usedframes;
|
||||
m->numframes = usedframes;
|
||||
|
||||
////////////
|
||||
return usedframes;
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t md_defineskin(int32_t modelid, const char *skinfn, int32_t palnum, int32_t skinnum, int32_t surfnum, float param, float specpower, float specfactor, int32_t flags)
|
||||
{
|
||||
mdskinmap_t *sk, *skl;
|
||||
|
|
|
@ -1807,7 +1807,7 @@ static void polymost_drawalls(int32_t const bunch)
|
|||
domostpolymethod = DAMETH_NOMASK;
|
||||
|
||||
if (nextsectnum >= 0)
|
||||
if ((!(gotsector[nextsectnum>>3]&pow2char[nextsectnum&7])) && testvisiblemost(x0,x1))
|
||||
if ((!(gotsector[nextsectnum>>3]& (1<<(nextsectnum&7)))) && testvisiblemost(x0,x1))
|
||||
polymost_scansector(nextsectnum);
|
||||
}
|
||||
}
|
||||
|
@ -1908,7 +1908,7 @@ void polymost_scansector(int32_t sectnum)
|
|||
}
|
||||
}
|
||||
|
||||
gotsector[sectnum>>3] |= pow2char[sectnum&7];
|
||||
gotsector[sectnum>>3] |= 1<<(sectnum&7);
|
||||
|
||||
int const bunchfrst = numbunches;
|
||||
int const onumscans = numscans;
|
||||
|
@ -1931,7 +1931,7 @@ void polymost_scansector(int32_t sectnum)
|
|||
int const nextsectnum = wal->nextsector; //Scan close sectors
|
||||
|
||||
if (nextsectnum >= 0 && !(wal->cstat&32) && sectorbordercnt < countof(sectorborder))
|
||||
if ((gotsector[nextsectnum>>3]&pow2char[nextsectnum&7]) == 0)
|
||||
if ((gotsector[nextsectnum>>3]&(1<<(nextsectnum&7))) == 0)
|
||||
{
|
||||
double const d = fp1.X* fp2.Y - fp2.X * fp1.Y;
|
||||
DVector2 const p1 = fp2 - fp1;
|
||||
|
@ -1941,7 +1941,7 @@ void polymost_scansector(int32_t sectnum)
|
|||
if (d*d < (p1.LengthSquared()) * 256.f)
|
||||
{
|
||||
sectorborder[sectorbordercnt++] = nextsectnum;
|
||||
gotsector[nextsectnum>>3] |= pow2char[nextsectnum&7];
|
||||
gotsector[nextsectnum>>3] |= 1<<(nextsectnum&7);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue