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
This commit is contained in:
parent
f47fd8875c
commit
c0daa75353
|
|
@ -221,10 +221,13 @@ class ParticleEffect(NodePath):
|
|||
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 @@ PUBLISHED:
|
|||
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 @@ PUBLISHED:
|
|||
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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue