From b38844700debb737dad4090774ad0426a0ebcc02 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 10 Mar 2013 23:20:37 +0300 Subject: Improve particle classes. --- src/particlecontainer.cpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) (limited to 'src/particlecontainer.cpp') diff --git a/src/particlecontainer.cpp b/src/particlecontainer.cpp index 4994ddadd..efab44619 100644 --- a/src/particlecontainer.cpp +++ b/src/particlecontainer.cpp @@ -32,7 +32,8 @@ ParticleContainer::ParticleContainer(ParticleContainer *const parent, const bool delParent): mDelParent(delParent), mNext(parent) -{} +{ +} ParticleContainer::~ParticleContainer() { @@ -82,9 +83,10 @@ void ParticleList::removeLocally(const Particle *const particle) for (std::list::iterator it = mElements.begin(); it != mElements.end(); ) { - if (*it == particle) + Particle *const p = *it; + if (p == particle) { - (*it)->kill(); + p->kill(); it = mElements.erase(it); } else @@ -109,10 +111,11 @@ void ParticleList::moveTo(const float x, const float y) for (std::list::iterator it = mElements.begin(); it != mElements.end(); ) { - (*it)->moveTo(x, y); - if ((*it)->isExtinct()) + Particle *const p = *it; + p->moveTo(x, y); + if (p->isExtinct()) { - (*it)->kill(); + p->kill(); it = mElements.erase(it); } else @@ -176,13 +179,14 @@ void ParticleVector::moveTo(const float x, const float y) for (std::vector::iterator it = mIndexedElements.begin(); it != mIndexedElements.end(); ++it) { - if (*it) + Particle *const p = *it; + if (p) { - (*it)->moveTo(x, y); + p->moveTo(x, y); - if ((*it)->isExtinct()) + if (p->isExtinct()) { - (*it)->kill(); + p->kill(); *it = nullptr; } } -- cgit v1.2.3-70-g09d2