diff --git a/interface/src/renderer/Model.cpp b/interface/src/renderer/Model.cpp index 3005921d39..5d94a9a7d0 100644 --- a/interface/src/renderer/Model.cpp +++ b/interface/src/renderer/Model.cpp @@ -1690,12 +1690,19 @@ static void insertSorted(QList& handles, const Animation } void AnimationHandle::setPriority(float priority) { - if (_priority != priority) { - _priority = priority; - if (_running) { - _model->_runningAnimations.removeOne(_self); - insertSorted(_model->_runningAnimations, _self); + if (_priority == priority) { + return; + } + if (_running) { + _model->_runningAnimations.removeOne(_self); + if (priority < _priority) { + lowerPriority(priority); } + _priority = priority; + insertSorted(_model->_runningAnimations, _self); + + } else { + _priority = priority; } } @@ -1726,15 +1733,7 @@ void AnimationHandle::setRunning(bool running) { } else { _model->_runningAnimations.removeOne(_self); - for (int i = 0; i < _jointMappings.size(); i++) { - int mapping = _jointMappings.at(i); - if (mapping != -1) { - Model::JointState& state = _model->_jointStates[mapping]; - if (_priority == state.animationPriority) { - state.animationPriority = 0.0f; - } - } - } + lowerPriority(0.0f); } emit runningChanged(_running); } @@ -1820,3 +1819,14 @@ void AnimationHandle::simulate(float deltaTime) { } } +void AnimationHandle::lowerPriority(float newPriority) { + for (int i = 0; i < _jointMappings.size(); i++) { + int mapping = _jointMappings.at(i); + if (mapping != -1) { + Model::JointState& state = _model->_jointStates[mapping]; + if (_priority == state.animationPriority) { + state.animationPriority = newPriority; + } + } + } +} diff --git a/interface/src/renderer/Model.h b/interface/src/renderer/Model.h index a0806ee238..c2aeec7183 100644 --- a/interface/src/renderer/Model.h +++ b/interface/src/renderer/Model.h @@ -430,7 +430,8 @@ private: AnimationHandle(Model* model); void simulate(float deltaTime); - + void lowerPriority(float newPriority); + Model* _model; WeakAnimationHandlePointer _self; AnimationPointer _animation; diff --git a/interface/src/ui/AnimationsDialog.cpp b/interface/src/ui/AnimationsDialog.cpp index 9f62abc270..2456b589da 100644 --- a/interface/src/ui/AnimationsDialog.cpp +++ b/interface/src/ui/AnimationsDialog.cpp @@ -148,8 +148,8 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo buttons->addWidget(remove); connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle())); - connect(_handle.data(), SIGNAL(runningChanged(bool)), SLOT(updateStartStop())); - updateStartStop(); + _stop->connect(_handle.data(), SIGNAL(runningChanged(bool)), SLOT(setEnabled(bool))); + _stop->setEnabled(_handle->isRunning()); } void AnimationPanel::chooseURL() { @@ -185,11 +185,6 @@ void AnimationPanel::chooseMaskedJoints() { } } -void AnimationPanel::updateStartStop() { - _start->setEnabled(!_handle->isRunning()); - _stop->setEnabled(_handle->isRunning()); -} - void AnimationPanel::updateHandle() { _handle->setRole(_role->currentText()); _handle->setURL(_url->text()); diff --git a/interface/src/ui/AnimationsDialog.h b/interface/src/ui/AnimationsDialog.h index 6f7a2f3784..dd3865741e 100644 --- a/interface/src/ui/AnimationsDialog.h +++ b/interface/src/ui/AnimationsDialog.h @@ -57,7 +57,6 @@ private slots: void chooseURL(); void chooseMaskedJoints(); - void updateStartStop(); void updateHandle(); void removeHandle();