From c546c0bd642ebb7d093b13fb97e164d95688a1f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Thu, 13 Sep 2018 14:33:13 +0200 Subject: [PATCH] Animation: fix pause() behavior. The pause should advance at `stopPauseTime - startTime`, but the *original* startTime. Since I changed startTime to be `stopPauseTime - startTime`, the pause advanced to `stopPauseTime + startTime`, which is wrong. Now the timeToUse variable is containing the real final time to unconfuse everything. --- src/Magnum/Animation/Player.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Magnum/Animation/Player.hpp b/src/Magnum/Animation/Player.hpp index f14c9a595..a919fca11 100644 --- a/src/Magnum/Animation/Player.hpp +++ b/src/Magnum/Animation/Player.hpp @@ -149,7 +149,7 @@ namespace Implementation { template Containers::Optional> playerElapsed(const K duration, const UnsignedInt playCount, const typename Player::Scaler scaler, const T time, T& startTime, T& stopPauseTime, State& state) { /* Time to use for advancing the animation */ - T timeToUse = time; + T timeToUse = time - startTime; /* The animation was paused right before this iteration, "park" the animation to the pause time. This time will be used by play() to offset @@ -158,8 +158,8 @@ template Containers::Optional> playe std::chrono::duration doesn't have operator bool, so I need to compare to default-constructed value. Ugh. */ if(state == State::Paused && (stopPauseTime != T{})) { - timeToUse = stopPauseTime; startTime = stopPauseTime - startTime; + timeToUse = startTime; stopPauseTime = {}; /* The animation was stopped by the user right before this iteration, @@ -191,7 +191,7 @@ template Containers::Optional> playe iteration. If we exceeded play count, stop the animation and give out value at duration end. */ } else { - std::tie(playIteration, key) = scaler(timeToUse - startTime, duration); + std::tie(playIteration, key) = scaler(timeToUse, duration); if(playCount && playIteration >= playCount) { state = State::Stopped; /* Don't reset the startTime to disambiguate between explicitly