fix minor bug with new anim optimization

This commit is contained in:
vaxerski 2022-06-30 13:11:10 +02:00
parent cfc1f6c211
commit d1564299d2

View file

@ -37,6 +37,11 @@ void CAnimationManager::tick() {
DEFAULTBEZIER = m_mBezierCurves.find("default"); DEFAULTBEZIER = m_mBezierCurves.find("default");
for (auto& av : m_lAnimatedVariables) { for (auto& av : m_lAnimatedVariables) {
// first of all, check if we need to update it at all
if (!av->isBeingAnimated())
continue;
// get speed // get speed
const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed; const auto SPEED = *av->m_pSpeed == 0 ? *PANIMSPEED : *av->m_pSpeed;
@ -44,12 +49,6 @@ void CAnimationManager::tick() {
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count(); const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - av->animationBegin).count();
const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f); const float SPENT = std::clamp((DURATIONPASSED / 100.f) / SPEED, 0.f, 1.f);
// first of all, check if we need to update it at all
if (SPENT >= 1.f) {
av->warp();
continue;
}
// window stuff // window stuff
const auto PWINDOW = (CWindow*)av->m_pWindow; const auto PWINDOW = (CWindow*)av->m_pWindow;
const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace; const auto PWORKSPACE = (CWorkspace*)av->m_pWorkspace;
@ -76,6 +75,11 @@ void CAnimationManager::tick() {
break; break;
} }
if (SPENT >= 1.f) {
av->warp();
break;
}
const auto DELTA = av->m_fGoal - av->m_fBegun; const auto DELTA = av->m_fGoal - av->m_fBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
@ -92,6 +96,11 @@ void CAnimationManager::tick() {
break; break;
} }
if (SPENT >= 1.f) {
av->warp();
break;
}
const auto DELTA = av->m_vGoal - av->m_vBegun; const auto DELTA = av->m_vGoal - av->m_vBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);
@ -108,6 +117,11 @@ void CAnimationManager::tick() {
break; break;
} }
if (SPENT >= 1.f) {
av->warp();
break;
}
const auto DELTA = av->m_cGoal - av->m_cBegun; const auto DELTA = av->m_cGoal - av->m_cBegun;
const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier); const auto BEZIER = m_mBezierCurves.find(*av->m_pBezier);