Skip to content
Permalink
Browse files

particles: add parameter to delay particle birth in soft_start()

Also adds a get_tics_since_birth() getter.

This feature can be used to synchronize different particle effects.

Closes #769
  • Loading branch information
ArsThaumaturgis authored and rdb committed Nov 10, 2019
1 parent f47fd88 commit c0daa753536caf474dd7f420d36ba74c5aaf1c26
@@ -221,10 +221,13 @@ def softStop(self):
for particles in self.getParticlesList():
particles.softStop()

def softStart(self):
def softStart(self, firstBirthDelay=None):
if self.__isValid():
for particles in self.getParticlesList():
particles.softStart()
if firstBirthDelay is not None:
particles.softStart(br=-1, first_birth_delay=firstBirthDelay)
else:
particles.softStart()
else:
# Not asserting here since we want to crash live clients for more expedient bugfix
# (Sorry, live clients)
@@ -58,6 +58,18 @@ soft_start(PN_stdfloat br) {
_tics_since_birth = 0.0f;
}

/**
* Causes system to use birth rate set by set_birth_rate(), with the system's
* first birth being delayed by the value of first_birth_delay. Note that a
* negative delay is perfectly valid, causing the first birth to happen
* sooner rather than later.
*/
INLINE void ParticleSystem::
soft_start(PN_stdfloat br, PN_stdfloat first_birth_delay) {
soft_start(br);
_tics_since_birth = -first_birth_delay;
}

/**
* Causes system to use birth rate set by set_soft_birth_rate()
*/
@@ -342,6 +354,14 @@ get_floor_z() const {
return _floor_z;
}

/**

*/
INLINE PN_stdfloat ParticleSystem::
get_tics_since_birth() const {
return _tics_since_birth;
}

/**

*/
@@ -83,6 +83,7 @@ class EXPCL_PANDA_PARTICLESYSTEM ParticleSystem : public Physical {
INLINE BaseParticleEmitter *get_emitter() const;
INLINE BaseParticleFactory *get_factory() const;
INLINE PN_stdfloat get_floor_z() const;
INLINE PN_stdfloat get_tics_since_birth() const;

// particle template vector

@@ -96,6 +97,7 @@ class EXPCL_PANDA_PARTICLESYSTEM ParticleSystem : public Physical {
INLINE void clear_to_initial();
INLINE void soft_stop(PN_stdfloat br = 0.0);
INLINE void soft_start(PN_stdfloat br = 0.0);
INLINE void soft_start(PN_stdfloat br, PN_stdfloat first_birth_delay);
void update(PN_stdfloat dt);

virtual void output(std::ostream &out) const;

0 comments on commit c0daa75

Please sign in to comment.
You can’t perform that action at this time.