mirror of
https://github.com/overte-org/overte.git
synced 2025-07-05 00:49:49 +02:00
We should let people "start" even if the animation is already playing (to
start again from the beginning). Fixed an issue with competing priorities.
This commit is contained in:
parent
5b65406012
commit
a32dfdb7bb
4 changed files with 28 additions and 23 deletions
|
@ -1690,12 +1690,19 @@ static void insertSorted(QList<AnimationHandlePointer>& 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -430,7 +430,8 @@ private:
|
|||
AnimationHandle(Model* model);
|
||||
|
||||
void simulate(float deltaTime);
|
||||
|
||||
void lowerPriority(float newPriority);
|
||||
|
||||
Model* _model;
|
||||
WeakAnimationHandlePointer _self;
|
||||
AnimationPointer _animation;
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -57,7 +57,6 @@ private slots:
|
|||
|
||||
void chooseURL();
|
||||
void chooseMaskedJoints();
|
||||
void updateStartStop();
|
||||
void updateHandle();
|
||||
void removeHandle();
|
||||
|
||||
|
|
Loading…
Reference in a new issue