mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Work around animation cache misbehavior wrt threads.
This commit is contained in:
parent
26f63a44fc
commit
2c856e4b08
2 changed files with 28 additions and 0 deletions
|
@ -704,19 +704,46 @@ float loadSetting(QSettings& settings, const char* name, float defaultValue) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Resource loading is not yet thread safe. If an animation is not loaded when requested by other than tha main thread,
|
||||||
|
// we block in AnimationHandle::setURL => AnimationCache::getAnimation.
|
||||||
|
// Meanwhile, the main thread will also eventually lock as it tries to render us.
|
||||||
|
// If we demand the animation from the update thread while we're locked, we'll deadlock.
|
||||||
|
// Until we untangle this, code puts the updates back on the main thread temporarilly and starts all the loading.
|
||||||
|
void MyAvatar::safelyLoadAnimations() {
|
||||||
|
qApp->setAvatarUpdateThreading(false);
|
||||||
|
_rig->addAnimationByRole("idle");
|
||||||
|
_rig->addAnimationByRole("walk");
|
||||||
|
_rig->addAnimationByRole("backup");
|
||||||
|
_rig->addAnimationByRole("leftTurn");
|
||||||
|
_rig->addAnimationByRole("rightTurn");
|
||||||
|
_rig->addAnimationByRole("leftStrafe");
|
||||||
|
_rig->addAnimationByRole("rightStrafe");
|
||||||
|
}
|
||||||
|
|
||||||
void MyAvatar::setEnableRigAnimations(bool isEnabled) {
|
void MyAvatar::setEnableRigAnimations(bool isEnabled) {
|
||||||
|
if (isEnabled) {
|
||||||
|
safelyLoadAnimations();
|
||||||
|
}
|
||||||
_rig->setEnableRig(isEnabled);
|
_rig->setEnableRig(isEnabled);
|
||||||
if (!isEnabled) {
|
if (!isEnabled) {
|
||||||
_rig->deleteAnimations();
|
_rig->deleteAnimations();
|
||||||
|
} else if (Menu::getInstance()->isOptionChecked(MenuOption::EnableAvatarUpdateThreading)) {
|
||||||
|
qApp->setAvatarUpdateThreading(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyAvatar::setEnableAnimGraph(bool isEnabled) {
|
void MyAvatar::setEnableAnimGraph(bool isEnabled) {
|
||||||
|
if (isEnabled) {
|
||||||
|
safelyLoadAnimations();
|
||||||
|
}
|
||||||
_rig->setEnableAnimGraph(isEnabled);
|
_rig->setEnableAnimGraph(isEnabled);
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
if (_skeletonModel.readyToAddToScene()) {
|
if (_skeletonModel.readyToAddToScene()) {
|
||||||
initAnimGraph();
|
initAnimGraph();
|
||||||
}
|
}
|
||||||
|
if (Menu::getInstance()->isOptionChecked(MenuOption::EnableAvatarUpdateThreading)) {
|
||||||
|
qApp->setAvatarUpdateThreading(true);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
destroyAnimGraph();
|
destroyAnimGraph();
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,6 +292,7 @@ private:
|
||||||
void initHeadBones();
|
void initHeadBones();
|
||||||
void initAnimGraph();
|
void initAnimGraph();
|
||||||
void destroyAnimGraph();
|
void destroyAnimGraph();
|
||||||
|
void safelyLoadAnimations();
|
||||||
|
|
||||||
// Avatar Preferences
|
// Avatar Preferences
|
||||||
QUrl _fullAvatarURLFromPreferences;
|
QUrl _fullAvatarURLFromPreferences;
|
||||||
|
|
Loading…
Reference in a new issue