From f84f6e9b667a942237fa16f13ea6c1ba4c8ad961 Mon Sep 17 00:00:00 2001 From: Atlante45 Date: Mon, 26 Jan 2015 19:12:18 -0800 Subject: [PATCH] Restore joints state on stopAnimation --- libraries/render-utils/src/AnimationHandle.cpp | 11 +++++++++++ libraries/render-utils/src/AnimationHandle.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libraries/render-utils/src/AnimationHandle.cpp b/libraries/render-utils/src/AnimationHandle.cpp index 30edf97a33..64e2bf28b9 100644 --- a/libraries/render-utils/src/AnimationHandle.cpp +++ b/libraries/render-utils/src/AnimationHandle.cpp @@ -74,6 +74,7 @@ void AnimationHandle::setRunning(bool running) { } } else { _model->_runningAnimations.removeOne(_self); + restoreJoints(); replaceMatchingPriorities(0.0f); } emit runningChanged(isRunning()); @@ -173,3 +174,13 @@ void AnimationHandle::replaceMatchingPriorities(float newPriority) { } } +void AnimationHandle::restoreJoints() { + for (int i = 0; i < _jointMappings.size(); i++) { + int mapping = _jointMappings.at(i); + if (mapping != -1) { + JointState& state = _model->_jointStates[mapping]; + state.restoreRotation(1.0f, state._animationPriority); + } + } +} + diff --git a/libraries/render-utils/src/AnimationHandle.h b/libraries/render-utils/src/AnimationHandle.h index 3956b01ebf..13a1b97dc1 100644 --- a/libraries/render-utils/src/AnimationHandle.h +++ b/libraries/render-utils/src/AnimationHandle.h @@ -92,6 +92,7 @@ private: void simulate(float deltaTime); void applyFrame(float frameIndex); void replaceMatchingPriorities(float newPriority); + void restoreJoints(); Model* _model; WeakAnimationHandlePointer _self;