From 6c1f4faff2602a6d834d8f641a8a39783bbb9465 Mon Sep 17 00:00:00 2001 From: vaxerski <43317083+vaxerski@users.noreply.github.com> Date: Thu, 20 Jul 2023 19:26:10 +0200 Subject: animationmgr: avoid looping over all avars in favor of only active ones --- src/helpers/AnimatedVariable.hpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/helpers/AnimatedVariable.hpp') diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp index ccba625d..d234dce2 100644 --- a/src/helpers/AnimatedVariable.hpp +++ b/src/helpers/AnimatedVariable.hpp @@ -259,9 +259,14 @@ class CAnimatedVariable { std::function m_fBeginCallback; std::function m_fUpdateCallback; + bool m_bIsConnectedToActive = false; + void connectToActive(); + void disconnectFromActive(); + // methods void onAnimationEnd() { m_bIsBeingAnimated = false; + disconnectFromActive(); if (m_fEndCallback) { // loading m_bRemoveEndAfterRan before calling the callback allows the callback to delete this animation safely if it is false. @@ -274,6 +279,7 @@ class CAnimatedVariable { void onAnimationBegin() { m_bIsBeingAnimated = true; + connectToActive(); if (m_fBeginCallback) { m_fBeginCallback(this); -- cgit v1.2.3