summaryrefslogtreecommitdiff
path: root/src/particle
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-03 20:17:11 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-03 20:17:53 +0300
commit4f276b2cf2ae45928eeab9b96e31343c45868afb (patch)
treee77e85bac07b7057bc2315bbf2def32b99825e01 /src/particle
parentc31d57561a06b4375f596e5c16bf67e99f2c53d7 (diff)
downloadplus-4f276b2cf2ae45928eeab9b96e31343c45868afb.tar.gz
plus-4f276b2cf2ae45928eeab9b96e31343c45868afb.tar.bz2
plus-4f276b2cf2ae45928eeab9b96e31343c45868afb.tar.xz
plus-4f276b2cf2ae45928eeab9b96e31343c45868afb.zip
Dont update particles located in long distance from screen.
Diffstat (limited to 'src/particle')
-rw-r--r--src/particle/particle.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/particle/particle.cpp b/src/particle/particle.cpp
index ac9ba8394..f6b951004 100644
--- a/src/particle/particle.cpp
+++ b/src/particle/particle.cpp
@@ -25,6 +25,8 @@
#include "configuration.h"
#include "logger.h"
+#include "gui/viewport.h"
+
#include "particle/animationparticle.h"
#include "particle/particleemitter.h"
#include "particle/rotationalparticle.h"
@@ -238,10 +240,24 @@ bool Particle::update() restrict2
// Update child particles
+ const int cameraX = viewport->getCameraX();
+ const int cameraY = viewport->getCameraY();
+ const float x1 = static_cast<float>(cameraX - 3000);
+ const float y1 = static_cast<float>(cameraY - 2000);
+ const float x2 = static_cast<float>(cameraX + 3000);
+ const float y2 = static_cast<float>(cameraY + 2000);
+
for (ParticleIterator p = mChildParticles.begin(),
fp2 = mChildParticles.end(); p != fp2; )
{
Particle *restrict const particle = *p;
+ const float posX = particle->mPos.x;
+ const float posY = particle->mPos.y;
+ if (posX < x1 || posX > x2 || posY < y1 || posY > y2)
+ {
+ ++p;
+ continue;
+ }
// move particle with its parent if desired
if (particle->mFollow)
particle->moveBy(change);