Support negative fadestep for particles

This commit is contained in:
RaveYard 2024-02-27 03:01:37 +01:00 committed by Christoph Oelckers
parent 47be9c1e54
commit 205d4b5ff3
2 changed files with 4 additions and 4 deletions

View file

@ -1691,7 +1691,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnParticleEx)
PARAM_FLOAT (rollacc)
startalpha = clamp(startalpha, 0., 1.);
if (fadestep > 0) fadestep = clamp(fadestep, 0., 1.);
fadestep = clamp(fadestep, -1.0, 1.0);
size = fabs(size);
if (lifetime != 0)
{

View file

@ -306,10 +306,9 @@ void P_ThinkParticles (FLevelLocals *Level)
continue;
}
auto oldtrans = particle->alpha;
particle->alpha -= particle->fadestep;
particle->size += particle->sizestep;
if (particle->alpha <= 0 || oldtrans < particle->alpha || --particle->ttl <= 0 || (particle->size <= 0))
if (particle->alpha <= 0 || --particle->ttl <= 0 || (particle->size <= 0))
{ // The particle has expired, so free it
*particle = {};
if (prev)
@ -375,7 +374,7 @@ void P_SpawnParticle(FLevelLocals *Level, const DVector3 &pos, const DVector3 &v
particle->Acc = FVector3(accel);
particle->color = ParticleColor(color);
particle->alpha = float(startalpha);
if (fadestep < 0) particle->fadestep = FADEFROMTTL(lifetime);
if (fadestep <= -1.0) particle->fadestep = FADEFROMTTL(lifetime);
else particle->fadestep = float(fadestep);
particle->ttl = lifetime;
particle->size = size;