animationmgr: avoid redundant ticks

This commit is contained in:
vaxerski 2023-08-05 23:29:33 +02:00
parent b925f1b497
commit a077b7a92e
5 changed files with 52 additions and 9 deletions

View file

@ -82,8 +82,11 @@ float CAnimatedVariable::getCurveValue() {
}
void CAnimatedVariable::connectToActive() {
g_pAnimationManager->scheduleTick(); // otherwise the animation manager will never pick this up
if (!m_bIsConnectedToActive)
g_pAnimationManager->m_vActiveAnimatedVariables.push_back(this);
m_bIsConnectedToActive = true;
}

View file

@ -14,4 +14,8 @@ int CTimer::getMillis() {
float CTimer::getSeconds() {
return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count() / 1000.f;
}
const std::chrono::system_clock::time_point& CTimer::chrono() const {
return m_tpLastReset;
}

View file

@ -4,9 +4,10 @@
class CTimer {
public:
void reset();
float getSeconds();
int getMillis();
void reset();
float getSeconds();
int getMillis();
const std::chrono::system_clock::time_point& chrono() const;
private:
std::chrono::system_clock::time_point m_tpLastReset;