mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-10 17:23:15 +02:00
enabled MyAvatar.get and .set rotation
This commit is contained in:
parent
04eac57950
commit
857a4ab739
2 changed files with 13 additions and 11 deletions
|
@ -1721,7 +1721,6 @@ glm::vec3 AvatarData::getJointTranslation(const QString& name) const {
|
|||
// on another thread in between the call to getJointIndex and getJointTranslation
|
||||
// return getJointTranslation(getJointIndex(name));
|
||||
return readLockWithNamedJointIndex<glm::vec3>(name, [this](int index) {
|
||||
return _jointData.at(index).translation;
|
||||
return getJointTranslation(index);
|
||||
});
|
||||
}
|
||||
|
@ -1809,8 +1808,8 @@ glm::quat AvatarData::getJointRotation(const QString& name) const {
|
|||
// Can't do this, not thread safe
|
||||
// return getJointRotation(getJointIndex(name));
|
||||
|
||||
return readLockWithNamedJointIndex<glm::quat>(name, [&](int index) {
|
||||
return _jointData.at(index).rotation;
|
||||
return readLockWithNamedJointIndex<glm::quat>(name, [this](int index) {
|
||||
return getJointRotation(index);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1750,14 +1750,14 @@ protected:
|
|||
|
||||
template <typename T, typename F>
|
||||
T readLockWithNamedJointIndex(const QString& name, const T& defaultValue, F f) const {
|
||||
int index = getFauxJointIndex(name);
|
||||
QReadLocker readLock(&_jointDataLock);
|
||||
|
||||
// The first conditional is superfluous, but illustrative
|
||||
if (index == -1 || index < _jointData.size()) {
|
||||
int index = getJointIndex(name);
|
||||
if (index == -1) {
|
||||
index = getFauxJointIndex(name);
|
||||
}
|
||||
if (index == -1) {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
QReadLocker readLock(&_jointDataLock);
|
||||
return f(index);
|
||||
}
|
||||
|
||||
|
@ -1768,11 +1768,14 @@ protected:
|
|||
|
||||
template <typename F>
|
||||
void writeLockWithNamedJointIndex(const QString& name, F f) {
|
||||
int index = getFauxJointIndex(name);
|
||||
QWriteLocker writeLock(&_jointDataLock);
|
||||
int index = getJointIndex(name);
|
||||
if (index == -1) {
|
||||
index = getFauxJointIndex(name);
|
||||
}
|
||||
if (index == -1) {
|
||||
return;
|
||||
}
|
||||
QWriteLocker writeLock(&_jointDataLock);
|
||||
if (_jointData.size() <= index) {
|
||||
_jointData.resize(index + 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue