summaryrefslogtreecommitdiff
path: root/src/particlecontainer.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-03-10 23:20:37 +0300
committerAndrei Karas <akaras@inbox.ru>2013-03-10 23:37:18 +0300
commitb38844700debb737dad4090774ad0426a0ebcc02 (patch)
tree83a0cfbda2e8a1ef8ac9854469e77d8774779981 /src/particlecontainer.cpp
parent1c423d3301cc1a04c11a8605822699e13d473a8a (diff)
downloadmv-b38844700debb737dad4090774ad0426a0ebcc02.tar.gz
mv-b38844700debb737dad4090774ad0426a0ebcc02.tar.bz2
mv-b38844700debb737dad4090774ad0426a0ebcc02.tar.xz
mv-b38844700debb737dad4090774ad0426a0ebcc02.zip
Improve particle classes.
Diffstat (limited to 'src/particlecontainer.cpp')
-rw-r--r--src/particlecontainer.cpp24
1 files changed, 14 insertions, 10 deletions
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<Particle *>::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<Particle *>::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<Particle *>::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;
}
}