diff --git a/libraries/animation/src/AnimationLoop.cpp b/libraries/animation/src/AnimationLoop.cpp index 7f559dd257..6062d71f9c 100644 --- a/libraries/animation/src/AnimationLoop.cpp +++ b/libraries/animation/src/AnimationLoop.cpp @@ -15,15 +15,17 @@ const float AnimationLoop::MAXIMUM_POSSIBLE_FRAME = 100000.0f; AnimationLoop::AnimationLoop() : -_fps(30.0f), -_loop(false), -_hold(false), -_startAutomatically(false), -_firstFrame(0.0f), -_lastFrame(MAXIMUM_POSSIBLE_FRAME), -_running(false), -_frameIndex(0.0f), -_maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME) + _fps(30.0f), + _loop(false), + _hold(false), + _startAutomatically(false), + _firstFrame(0.0f), + _lastFrame(MAXIMUM_POSSIBLE_FRAME), + _running(false), + _frameIndex(0.0f), + _maxFrameIndexHint(MAXIMUM_POSSIBLE_FRAME), + _resetOnRunning(false), + _firstRun(true) { } @@ -35,7 +37,9 @@ AnimationLoop::AnimationLoop(const AnimationDetails& animationDetails) : _firstFrame(animationDetails.firstFrame), _lastFrame(animationDetails.lastFrame), _running(animationDetails.running), - _frameIndex(animationDetails.frameIndex) + _frameIndex(animationDetails.frameIndex), + _resetOnRunning(false), + _firstRun(true) { } @@ -48,7 +52,9 @@ AnimationLoop::AnimationLoop(float fps, bool loop, bool hold, bool startAutomati _firstFrame(firstFrame), _lastFrame(lastFrame), _running(running), - _frameIndex(frameIndex) + _frameIndex(frameIndex), + _resetOnRunning(false), + _firstRun(true) { } @@ -88,9 +94,10 @@ void AnimationLoop::setRunning(bool running) { _running = running; // If we just set running to true, then also reset the frame to the first frame - if (running && _resetOnRunning) { + if (running && (_resetOnRunning || _firstRun)) { // move back to the beginning _frameIndex = _firstFrame; + _firstRun = false; } } } diff --git a/libraries/animation/src/AnimationLoop.h b/libraries/animation/src/AnimationLoop.h index c906ba530f..ae5a88fdbd 100644 --- a/libraries/animation/src/AnimationLoop.h +++ b/libraries/animation/src/AnimationLoop.h @@ -74,6 +74,7 @@ private: float _frameIndex = 0.0f; float _maxFrameIndexHint = MAXIMUM_POSSIBLE_FRAME; bool _resetOnRunning = false; + bool _firstRun = true; }; #endif // hifi_AnimationLoop_h