From 4b039f935f8a3314625d43ee9fc3bb4c18a4eb4a Mon Sep 17 00:00:00 2001 From: auria Date: Mon, 10 Jan 2011 01:57:18 +0000 Subject: [PATCH] Hopefully work around emitter pause bug by removing the emitter when nothing is emitted git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/trunk@7348 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/graphics/particle_emitter.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/graphics/particle_emitter.cpp b/src/graphics/particle_emitter.cpp index 9b3938fd4..652863172 100644 --- a/src/graphics/particle_emitter.cpp +++ b/src/graphics/particle_emitter.cpp @@ -80,6 +80,20 @@ void ParticleEmitter::setCreationRate(float f) { m_emitter->setMinParticlesPerSecond(int(f)); m_emitter->setMaxParticlesPerSecond(int(f)); + + // FIXME: to work around irrlicht bug, when an emitter is paused by setting the rate + // to 0 results in a massive emission when enabling it back. In irrlicht 1.8 + // the node has a method called "clearParticles" that should be cleaner than this + if (f == 0.0f) + { + m_emitter->grab(); + m_node->setEmitter(NULL); + } + else if (m_node->getEmitter() == NULL) + { + m_node->setEmitter(m_emitter); + m_emitter->drop(); + } } // setCreationRate //-----------------------------------------------------------------------------