Skip to content

Commit 5cd3b3a

Browse files
authored
Extend particle interpolation to lifetime (#6910)
* the naive method * the correct method
1 parent 75b61ef commit 5cd3b3a

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

code/particle/ParticleEffect.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,16 @@ auto ParticleEffect::processSourceInternal(float interp, const ParticleSource& s
339339
info.length = m_length.next() * lengthMultiplier;
340340
if (m_hasLifetime) {
341341
if (m_parentLifetime)
342-
// if we were spawned by a particle, parentLifetime is the parent's remaining liftime and m_lifetime is a factor of that
342+
// if we were spawned by a particle, parentLifetime is the parent's remaining lifetime and m_lifetime is a factor of that
343343
info.lifetime = parentLifetime * m_lifetime.next() * lifetimeMultiplier;
344344
else
345345
info.lifetime = m_lifetime.next() * lifetimeMultiplier;
346+
346347
info.lifetime_from_animation = m_keep_anim_length_if_available;
347348
}
349+
350+
info.starting_age = interp * f2fl(Frametime);
351+
348352
info.size_lifetime_curve = m_size_lifetime_curve;
349353
info.vel_lifetime_curve = m_vel_lifetime_curve;
350354

code/particle/particle.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ namespace particle
159159

160160
part->pos = info->pos;
161161
part->velocity = info->vel;
162-
part->age = 0.0f;
162+
part->age = info->starting_age;
163163
part->max_life = info->lifetime;
164164
part->radius = info->rad;
165165
part->bitmap = info->bitmap;

code/particle/particle.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace particle
6262
vec3d pos = vmd_zero_vector;
6363
vec3d vel = vmd_zero_vector;
6464
float lifetime = -1.0f;
65+
float starting_age = 0.0f;
6566
float rad = -1.0f;
6667
int bitmap = -1;
6768
int nframes = -1;

0 commit comments

Comments
 (0)