Merge pull request #4643 from ctrlaltdavid/fix-auto-start-animation

Fix auto start animation
This commit is contained in:
Brad Hefta-Gaub 2015-04-15 10:14:26 -07:00
commit 72f9ae3e85
2 changed files with 7 additions and 13 deletions

View file

@ -646,7 +646,6 @@ void MyAvatar::saveData() {
settings.setValue("firstFrame", pointer->getFirstFrame());
settings.setValue("lastFrame", pointer->getLastFrame());
settings.setValue("maskedJoints", pointer->getMaskedJoints());
settings.setValue("running", pointer->getLoop() && pointer->isRunning());
}
settings.endArray();
@ -761,13 +760,10 @@ void MyAvatar::loadData() {
handle->setPriority(loadSetting(settings, "priority", 1.0f));
handle->setLoop(settings.value("loop", true).toBool());
handle->setHold(settings.value("hold", false).toBool());
handle->setStartAutomatically(settings.value("startAutomatically", true).toBool());
handle->setFirstFrame(settings.value("firstFrame", 0.0f).toFloat());
handle->setLastFrame(settings.value("lastFrame", INT_MAX).toFloat());
handle->setMaskedJoints(settings.value("maskedJoints").toStringList());
if (settings.value("loop", true).toBool() && settings.value("running", false).toBool()) {
handle->setRunning(true);
}
handle->setStartAutomatically(settings.value("startAutomatically", true).toBool());
}
settings.endArray();

View file

@ -47,10 +47,11 @@ void AnimationHandle::setPriority(float priority) {
}
void AnimationHandle::setStartAutomatically(bool startAutomatically) {
_animationLoop.setStartAutomatically(startAutomatically);
if (getStartAutomatically() && !isRunning()) {
if (startAutomatically && !isRunning()) {
// Start before setting _animationLoop value so that code in setRunning() is executed
start();
}
_animationLoop.setStartAutomatically(startAutomatically);
}
void AnimationHandle::setMaskedJoints(const QStringList& maskedJoints) {
@ -59,13 +60,10 @@ void AnimationHandle::setMaskedJoints(const QStringList& maskedJoints) {
}
void AnimationHandle::setRunning(bool running) {
if (isRunning() == running) {
if (running && isRunning()) {
// if we're already running, this is the same as a restart
if (running) {
// move back to the beginning
setFrameIndex(getFirstFrame());
return;
}
setFrameIndex(getFirstFrame());
return;
}
_animationLoop.setRunning(running);
if (isRunning()) {