summaryrefslogtreecommitdiff
path: root/src/particle/rotationalparticle.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-03-16 21:40:35 +0300
committerAndrei Karas <akaras@inbox.ru>2016-03-16 21:40:35 +0300
commit7c6cb759593ec5abc8cf2a3b04a388c7cba269b8 (patch)
tree5d4a06f43a1717502b7f6e19153a28989ba79c8d /src/particle/rotationalparticle.cpp
parentc4a6dd36733fc3365d5a8913e8cdc7b4c1175c8d (diff)
downloadmv-7c6cb759593ec5abc8cf2a3b04a388c7cba269b8.tar.gz
mv-7c6cb759593ec5abc8cf2a3b04a388c7cba269b8.tar.bz2
mv-7c6cb759593ec5abc8cf2a3b04a388c7cba269b8.tar.xz
mv-7c6cb759593ec5abc8cf2a3b04a388c7cba269b8.zip
Move AnimationParticle and RotationalParticle update functions into Particle.
Diffstat (limited to 'src/particle/rotationalparticle.cpp')
-rw-r--r--src/particle/rotationalparticle.cpp40
1 files changed, 0 insertions, 40 deletions
diff --git a/src/particle/rotationalparticle.cpp b/src/particle/rotationalparticle.cpp
index a52e0ca4b..71e9f09fd 100644
--- a/src/particle/rotationalparticle.cpp
+++ b/src/particle/rotationalparticle.cpp
@@ -26,9 +26,6 @@
#include "debug.h"
-static const double PI = M_PI;
-static const float PI2 = 2 * M_PI;
-
RotationalParticle::RotationalParticle(Animation *restrict const animation) :
ImageParticle(nullptr)
{
@@ -49,40 +46,3 @@ RotationalParticle::~RotationalParticle()
{
mImage = nullptr;
}
-
-bool RotationalParticle::update() restrict2
-{
- // TODO: cache velocities to avoid spamming atan2()
-
- const int size = mAnimation->getLength();
- if (!size)
- return false;
-
- float rad = static_cast<float>(atan2(mVelocity.x, mVelocity.y));
- if (rad < 0)
- rad = PI2 + rad;
-
- const float range = static_cast<const float>(PI / size);
-
- // Determines which frame the particle should play
- if (rad < range || rad > PI2 - range)
- {
- mAnimation->setFrame(0);
- }
- else
- {
- for (int c = 1; c < size; c++)
- {
- if (((static_cast<float>(c) * (2 * range)) - range) < rad
- && rad < ((static_cast<float>(c) * (2 * range)) + range))
- {
- mAnimation->setFrame(c);
- break;
- }
- }
- }
-
- mImage = mAnimation->getCurrentImage();
-
- return Particle::update();
-}