Skip to content

Commit

Permalink
Use a tspr->clipdist bit to specify legacy voxels instead of tspr->cs…
Browse files Browse the repository at this point in the history
…tat 48
  • Loading branch information
Hendricks266 committed Aug 27, 2023
1 parent 9a42fe3 commit 6e6b82d
Show file tree
Hide file tree
Showing 11 changed files with 1,313 additions and 1,311 deletions.
1 change: 1 addition & 0 deletions source/build/include/build.h
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ enum
TSPR_FLAGS_NO_SHADOW = 1u<<2u,
TSPR_FLAGS_INVISIBLE_WITH_SHADOW = 1u<<3u,
TSPR_FLAGS_SLOPE_SPRITE = 1u<<4u,
TSPR_FLAGS_SLAB = 1u<<5u,
};

EXTERN int32_t guniqhudid;
Expand Down
1 change: 0 additions & 1 deletion source/build/include/buildtypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ enum
CSTAT_SPRITE_ALIGNMENT_FACING = 0,
CSTAT_SPRITE_ALIGNMENT_WALL = 1u<<4u,
CSTAT_SPRITE_ALIGNMENT_FLOOR = 1u<<5u,
CSTAT_SPRITE_ALIGNMENT_SLAB = 1u<<4u | 1u<<5u,
CSTAT_SPRITE_ALIGNMENT_SLOPE = 1u<<4u | 1u<<5u,

CSTAT_SPRITE_ALIGNMENT_MASK = 1u<<4u | 1u<<5u,
Expand Down
2 changes: 1 addition & 1 deletion source/build/src/clip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,7 +1723,7 @@ int pushmove(vec3_t *const vect, int16_t *const sectnum,
for (i=headspritesect[clipsectorlist[clipsectcnt]]; i>=0; i=nextspritesect[i])
{
spr = &sprite[i];
if (((spr->cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_FACING) && ((spr->cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_SLAB)) continue;
if ((spr->cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_FACING) continue;
if ((spr->cstat&dasprclipmask) == 0) continue;

dax = (vect->x)-spr->x; day = (vect->y)-spr->y;
Expand Down
2,577 changes: 1,289 additions & 1,288 deletions source/build/src/engine.cpp

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions source/build/src/polymost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2728,9 +2728,9 @@ static inline pthtyp *our_texcache_fetch(int32_t dameth)

static inline bool polymost_spriteIsLegacyVoxel(tspritetype const * const tspr)
{
auto const cstat = tspr->cstat;
auto const tsprflags = tspr->clipdist;
auto const picnum = tspr->picnum;
return (cstat & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_SLAB && (unsigned)picnum < MAXVOXELS && voxmodels[picnum];
return (tsprflags & TSPR_FLAGS_SLAB) && (unsigned)picnum < MAXVOXELS && voxmodels[picnum];
}

static inline bool polymost_spriteIsModernVoxel(tspritetype const * const tspr)
Expand Down Expand Up @@ -7546,7 +7546,7 @@ void polymost2_drawsprite(int32_t snum)

vec2f_t off = { 0.f, 0.f };

if ((globalorientation & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_SLAB) // only non-voxel sprites should do this
if (!(tsprflags & TSPR_FLAGS_SLAB)) // only non-voxel sprites should do this
{
int const flag = usehightile && h_xsize[globalpicnum];
off.x = (float)((int32_t)tspr->xoffset + (flag ? h_xoffs[globalpicnum] : picanm[globalpicnum].xofs));
Expand Down Expand Up @@ -7596,7 +7596,7 @@ void polymost2_drawsprite(int32_t snum)
//POGO: some comments seem to indicate that spinning sprites were intended to be supported before the
// decision was made to implement that behaviour with voxels.
// Skip SLAB aligned sprites when not rendering as voxels.
if ((globalorientation & CSTAT_SPRITE_ALIGNMENT) == CSTAT_SPRITE_ALIGNMENT_SLAB)
if (tsprflags & TSPR_FLAGS_SLAB)
{
return;
}
Expand Down Expand Up @@ -8118,7 +8118,7 @@ void polymost_drawsprite(int32_t snum)

auto const tsprflags = tspr->clipdist;

if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_SLAB)
if (!(tsprflags & TSPR_FLAGS_SLAB))
tileUpdatePicnum(&tspr->picnum, spritenum + 32768);

globalpicnum = tspr->picnum;
Expand All @@ -8137,7 +8137,7 @@ void polymost_drawsprite(int32_t snum)

vec2_t off = { 0, 0 };

if ((globalorientation & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_SLAB) // only non-voxel sprites should do this
if (!(tsprflags & TSPR_FLAGS_SLAB)) // only non-voxel sprites should do this
{
int const flag = usehightile && h_xsize[globalpicnum];
off = { flag ? h_xoffs[globalpicnum] : picanm[globalpicnum].xofs,
Expand Down
4 changes: 2 additions & 2 deletions source/build/src/voxmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1074,7 +1074,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
zoff = m->siz.z*.5f;
if (!(tspr->cstat&128))
zoff += m->piv.z;
else if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT) != CSTAT_SPRITE_ALIGNMENT_SLAB)
else if (!(tsprflags & TSPR_FLAGS_SLAB))
{
zoff += m->piv.z;
zoff -= m->siz.z*.5f;
Expand Down Expand Up @@ -1125,7 +1125,7 @@ int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr)
if (have_basepal_tint())
hictinting_apply(pc, MAXPALOOKUPS - 1);

int32_t const voxid = (tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_SLAB
int32_t const voxid = (tsprflags & TSPR_FLAGS_SLAB)
? tspr->picnum
: tiletovox[tspr->picnum];
if (!shadowHack && (voxflags[voxid] & VF_NOTRANS) != VF_NOTRANS)
Expand Down
6 changes: 4 additions & 2 deletions source/kenbuild/src/bstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, i
if (voxid_PLAYER == -1)
break;

tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
tspr->clipdist |= TSPR_FLAGS_SLAB;
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
tspr->picnum = voxid_PLAYER;

longptr = (int32_t *)voxoff[voxid_PLAYER][0];
Expand All @@ -303,7 +304,8 @@ void ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, i
if (voxid_BROWNMONSTER == -1)
break;

tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
tspr->clipdist |= TSPR_FLAGS_SLAB;
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
tspr->picnum = voxid_BROWNMONSTER;
break;
}
Expand Down
6 changes: 4 additions & 2 deletions source/kenbuild/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2023,7 +2023,8 @@ void analyzesprites(int dax, int day)
if (voxid_PLAYER == -1)
break;

tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
tspr->clipdist |= TSPR_FLAGS_SLAB;
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
tspr->picnum = voxid_PLAYER;

auto const voxptr = (int32_t const *)voxoff[voxid_PLAYER][0];
Expand All @@ -2036,7 +2037,8 @@ void analyzesprites(int dax, int day)
if (voxid_BROWNMONSTER == -1)
break;

tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB;
tspr->clipdist |= TSPR_FLAGS_SLAB;
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
tspr->picnum = voxid_BROWNMONSTER;
break;
}
Expand Down
6 changes: 0 additions & 6 deletions source/sw/src/draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -576,12 +576,6 @@ DoMotionBlur(tspritetype const * const tsp)

}

void SetVoxelSprite(SPRITEp sp, short pic)
{
SET(sp->cstat, CSTAT_SPRITE_ALIGNMENT_SLAB);
sp->picnum = pic;
}

void WarpCopySprite(void)
{
SPRITEp sp1, sp2, sp;
Expand Down
3 changes: 2 additions & 1 deletion source/sw/src/jnstub.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ ExtAnalyzeSprites(int32_t ourx, int32_t oury, int32_t ourz, int32_t oura, int32_
{
// Turn on voxels
tspr->picnum = aVoxelArray[tspr->picnum]; // Get the voxel number
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; // Set stat to voxelize sprite
tspr->clipdist |= TSPR_FLAGS_SLAB; // Set stat to voxelize sprite
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
}
}
}
Expand Down
6 changes: 4 additions & 2 deletions source/sw/src/jsector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,8 @@ JAnalyzeSprites(tspriteptr_t tspr)
{
// Turn on voxels
tspr->picnum = aVoxelArray[tspr->picnum].Voxel; // Get the voxel number
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; // Set stat to voxelize sprite
tspr->clipdist |= TSPR_FLAGS_SLAB; // Set stat to voxelize sprite
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
}
}
else
Expand All @@ -1101,7 +1102,8 @@ JAnalyzeSprites(tspriteptr_t tspr)
{
// Turn on voxels
tspr->picnum = aVoxelArray[tspr->picnum].Voxel; // Get the voxel number
tspr->cstat |= CSTAT_SPRITE_ALIGNMENT_SLAB; // Set stat to voxelize sprite
tspr->clipdist |= TSPR_FLAGS_SLAB; // Set stat to voxelize sprite
tspr->cstat &= ~CSTAT_SPRITE_ALIGNMENT;
}
break;
}
Expand Down

0 comments on commit 6e6b82d

Please sign in to comment.