From 2cf3c1e9938d64fe7b2cf1cffca0ec8b12970e80 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 19 May 2016 20:15:51 +0300 Subject: Move child particles only if current particle changed position. --- src/particle/particle.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp index b28e3a819..728433ae9 100644 --- a/src/particle/particle.cpp +++ b/src/particle/particle.cpp @@ -237,11 +237,19 @@ bool Particle::update() restrict2 { if (mAlive == AliveStatus::ALIVE) { - const Vector oldPos = mPos; - if (mLifetimeLeft == 0) { mAlive = AliveStatus::DEAD_TIMEOUT; + + if (mChildParticles.empty()) + { + if (mAlive != AliveStatus::ALIVE && + mAutoDelete) + { + return false; + } + return true; + } } else { @@ -289,24 +297,26 @@ bool Particle::update() restrict2 } mImage = mAnimation->getCurrentImage(); } + const Vector oldPos = mPos; + updateSelf(); - } - const Vector change = mPos - oldPos; - if (mChildParticles.empty()) - { - if (mAlive != AliveStatus::ALIVE && - mAutoDelete) + const Vector change = mPos - oldPos; + if (mChildParticles.empty()) { - return false; + if (mAlive != AliveStatus::ALIVE && + mAutoDelete) + { + return false; + } + return true; + } + for (ParticleIterator p = mChildMoveParticles.begin(), + fp2 = mChildMoveParticles.end(); p != fp2; ) + { + // move particle with its parent if desired + (*p)->moveBy(change); } - return true; - } - for (ParticleIterator p = mChildMoveParticles.begin(), - fp2 = mChildMoveParticles.end(); p != fp2; ) - { - // move particle with its parent if desired - (*p)->moveBy(change); } // Update child particles -- cgit v1.2.3-70-g09d2