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_RELANG = 1 << 4,
SPF_NOTIMEFREEZE = 1 << 5, SPF_NOTIMEFREEZE = 1 << 5,
SPF_ROLL = 1 << 6, SPF_ROLL = 1 << 6,
SPF_REPLACE = 1 << 7,
SPF_NO_XY_BILLBOARD = 1 << 8,
}; };
DEFINE_ACTION_FUNCTION(AActor, A_SpawnParticle) DEFINE_ACTION_FUNCTION(AActor, A_SpawnParticle)

View file

@ -271,7 +271,7 @@ void P_ThinkParticles (FLevelLocals *Level)
{ {
particle = &Level->Particles[i]; particle = &Level->Particles[i];
i = particle->tnext; i = particle->tnext;
if (Level->isFrozen() && !particle->notimefreeze) if (Level->isFrozen() && !(particle->flags &PT_NOTIMEFREEZE))
{ {
prev = particle; prev = particle;
continue; continue;
@ -305,7 +305,7 @@ void P_ThinkParticles (FLevelLocals *Level)
particle->Pos.Z += particle->Vel.Z; particle->Pos.Z += particle->Vel.Z;
particle->Vel += particle->Acc; particle->Vel += particle->Acc;
if(particle->doRoll) if(particle->flags & PT_DOROLL)
{ {
particle->Roll += particle->RollVel; particle->Roll += particle->RollVel;
particle->RollVel += particle->RollAcc; particle->RollVel += particle->RollAcc;
@ -340,6 +340,7 @@ enum PSFlag
PS_NOTIMEFREEZE = 1 << 5, PS_NOTIMEFREEZE = 1 << 5,
PS_ROLL = 1 << 6, PS_ROLL = 1 << 6,
PS_REPLACE = 1 << 7, 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, 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->bright = !!(flags & PS_FULLBRIGHT);
particle->size = size; particle->size = size;
particle->sizestep = sizestep; particle->sizestep = sizestep;
particle->notimefreeze = !!(flags & PS_NOTIMEFREEZE);
particle->texture = texture; particle->texture = texture;
particle->style = style; particle->style = style;
particle->Roll = startroll; particle->Roll = startroll;
particle->RollVel = rollvel; particle->RollVel = rollvel;
particle->RollAcc = rollacc; 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 // [RH] Particle details
enum EParticleFlags
{
PT_NOTIMEFREEZE = 1,
PT_DOROLL = 1 << 1,
PT_NOXYBILLBOARD = 1 << 2,
};
struct particle_t struct particle_t
{ {
DVector3 Pos; DVector3 Pos;
@ -65,7 +72,7 @@ struct particle_t
double Roll, RollVel, RollAcc; double Roll, RollVel, RollAcc;
uint16_t tnext, snext, tprev; uint16_t tnext, snext, tprev;
uint8_t bright; uint8_t bright;
bool notimefreeze, doRoll; uint8_t flags;
}; };
const uint16_t NO_PARTICLE = 0xffff; const uint16_t NO_PARTICLE = 0xffff;

View file

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

View file

@ -691,6 +691,7 @@ enum EParticleFlags
SPF_NOTIMEFREEZE = 1 << 5, SPF_NOTIMEFREEZE = 1 << 5,
SPF_ROLL = 1 << 6, SPF_ROLL = 1 << 6,
SPF_REPLACE = 1 << 7, SPF_REPLACE = 1 << 7,
SPF_NO_XY_BILLBOARD = 1 << 8,
SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG SPF_RELATIVE = SPF_RELPOS|SPF_RELVEL|SPF_RELACCEL|SPF_RELANG
}; };