made animations extremely precise

master
Vectozavr 2021-11-01 23:04:10 +07:00
parent 01d89bfc66
commit 6e35a531c7
4 changed files with 20 additions and 16 deletions

View File

@ -86,10 +86,10 @@ void Player::addWeapon(std::shared_ptr<Weapon> weapon) {
_weapons.back()->setReloadCallBack([this]() { _weapons.back()->setReloadCallBack([this]() {
Timeline::animate(AnimationListTag("reload_weapon"), Timeline::animate(AnimationListTag("reload_weapon"),
std::make_shared<ARotateLeft>(_weapons[_selectedWeapon], std::make_shared<ARotateLeft>(_weapons[_selectedWeapon],
10 * Consts::PI, 4 * Consts::PI,
_weapons[_selectedWeapon]->reloadTime() / 2, _weapons[_selectedWeapon]->reloadTime()/2,
Animation::LoopOut::None, Animation::LoopOut::None,
Animation::InterpolationType::Linear)); Animation::InterpolationType::Cos));
}); });
// add call back function to create fire traces // add call back function to create fire traces

View File

@ -15,6 +15,7 @@
#include "engine/animation/ARotateRelativePoint.h" #include "engine/animation/ARotateRelativePoint.h"
#include "engine/animation/ATranslateToPoint.h" #include "engine/animation/ATranslateToPoint.h"
#include "engine/animation/AWait.h" #include "engine/animation/AWait.h"
#include "engine/animation/ATranslate.h"
using namespace std; using namespace std;

View File

@ -17,18 +17,6 @@ bool Animation::updateState() {
// linear normalized time: // linear normalized time:
_dtime = Time::deltaTime() / _duration; _dtime = Time::deltaTime() / _duration;
if(_time + _dtime < 1.0) {
_time += _dtime;
} else {
_dtime = 1.0 - _time;
_time = 1.0 - _dtime;
_finished = true;
}
if (_looped == LoopOut::Continue && _time > 0.5) {
_time = 0.5;
}
switch (_intType) { switch (_intType) {
case InterpolationType::Bezier: case InterpolationType::Bezier:
_progress = Interpolation::Bezier(Consts::BEZIER[0], Consts::BEZIER[1], _time); _progress = Interpolation::Bezier(Consts::BEZIER[0], Consts::BEZIER[1], _time);
@ -51,6 +39,22 @@ bool Animation::updateState() {
"Animation::updateState: unknown interpolation type " + std::to_string(static_cast<int>(_intType))}; "Animation::updateState: unknown interpolation type " + std::to_string(static_cast<int>(_intType))};
} }
if(_time + _dtime < 1.0) {
_time += _dtime;
} else {
_dtime = 1.0 - _time;
_time = 1.0;
_dprogress = 1 - _progress;
_progress = 1.0;
update();
_finished = true;
return false;
}
if (_looped == LoopOut::Continue && _time > 0.5) {
_time = 0.5;
}
update(); update();
return !_finished; return !_finished;

View File

@ -20,7 +20,6 @@ public:
}; };
enum class LoopOut { enum class LoopOut {
None, None,
Cycle,
Continue Continue
}; };
private: private: