Merge pull request #15316 from amantley/bugSetRotation

Bug fixed for MyAvatar.getJointRotation(name, quat) and MyAvatar.setJointRotation(name, quat)
This commit is contained in:
Shannon Romano 2019-04-12 12:23:03 -07:00 committed by GitHub
commit 5e8e44f97b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 9 deletions

View file

@ -1721,7 +1721,6 @@ glm::vec3 AvatarData::getJointTranslation(const QString& name) const {
// on another thread in between the call to getJointIndex and getJointTranslation // on another thread in between the call to getJointIndex and getJointTranslation
// return getJointTranslation(getJointIndex(name)); // return getJointTranslation(getJointIndex(name));
return readLockWithNamedJointIndex<glm::vec3>(name, [this](int index) { return readLockWithNamedJointIndex<glm::vec3>(name, [this](int index) {
return _jointData.at(index).translation;
return getJointTranslation(index); return getJointTranslation(index);
}); });
} }
@ -1809,8 +1808,8 @@ glm::quat AvatarData::getJointRotation(const QString& name) const {
// Can't do this, not thread safe // Can't do this, not thread safe
// return getJointRotation(getJointIndex(name)); // return getJointRotation(getJointIndex(name));
return readLockWithNamedJointIndex<glm::quat>(name, [&](int index) { return readLockWithNamedJointIndex<glm::quat>(name, [this](int index) {
return _jointData.at(index).rotation; return getJointRotation(index);
}); });
} }

View file

@ -1751,14 +1751,11 @@ protected:
template <typename T, typename F> template <typename T, typename F>
T readLockWithNamedJointIndex(const QString& name, const T& defaultValue, F f) const { T readLockWithNamedJointIndex(const QString& name, const T& defaultValue, F f) const {
int index = getFauxJointIndex(name);
QReadLocker readLock(&_jointDataLock); QReadLocker readLock(&_jointDataLock);
int index = getJointIndex(name);
// The first conditional is superfluous, but illustrative if (index == -1) {
if (index == -1 || index < _jointData.size()) {
return defaultValue; return defaultValue;
} }
return f(index); return f(index);
} }
@ -1769,8 +1766,8 @@ protected:
template <typename F> template <typename F>
void writeLockWithNamedJointIndex(const QString& name, F f) { void writeLockWithNamedJointIndex(const QString& name, F f) {
int index = getFauxJointIndex(name);
QWriteLocker writeLock(&_jointDataLock); QWriteLocker writeLock(&_jointDataLock);
int index = getJointIndex(name);
if (index == -1) { if (index == -1) {
return; return;
} }