From 47cf0d69e8026927ca69547a17ac8e1d288538b7 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 12 Nov 2015 16:02:15 +0300 Subject: Improve a bit particles creation. --- src/particle/particle.cpp | 7 +++++-- src/particle/particleemitter.cpp | 9 +++------ src/particle/particleemitter.h | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index 9dee09754..b487e5ffb 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -203,8 +203,11 @@ bool Particle::update() { FOR_EACH (EmitterConstIterator, e, mChildEmitters) { - Particles newParticles = (*e)->createParticles(mLifetimePast); - FOR_EACH (ParticleConstIterator, it, newParticles) + std::vector newParticles; + (*e)->createParticles(mLifetimePast, newParticles); + FOR_EACH (std::vector::const_iterator, + it, + newParticles) { Particle *const p = *it; p->moveBy(mPos); diff --git a/src/particle/particleemitter.cpp b/src/particle/particleemitter.cpp index af9b32fe4..5cba3ba54 100644 --- a/src/particle/particleemitter.cpp +++ b/src/particle/particleemitter.cpp @@ -483,14 +483,13 @@ ParticleEmitter::readParticleEmitterProp(XmlNodePtrConst propertyNode, T def) return retval; } -std::list ParticleEmitter::createParticles(const int tick) +void ParticleEmitter::createParticles(const int tick, + std::vector &newParticles) { - std::list newParticles; - if (mOutputPauseLeft > 0) { mOutputPauseLeft --; - return newParticles; + return; } mOutputPauseLeft = mOutputPause.value(tick); @@ -574,8 +573,6 @@ std::list ParticleEmitter::createParticles(const int tick) newParticles.push_back(newParticle); } - - return newParticles; } void ParticleEmitter::adjustSize(const int w, const int h) diff --git a/src/particle/particleemitter.h b/src/particle/particleemitter.h index 395f09ac4..41381b6e1 100644 --- a/src/particle/particleemitter.h +++ b/src/particle/particleemitter.h @@ -66,9 +66,9 @@ class ParticleEmitter final /** * Spawns new particles - * @return: a list of created particles */ - std::list createParticles(const int tick); + void createParticles(const int tick, + std::vector &newParticles); /** * Sets the target of the particles that are created -- cgit v1.2.3-70-g09d2