mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Added a priority setting so that we can control the order in which animations
are applied.
This commit is contained in:
parent
f709ea61b5
commit
1022f1bec4
5 changed files with 39 additions and 3 deletions
|
@ -480,6 +480,7 @@ void MyAvatar::saveData(QSettings* settings) {
|
|||
const AnimationHandlePointer& pointer = _animationHandles.at(i);
|
||||
settings->setValue("url", pointer->getURL());
|
||||
settings->setValue("fps", pointer->getFPS());
|
||||
settings->setValue("priority", pointer->getPriority());
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
@ -545,6 +546,7 @@ void MyAvatar::loadData(QSettings* settings) {
|
|||
const AnimationHandlePointer& handle = _animationHandles.at(i);
|
||||
handle->setURL(settings->value("url").toUrl());
|
||||
handle->setFPS(loadSetting(settings, "fps", 30.0f));
|
||||
handle->setPriority(loadSetting(settings, "priority", 1.0f));
|
||||
}
|
||||
settings->endArray();
|
||||
|
||||
|
|
|
@ -1651,13 +1651,33 @@ void Model::renderMeshes(float alpha, RenderMode mode, bool translucent) {
|
|||
}
|
||||
|
||||
void AnimationHandle::setURL(const QUrl& url) {
|
||||
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url);
|
||||
_jointMappings.clear();
|
||||
if (_url != url) {
|
||||
_animation = Application::getInstance()->getAnimationCache()->getAnimation(_url = url);
|
||||
_jointMappings.clear();
|
||||
}
|
||||
}
|
||||
|
||||
static void insertSorted(QList<AnimationHandlePointer>& handles, const AnimationHandlePointer& handle) {
|
||||
for (QList<AnimationHandlePointer>::iterator it = handles.begin(); it != handles.end(); it++) {
|
||||
if (handle->getPriority() < (*it)->getPriority()) {
|
||||
handles.insert(it, handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
handles.append(handle);
|
||||
}
|
||||
|
||||
void AnimationHandle::setPriority(float priority) {
|
||||
if (_priority != priority) {
|
||||
_priority = priority;
|
||||
_model->_runningAnimations.removeOne(_self);
|
||||
insertSorted(_model->_runningAnimations, _self);
|
||||
}
|
||||
}
|
||||
|
||||
void AnimationHandle::start() {
|
||||
if (!_model->_runningAnimations.contains(_self)) {
|
||||
_model->_runningAnimations.append(_self);
|
||||
insertSorted(_model->_runningAnimations, _self);
|
||||
}
|
||||
_frameIndex = 0.0f;
|
||||
}
|
||||
|
@ -1670,6 +1690,7 @@ AnimationHandle::AnimationHandle(Model* model) :
|
|||
QObject(model),
|
||||
_model(model),
|
||||
_fps(30.0f),
|
||||
_priority(1.0f),
|
||||
_loop(false) {
|
||||
}
|
||||
|
||||
|
|
|
@ -384,6 +384,9 @@ public:
|
|||
|
||||
void setFPS(float fps) { _fps = fps; }
|
||||
float getFPS() const { return _fps; }
|
||||
|
||||
void setPriority(float priority);
|
||||
float getPriority() const { return _priority; }
|
||||
|
||||
void setLoop(bool loop) { _loop = loop; }
|
||||
bool getLoop() const { return _loop; }
|
||||
|
@ -404,6 +407,7 @@ private:
|
|||
AnimationPointer _animation;
|
||||
QUrl _url;
|
||||
float _fps;
|
||||
float _priority;
|
||||
bool _loop;
|
||||
QVector<int> _jointMappings;
|
||||
float _frameIndex;
|
||||
|
|
|
@ -93,6 +93,13 @@ AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePo
|
|||
_fps->setValue(handle->getFPS());
|
||||
connect(_fps, SIGNAL(valueChanged(double)), SLOT(updateHandle()));
|
||||
|
||||
layout->addRow("Priority:", _priority = new QDoubleSpinBox());
|
||||
_priority->setSingleStep(0.01);
|
||||
_priority->setMinimum(-FLT_MAX);
|
||||
_priority->setMaximum(FLT_MAX);
|
||||
_priority->setValue(handle->getPriority());
|
||||
connect(_priority, SIGNAL(valueChanged(double)), SLOT(updateHandle()));
|
||||
|
||||
QPushButton* remove = new QPushButton("Delete");
|
||||
layout->addRow(remove);
|
||||
connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle()));
|
||||
|
@ -114,6 +121,7 @@ void AnimationPanel::chooseURL() {
|
|||
void AnimationPanel::updateHandle() {
|
||||
_handle->setURL(_url->text());
|
||||
_handle->setFPS(_fps->value());
|
||||
_handle->setPriority(_priority->value());
|
||||
}
|
||||
|
||||
void AnimationPanel::removeHandle() {
|
||||
|
|
|
@ -62,6 +62,7 @@ private:
|
|||
AnimationHandlePointer _handle;
|
||||
QLineEdit* _url;
|
||||
QDoubleSpinBox* _fps;
|
||||
QDoubleSpinBox* _priority;
|
||||
bool _applying;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue