From 7c6cb759593ec5abc8cf2a3b04a388c7cba269b8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 16 Mar 2016 21:40:35 +0300 Subject: Move AnimationParticle and RotationalParticle update functions into Particle. --- src/particle/rotationalparticle.cpp | 40 ------------------------------------- 1 file changed, 40 deletions(-) (limited to 'src/particle/rotationalparticle.cpp') 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(atan2(mVelocity.x, mVelocity.y)); - if (rad < 0) - rad = PI2 + rad; - - const float range = static_cast(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(c) * (2 * range)) - range) < rad - && rad < ((static_cast(c) * (2 * range)) + range)) - { - mAnimation->setFrame(c); - break; - } - } - } - - mImage = mAnimation->getCurrentImage(); - - return Particle::update(); -} -- cgit v1.2.3-70-g09d2