Skip to content

Commit

Permalink
Support negative fadestep for particles
Browse files Browse the repository at this point in the history
  • Loading branch information
MrRaveYard authored and coelckers committed Feb 27, 2024
1 parent 47be9c1 commit 205d4b5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/playsim/p_actionfunctions.cpp
Expand Up @@ -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)
{
Expand Down
5 changes: 2 additions & 3 deletions src/playsim/p_effect.cpp
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 205d4b5

Please sign in to comment.