Fixed bug with animations.

- Before, if you shoot and go to the main menu, then the traces of the bullets were not removed from the map. This was because the animation stopped updating and the time kept going forward. As a result, the system believed that the animations had already passed, although in reality they had not. Now animations are tied not to their own, but to the global time counter
master
Vectozavr 2021-10-13 00:04:48 +07:00
parent d3684f8aa6
commit 4dae42a3ef
3 changed files with 6 additions and 13 deletions

View File

@ -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:

View File

@ -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;

View File

@ -22,6 +22,8 @@ namespace Interpolation {
static double dBouncing(double t, double dt);
};
double Interpolation::Linear(double t) {
if(t < 0)
t = -t;