Particle* ParticleSystem::createParticle(void) { Particle* p = 0; if (!mFreeParticles.empty()) { // Fast creation (don't use superclass since emitter will init) p = mFreeParticles.front(); mActiveParticles.splice(mActiveParticles.end(), mFreeParticles, mFreeParticles.begin()); p->_notifyOwner(this); } return p; }
Particle* ParticleSystem::createEmitterParticle(const String& emitterName) { // Get the appropriate list and retrieve an emitter Particle* p = 0; std::list<ParticleEmitter*>* fee = findFreeEmittedEmitter(emitterName); if (fee && !fee->empty()) { p = fee->front(); p->particleType = Particle::Emitter; fee->pop_front(); mActiveParticles.push_back(p); // Also add to mActiveEmittedEmitters. This is needed to traverse through all active emitters // that are emitted. Don't use mActiveParticles for that (although they are added to // mActiveParticles also), because it would take too long to traverse. mActiveEmittedEmitters.push_back(static_cast<ParticleEmitter*>(p)); p->_notifyOwner(this); } return p; }