diff options
| author | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-07-20 19:26:10 +0200 |
|---|---|---|
| committer | vaxerski <43317083+vaxerski@users.noreply.github.com> | 2023-07-20 19:26:10 +0200 |
| commit | 6c1f4faff2602a6d834d8f641a8a39783bbb9465 (patch) | |
| tree | b7c662026ce9b584baf4a2d1d65d02464dd49d79 /src/helpers/AnimatedVariable.cpp | |
| parent | 7940f779e9dd670157932ce17a872c14747ad490 (diff) | |
animationmgr: avoid looping over all avars in favor of only active ones
Diffstat (limited to 'src/helpers/AnimatedVariable.cpp')
| -rw-r--r-- | src/helpers/AnimatedVariable.cpp | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp index 5b98e426..2961439d 100644 --- a/src/helpers/AnimatedVariable.cpp +++ b/src/helpers/AnimatedVariable.cpp @@ -51,13 +51,14 @@ CAnimatedVariable::~CAnimatedVariable() { } void CAnimatedVariable::unregister() { - g_pAnimationManager->m_lAnimatedVariables.remove(this); + std::erase_if(g_pAnimationManager->m_vAnimatedVariables, [&](const auto& other) { return other == this; }); m_bIsRegistered = false; + disconnectFromActive(); } void CAnimatedVariable::registerVar() { if (!m_bIsRegistered) - g_pAnimationManager->m_lAnimatedVariables.push_back(this); + g_pAnimationManager->m_vAnimatedVariables.push_back(this); m_bIsRegistered = true; } @@ -78,4 +79,15 @@ float CAnimatedVariable::getCurveValue() { return 1.f; return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT); +} + +void CAnimatedVariable::connectToActive() { + if (!m_bIsConnectedToActive) + g_pAnimationManager->m_vActiveAnimatedVariables.push_back(this); + m_bIsConnectedToActive = true; +} + +void CAnimatedVariable::disconnectFromActive() { + std::erase_if(g_pAnimationManager->m_vActiveAnimatedVariables, [&](const auto& other) { return other == this; }); + m_bIsConnectedToActive = false; }
\ No newline at end of file |
