From 6360fe4153a41cd85e6c3f4ca76fb60b69793074 Mon Sep 17 00:00:00 2001 From: Roland Hill Date: Mon, 19 Aug 2024 11:51:14 +1000 Subject: [PATCH] Ensure animation ends on final key frame --- src/vsg/animation/Animation.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/vsg/animation/Animation.cpp b/src/vsg/animation/Animation.cpp index 05f1e784e..238866e36 100644 --- a/src/vsg/animation/Animation.cpp +++ b/src/vsg/animation/Animation.cpp @@ -132,6 +132,8 @@ bool Animation::update(double simulationTime) { if (!_active) return false; + bool finished = false; + auto time_within_period = [](double x, double y) -> double { return x < 0.0 ? y + std::fmod(x, y) : std::fmod(x, y); }; @@ -153,8 +155,8 @@ bool Animation::update(double simulationTime) { if (time > _maxTime) { - stop(simulationTime); - return false; + finished = true; + samplerTime = time = _maxTime; } } @@ -163,6 +165,12 @@ bool Animation::update(double simulationTime) sampler->update(samplerTime); } + if(finished) + { + stop(simulationTime); + return false; + } + return true; }