- moved the tsprite flags from cstat2 to clipdist which was already holding other ones.

cstat2 should only hold flags for game-side sprites.
This commit is contained in:
Christoph Oelckers 2021-12-30 19:00:35 +01:00
parent 552668418a
commit a9b162b8e9
9 changed files with 24 additions and 24 deletions

View file

@ -92,13 +92,6 @@ enum {
int32_t getwalldist(vec2_t const in, int const wallnum);
int32_t getwalldist(vec2_t const in, int const wallnum, vec2_t * const out);
// using the clipdist field
enum
{
TSPR_FLAGS_MDHACK = 1u<<0u,
TSPR_FLAGS_DRAW_LAST = 1u<<1u,
};
EXTERN int32_t guniqhudid;
struct usermaphack_t

View file

@ -594,6 +594,7 @@ CollisionBase clipmove_(vec3_t * const pos, int * const sectnum, int32_t xvect,
auto const spr = &actor->spr;
const int32_t cstat = spr->cstat;
if (spr->cstat2 & CSTAT2_SPRITE_NOFIND) continue;
if ((cstat&dasprclipmask) == 0)
continue;

View file

@ -2702,7 +2702,7 @@ void polymost_drawsprite(int32_t snum)
off = { (flag ? TileFiles.tiledata[globalpicnum].hiofs.xoffs : tileLeftOffset(globalpicnum)),
(flag ? TileFiles.tiledata[globalpicnum].hiofs.yoffs : tileTopOffset(globalpicnum)) };
if (!(tspr->cstat2 & CSTAT2_SPRITE_SLOPE))
if (!(tspr->clipdist & TSPR_SLOPESPRITE))
{
off.X += tspr->xoffset;
off.Y += tspr->yoffset;
@ -3821,7 +3821,7 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspritetype* const tspr, bool rotate)
if ((tspr->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_FLOOR)
return 0;
if ((tspr->cstat2 & CSTAT2_SPRITE_MDLROTATE) || rotate)
if ((tspr->clipdist & TSPR_MDLROTATE) || rotate)
{
int myclock = (PlayClock << 3) + MulScale(4 << 3, pm_smoothratio, 16);
tspr->ang = (tspr->ang + myclock) & 2047; // will be applied in md3_vox_calcmat_common.

View file

@ -287,7 +287,7 @@ inline int spriteGetSlope(DCoreActor* actor)
// same stuff, different flag...
inline int tspriteGetSlope(const tspritetype* spr)
{
return !(spr->cstat2 & CSTAT2_SPRITE_SLOPE) ? 0 : uint8_t(spr->xoffset) + (uint8_t(spr->yoffset) << 8);
return !(spr->clipdist & TSPR_SLOPESPRITE) ? 0 : uint8_t(spr->xoffset) + (uint8_t(spr->yoffset) << 8);
}
inline int32_t tspriteGetZOfSlope(const tspritetype* tspr, int dax, int day)

View file

@ -165,13 +165,20 @@ DEFINE_TFLAGS_OPERATORS(ESpriteFlags)
enum ESpriteBits2
{
CSTAT2_SPRITE_MDLROTATE = 1, // Only for tsprites: rotate if this is a model or voxel.
CSTAT2_SPRITE_NOFIND = 2, // Invisible to neartag and hitscan
CSTAT2_SPRITE_MAPPED = 4, // sprite was mapped for automap
CSTAT2_SPRITE_SLOPE = 8, // Only for tsprites: render as sloped sprite
CSTAT2_SPRITE_NOFIND = 1, // Invisible to neartag and hitscan
CSTAT2_SPRITE_MAPPED = 2, // sprite was mapped for automap
};
// tsprite flags use the otherwise unused clipdist field.
enum ETSprFlags
{
TSPR_FLAGS_MDHACK = 1, // Currently unused: set for model shadows
TSPR_FLAGS_DRAW_LAST = 2, // Currently unused: checked by Polymost but never set.
TSPR_MDLROTATE = 4, // rotate if this is a model or voxel.
TSPR_SLOPESPRITE = 8, // render as sloped sprite
};
//=============================================================================
//
// external references
@ -443,7 +450,6 @@ struct spritetypebase
// extensions not from the binary map format.
int time;
uint16_t cstat2;
};
@ -451,6 +457,7 @@ struct spritetype : public spritetypebase
{
int16_t owner;
int16_t detail;
uint16_t cstat2;
};
//=============================================================================
@ -471,7 +478,7 @@ struct tspritetype : public spritetypebase
picnum = spr->picnum;
shade = spr->shade;
pal = spr->pal;
clipdist = spr->clipdist;
clipdist = 0;
blend = spr->blend;
xrepeat = spr->xrepeat;
yrepeat = spr->yrepeat;
@ -487,14 +494,13 @@ struct tspritetype : public spritetypebase
hitag = spr->hitag;
extra = spr->extra;
time = spr->time;
cstat2 = spr->cstat2;
ownerActor = nullptr;
// need to copy the slope sprite flag around because for tsprites the bit combination means 'voxel'.
if ((cstat & CSTAT_SPRITE_ALIGNMENT_MASK) == CSTAT_SPRITE_ALIGNMENT_SLOPE)
{
cstat &= ~CSTAT_SPRITE_ALIGNMENT_WALL;
cstat2 |= CSTAT2_SPRITE_SLOPE;
clipdist |= TSPR_SLOPESPRITE;
}
}

View file

@ -127,7 +127,7 @@ void HWFlat::MakeVertices(HWDrawInfo* di)
auto vp = ret.first;
float x = !(Sprite->cstat & CSTAT_SPRITE_XFLIP) ? 0.f : 1.f;
float y = !(Sprite->cstat & CSTAT_SPRITE_YFLIP) ? 0.f : 1.f;
if (Sprite->cstat2 & CSTAT2_SPRITE_SLOPE)
if (Sprite->clipdist & TSPR_SLOPESPRITE)
{
int posx = int(di->Viewpoint.Pos.X * 16.f);

View file

@ -460,7 +460,7 @@ bool HWSprite::ProcessVoxel(HWDrawInfo* di, voxmodel_t* vox, tspritetype* spr, s
voxel = vox;
auto ang = spr->ang + ownerActor->sprext.angoff;
if ((spr->cstat2 & CSTAT2_SPRITE_MDLROTATE) || rotate)
if ((spr->clipdist & TSPR_MDLROTATE) || rotate)
{
int myclock = (PlayClock << 3) + MulScale(4 << 3, (int)di->Viewpoint.TicFrac, 16);
ang = (ang + myclock) & 2047;

View file

@ -691,7 +691,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
int const nVoxel = tiletovox[pTSprite->picnum];
if (nVoxel != -1 && (picanm[nRootTile].extra & 7) == 7)
pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting.
pTSprite->clipdist |= TSPR_MDLROTATE; // per-sprite rotation setting.
}
if ((pTSprite->cstat & CSTAT_SPRITE_ALIGNMENT_MASK) != CSTAT_SPRITE_ALIGNMENT_SLAB && hw_models && !(owneractor->sprext.flags & SPREXT_NOTMD))
@ -706,7 +706,7 @@ void viewProcessSprites(tspritetype* tsprite, int& spritesortcnt, int32_t cX, in
pTSprite->xoffset += tileLeftOffset(nAnimTile);
if ((picanm[nRootTile].extra & 7) == 7)
pTSprite->cstat2 |= CSTAT2_SPRITE_MDLROTATE; // per-sprite rotation setting.
pTSprite->clipdist |= TSPR_MDLROTATE; // per-sprite rotation setting.
}
}

View file

@ -584,7 +584,7 @@ int seq_PlotSequence(int nSprite, int16_t edx, int16_t nFrame, int16_t ecx)
tsp->ownerActor = pTSprite->ownerActor;
tsp->sectp = pTSprite->sectp;
tsp->cstat = pTSprite->cstat |= CSTAT_SPRITE_YCENTER;
tsp->cstat2 = pTSprite->cstat2;
tsp->clipdist = pTSprite->clipdist;
tsp->statnum = esi;
if (ChunkFlag[nBase] & 1)