diff --git a/src/SceneGraph/Animable.hpp b/src/SceneGraph/Animable.hpp index c1a3f11f5..619e556c2 100644 --- a/src/SceneGraph/Animable.hpp +++ b/src/SceneGraph/Animable.hpp @@ -80,10 +80,12 @@ template void AnimableGroup::st CORRADE_INTERNAL_ASSERT(animable->previousState == animable->currentState); continue; - /* The animation was started recently, set start time to previous frame time */ + /* The animation was started recently, set start time to previous frame + time, reset repeat count */ } else if(animable->previousState == AnimationState::Stopped) { animable->previousState = AnimationState::Running; animable->startTime = time; + animable->repeats = 0; ++_runningCount; animable->animationStarted(); diff --git a/src/SceneGraph/Test/AnimableTest.cpp b/src/SceneGraph/Test/AnimableTest.cpp index 1c4840fb1..1be3a1fd4 100644 --- a/src/SceneGraph/Test/AnimableTest.cpp +++ b/src/SceneGraph/Test/AnimableTest.cpp @@ -266,6 +266,21 @@ void AnimableTest::repeat() { group.step(33.0f, 0.5f); CORRADE_COMPARE(animable.state(), AnimationState::Stopped); CORRADE_COMPARE(animable.time, 4.5f); + + /* Starting the animation again, should be repeatable again */ + animable.setState(AnimationState::Running); + + /* Three animation repeats */ + group.step(1.0f, 0.5f); + CORRADE_COMPARE(animable.state(), AnimationState::Running); + group.step(11.5f, 0.5f); + CORRADE_COMPARE(animable.state(), AnimationState::Running); + group.step(25.5f, 0.5f); + CORRADE_COMPARE(animable.state(), AnimationState::Running); + + /* Should be stopped now */ + group.step(33.0f, 0.5f); + CORRADE_COMPARE(animable.state(), AnimationState::Stopped); } void AnimableTest::stop() {