mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
particles: expose birth_litter() to support burst emission
Closes #524 Closes #340
This commit is contained in:
parent
f21ab509ec
commit
50d27166d8
@ -36,6 +36,10 @@ class ParticleEffect(NodePath):
|
|||||||
self.addParticles(particles)
|
self.addParticles(particles)
|
||||||
self.renderParent = None
|
self.renderParent = None
|
||||||
|
|
||||||
|
def birthLitter(self):
|
||||||
|
for p in self.particlesDict.values():
|
||||||
|
p.birthLitter()
|
||||||
|
|
||||||
def cleanup(self):
|
def cleanup(self):
|
||||||
self.removeNode()
|
self.removeNode()
|
||||||
self.disable()
|
self.disable()
|
||||||
@ -269,3 +273,4 @@ class ParticleEffect(NodePath):
|
|||||||
clear_to_initial = clearToInitial
|
clear_to_initial = clearToInitial
|
||||||
soft_stop = softStop
|
soft_stop = softStop
|
||||||
soft_start = softStart
|
soft_start = softStart
|
||||||
|
birth_litter = birthLitter
|
||||||
|
@ -104,6 +104,8 @@ PUBLISHED:
|
|||||||
virtual void write_spawn_templates(std::ostream &out, int indent=0) const;
|
virtual void write_spawn_templates(std::ostream &out, int indent=0) const;
|
||||||
virtual void write(std::ostream &out, int indent=0) const;
|
virtual void write(std::ostream &out, int indent=0) const;
|
||||||
|
|
||||||
|
void birth_litter();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef PSSANITYCHECK
|
#ifdef PSSANITYCHECK
|
||||||
int sanity_check();
|
int sanity_check();
|
||||||
@ -111,7 +113,6 @@ private:
|
|||||||
|
|
||||||
bool birth_particle();
|
bool birth_particle();
|
||||||
void kill_particle(int pool_index);
|
void kill_particle(int pool_index);
|
||||||
void birth_litter();
|
|
||||||
void resize_pool(int size);
|
void resize_pool(int size);
|
||||||
|
|
||||||
pdeque< int > _free_particle_fifo;
|
pdeque< int > _free_particle_fifo;
|
||||||
|
@ -101,3 +101,38 @@ def test_particle_soft_start():
|
|||||||
system.update(1)
|
system.update(1)
|
||||||
|
|
||||||
assert system.get_living_particles() == 1
|
assert system.get_living_particles() == 1
|
||||||
|
|
||||||
|
|
||||||
|
def test_particle_burst_emission():
|
||||||
|
effect = ParticleEffect()
|
||||||
|
system = Particles("testSystem", 10)
|
||||||
|
effect.add_particles(system)
|
||||||
|
|
||||||
|
# Setup some dummy nodes, since it seems to want them
|
||||||
|
# We might normally call "start", but that calls "enable", which
|
||||||
|
# seems to assume that "base" exists and has physics and particle managers...
|
||||||
|
system.setRenderParent(NodePath(PandaNode("test")))
|
||||||
|
system.setSpawnRenderNodePath(NodePath(PandaNode("test")))
|
||||||
|
# However, we don't want normal emission, so we now soft-stop it immediately,
|
||||||
|
# before the system has a chance to update and emit.
|
||||||
|
effect.softStop()
|
||||||
|
|
||||||
|
# Now, a sanity-check: assert that we have no particles,
|
||||||
|
# Then update the system, and assert again that we
|
||||||
|
# have no particles. If so, then we're (hopefully)
|
||||||
|
# not emitting normally!
|
||||||
|
|
||||||
|
assert system.getLivingParticles() == 0
|
||||||
|
system.update(1)
|
||||||
|
assert system.getLivingParticles() == 0
|
||||||
|
|
||||||
|
# Now, the real test: emit a particle-burst!
|
||||||
|
effect.birthLitter()
|
||||||
|
|
||||||
|
# And assert that a particle has, in fact, been emitted.
|
||||||
|
assert system.getLivingParticles() == 1
|
||||||
|
|
||||||
|
# Check the snake-case version, too.
|
||||||
|
effect.birth_litter()
|
||||||
|
|
||||||
|
assert system.getLivingParticles() == 2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user