Allow Disabling of XY Billboard for Particles

This commit is contained in:
Ricardo Luís Vaz Silva 2022-11-02 15:08:15 -03:00 committed by Christoph Oelckers
parent 964534f4b0
commit f666edc60c
5 changed files with 42 additions and 21 deletions

View file

@ -1620,6 +1620,8 @@ enum SPFflag
SPF_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5,
SPF_ROLL = 1 << 6,
SPF_REPLACE = 1 << 7,
SPF_NO_XY_BILLBOARD = 1 << 8,
};
DEFINE_ACTION_FUNCTION(AActor, A_SpawnParticle)

View file

@ -271,7 +271,7 @@ void P_ThinkParticles (FLevelLocals *Level)
{
particle = &Level->Particles[i];
i = particle->tnext;
if (Level->isFrozen() && !particle->notimefreeze)
if (Level->isFrozen() && !(particle->flags &PT_NOTIMEFREEZE))
{
prev = particle;
continue;
@ -305,7 +305,7 @@ void P_ThinkParticles (FLevelLocals *Level)
particle->Pos.Z += particle->Vel.Z;
particle->Vel += particle->Acc;
if(particle->doRoll)
if(particle->flags & PT_DOROLL)
{
particle->Roll += particle->RollVel;
particle->RollVel += particle->RollAcc;
@ -336,10 +336,11 @@ void P_ThinkParticles (FLevelLocals *Level)
enum PSFlag
{
PS_FULLBRIGHT = 1,
PS_NOTIMEFREEZE = 1 << 5,
PS_ROLL = 1 << 6,
PS_REPLACE = 1 << 7,
PS_FULLBRIGHT = 1,
PS_NOTIMEFREEZE = 1 << 5,
PS_ROLL = 1 << 6,
PS_REPLACE = 1 << 7,
PS_NO_XY_BILLBOARD = 1 << 8,
};
void P_SpawnParticle(FLevelLocals *Level, const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, double startalpha, int lifetime, double size,
@ -360,13 +361,23 @@ void P_SpawnParticle(FLevelLocals *Level, const DVector3 &pos, const DVector3 &v
particle->bright = !!(flags & PS_FULLBRIGHT);
particle->size = size;
particle->sizestep = sizestep;
particle->notimefreeze = !!(flags & PS_NOTIMEFREEZE);
particle->texture = texture;
particle->style = style;
particle->Roll = startroll;
particle->RollVel = rollvel;
particle->RollAcc = rollacc;
particle->doRoll = !!(flags & PS_ROLL);
if(flags & PS_NOTIMEFREEZE)
{
particle->flags |= PT_NOTIMEFREEZE;
}
if(flags & PS_ROLL)
{
particle->flags |= PT_DOROLL;
}
if(flags & PS_NO_XY_BILLBOARD)
{
particle->flags |= PT_NOXYBILLBOARD;
}
}
}

View file

@ -50,6 +50,13 @@ struct FLevelLocals;
// [RH] Particle details
enum EParticleFlags
{
PT_NOTIMEFREEZE = 1,
PT_DOROLL = 1 << 1,
PT_NOXYBILLBOARD = 1 << 2,
};
struct particle_t
{
DVector3 Pos;
@ -65,7 +72,7 @@ struct particle_t
double Roll, RollVel, RollAcc;
uint16_t tnext, snext, tprev;
uint8_t bright;
bool notimefreeze, doRoll;
uint8_t flags;
};
const uint16_t NO_PARTICLE = 0xffff;

View file

@ -382,7 +382,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
}
// [BB] Billboard stuff
const bool drawWithXYBillboard = ((particle && gl_billboard_particles) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
const bool drawWithXYBillboard = ((particle && gl_billboard_particles && !(particle->flags & PT_NOXYBILLBOARD)) || (!(actor && actor->renderflags & RF_FORCEYBILLBOARD)
//&& di->mViewActor != nullptr
&& (gl_billboard_mode == 1 || (actor && actor->renderflags & RF_FORCEXYBILLBOARD))));
@ -390,7 +390,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
// [Nash] has +ROLLSPRITE
const bool drawRollSpriteActor = (actor != nullptr && actor->renderflags & RF_ROLLSPRITE);
const bool drawRollParticle = (particle != nullptr && particle->doRoll);
const bool drawRollParticle = (particle != nullptr && particle->flags & PT_DOROLL);
// [fgsfds] check sprite type mask
@ -402,7 +402,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp)
const bool useOffsets = (actor != nullptr) && !(actor->renderflags & RF_ROLLCENTER);
// [Nash] check for special sprite drawing modes
if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || isFlatSprite)
if (drawWithXYBillboard || drawBillboardFacingCamera || drawRollSpriteActor || drawRollParticle || isFlatSprite)
{
// Compute center of sprite
float xcenter = (x1 + x2)*0.5;
@ -1343,7 +1343,7 @@ void HWSprite::ProcessParticle (HWDrawInfo *di, particle_t *particle, sector_t *
y = float(particle->Pos.Y) + yvf;
z = float(particle->Pos.Z) + zvf;
if(particle->doRoll)
if(particle->flags & PT_DOROLL)
{
float rvf = (particle->RollVel) * timefrac;
Angles.Roll = TAngle<double>::fromDeg(particle->Roll + rvf);

View file

@ -683,14 +683,15 @@ enum ECheckBlockFlags
enum EParticleFlags
{
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5,
SPF_ROLL = 1 << 6,
SPF_REPLACE = 1 << 7,
SPF_FULLBRIGHT = 1,
SPF_RELPOS = 1 << 1,
SPF_RELVEL = 1 << 2,
SPF_RELACCEL = 1 << 3,
SPF_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5,
SPF_ROLL = 1 << 6,
SPF_REPLACE = 1 << 7,
SPF_NO_XY_BILLBOARD = 1 << 8,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
};