diff --git a/engine/animation/Animation.cpp b/engine/animation/Animation.cpp index 458261b..d36eb36 100644 --- a/engine/animation/Animation.cpp +++ b/engine/animation/Animation.cpp @@ -6,22 +6,16 @@ bool Animation::updateState() { if(!_started) { - _startAnimationPoint = Time::time(); - _endAnimationPoint = _startAnimationPoint + _duration; _started = true; return _duration != 0; } - _timeOld = _time; // linear normalized time: - _time = (Time::time() - _startAnimationPoint)/(_endAnimationPoint - _startAnimationPoint); + _dtime = Time::deltaTime()/_duration; + _time += _dtime; - if(_looped != LoopOut::Continue || _time < 0.5) - _dtime = _time - _timeOld; - else { - _time = _timeOld; - //_intType = linear; - } + if(_looped == LoopOut::Continue && _time > 0.5) + _time = 0.5; switch (_intType) { case InterpolationType::bezier: diff --git a/engine/animation/Animation.h b/engine/animation/Animation.h index e1f4db7..62cee7b 100644 --- a/engine/animation/Animation.h +++ b/engine/animation/Animation.h @@ -26,10 +26,7 @@ public: protected: double _time = 0; // normalized time (from 0 to 1) double _dtime = 0; - double _timeOld = 0; - double _endAnimationPoint = 0; - double _startAnimationPoint = 0; double _duration = 0; bool _started = false; LoopOut _looped = LoopOut::None; diff --git a/engine/animation/Interpolation.h b/engine/animation/Interpolation.h index 90ce54c..409dccd 100644 --- a/engine/animation/Interpolation.h +++ b/engine/animation/Interpolation.h @@ -22,6 +22,8 @@ namespace Interpolation { static double dBouncing(double t, double dt); }; + + double Interpolation::Linear(double t) { if(t < 0) t = -t;