mirror of
https://github.com/overte-org/overte.git
synced 2025-07-05 07:49:42 +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) {
|
void AnimationHandle::setPriority(float priority) {
|
||||||
if (_priority != priority) {
|
if (_priority == priority) {
|
||||||
_priority = priority;
|
return;
|
||||||
|
}
|
||||||
if (_running) {
|
if (_running) {
|
||||||
_model->_runningAnimations.removeOne(_self);
|
_model->_runningAnimations.removeOne(_self);
|
||||||
insertSorted(_model->_runningAnimations, _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 {
|
} else {
|
||||||
_model->_runningAnimations.removeOne(_self);
|
_model->_runningAnimations.removeOne(_self);
|
||||||
for (int i = 0; i < _jointMappings.size(); i++) {
|
lowerPriority(0.0f);
|
||||||
int mapping = _jointMappings.at(i);
|
|
||||||
if (mapping != -1) {
|
|
||||||
Model::JointState& state = _model->_jointStates[mapping];
|
|
||||||
if (_priority == state.animationPriority) {
|
|
||||||
state.animationPriority = 0.0f;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
emit runningChanged(_running);
|
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,6 +430,7 @@ private:
|
||||||
AnimationHandle(Model* model);
|
AnimationHandle(Model* model);
|
||||||
|
|
||||||
void simulate(float deltaTime);
|
void simulate(float deltaTime);
|
||||||
|
void lowerPriority(float newPriority);
|
||||||
|
|
||||||
Model* _model;
|
Model* _model;
|
||||||
WeakAnimationHandlePointer _self;
|
WeakAnimationHandlePointer _self;
|
||||||
|
|
|
@ -148,8 +148,8 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
|
||||||
buttons->addWidget(remove);
|
buttons->addWidget(remove);
|
||||||
connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle()));
|
connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle()));
|
||||||
|
|
||||||
connect(_handle.data(), SIGNAL(runningChanged(bool)), SLOT(updateStartStop()));
|
_stop->connect(_handle.data(), SIGNAL(runningChanged(bool)), SLOT(setEnabled(bool)));
|
||||||
updateStartStop();
|
_stop->setEnabled(_handle->isRunning());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationPanel::chooseURL() {
|
void AnimationPanel::chooseURL() {
|
||||||
|
@ -185,11 +185,6 @@ void AnimationPanel::chooseMaskedJoints() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnimationPanel::updateStartStop() {
|
|
||||||
_start->setEnabled(!_handle->isRunning());
|
|
||||||
_stop->setEnabled(_handle->isRunning());
|
|
||||||
}
|
|
||||||
|
|
||||||
void AnimationPanel::updateHandle() {
|
void AnimationPanel::updateHandle() {
|
||||||
_handle->setRole(_role->currentText());
|
_handle->setRole(_role->currentText());
|
||||||
_handle->setURL(_url->text());
|
_handle->setURL(_url->text());
|
||||||
|
|
|
@ -57,7 +57,6 @@ private slots:
|
||||||
|
|
||||||
void chooseURL();
|
void chooseURL();
|
||||||
void chooseMaskedJoints();
|
void chooseMaskedJoints();
|
||||||
void updateStartStop();
|
|
||||||
void updateHandle();
|
void updateHandle();
|
||||||
void removeHandle();
|
void removeHandle();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue