summaryrefslogtreecommitdiff
path: root/src/helpers
diff options
context:
space:
mode:
authorvaxerski <vaxry@vaxry.net>2022-12-29 12:30:43 +0100
committervaxerski <vaxry@vaxry.net>2022-12-29 12:30:43 +0100
commit5d095bb9e18a3a00461c0667e3a87b887d69dcae (patch)
tree84b6dfbdcfe40ccd922f6f390103287ab357dd5d /src/helpers
parent759490689c3bcb897c900874fcf3be30d72ec74f (diff)
use curves for special dim anim
Diffstat (limited to 'src/helpers')
-rw-r--r--src/helpers/AnimatedVariable.cpp9
-rw-r--r--src/helpers/AnimatedVariable.hpp9
2 files changed, 14 insertions, 4 deletions
diff --git a/src/helpers/AnimatedVariable.cpp b/src/helpers/AnimatedVariable.cpp
index f3b1d1e4..5b98e426 100644
--- a/src/helpers/AnimatedVariable.cpp
+++ b/src/helpers/AnimatedVariable.cpp
@@ -69,4 +69,13 @@ int CAnimatedVariable::getDurationLeftMs() {
float CAnimatedVariable::getPercent() {
const auto DURATIONPASSED = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now() - animationBegin).count();
return std::clamp((DURATIONPASSED / 100.f) / m_pConfig->pValues->internalSpeed, 0.f, 1.f);
+}
+
+float CAnimatedVariable::getCurveValue() {
+ const auto SPENT = getPercent();
+
+ if (SPENT >= 1.f)
+ return 1.f;
+
+ return g_pAnimationManager->getBezier(m_pConfig->pValues->internalBezier)->getYForPoint(SPENT);
} \ No newline at end of file
diff --git a/src/helpers/AnimatedVariable.hpp b/src/helpers/AnimatedVariable.hpp
index 6aa33255..b01ca48c 100644
--- a/src/helpers/AnimatedVariable.hpp
+++ b/src/helpers/AnimatedVariable.hpp
@@ -3,16 +3,14 @@
#include "../defines.hpp"
#include <any>
-enum ANIMATEDVARTYPE
-{
+enum ANIMATEDVARTYPE {
AVARTYPE_INVALID = -1,
AVARTYPE_FLOAT,
AVARTYPE_VECTOR,
AVARTYPE_COLOR
};
-enum AVARDAMAGEPOLICY
-{
+enum AVARDAMAGEPOLICY {
AVARDAMAGE_INVALID = -1,
AVARDAMAGE_ENTIRE = 0,
AVARDAMAGE_BORDER,
@@ -190,6 +188,9 @@ class CAnimatedVariable {
/* returns the spent (completion) % */
float getPercent();
+ /* returns the current curve value */
+ float getCurveValue();
+
/* sets a function to be ran when the animation finishes.
if an animation is not running, runs instantly.
if "remove" is set to true, will remove the callback when ran. */