From 24c8267030734bc6b96b1e853cca43bc0588ad4d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 6 Jul 2017 13:22:14 -0700 Subject: [PATCH] in Rig joint accessors, if on the Rig's thread use internalPoseSet, else use external --- libraries/animation/src/Rig.cpp | 42 +++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 3ea03bc5f9..cd5d8c6231 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -404,31 +404,41 @@ void Rig::setJointRotation(int index, bool valid, const glm::quat& rotation, flo } bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const { - // if (isIndexValid(jointIndex)) { + if (QThread::currentThread() == thread()) { + if (isIndexValid(jointIndex)) { + position = (rotation * _internalPoseSet._absolutePoses[jointIndex].trans()) + translation; + return true; + } + return false; + } + QReadLocker readLock(&_externalPoseSetLock); if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) { position = (rotation * _externalPoseSet._absolutePoses[jointIndex].trans()) + translation; return true; - } else { - return false; } + return false; } bool Rig::getJointPosition(int jointIndex, glm::vec3& position) const { -/* - if (isIndexValid(jointIndex)) { - position = _internalPoseSet._absolutePoses[jointIndex].trans(); - return true; - } else { + if (QThread::currentThread() == thread()) { + if (isIndexValid(jointIndex)) { + position = _internalPoseSet._absolutePoses[jointIndex].trans(); + return true; + } return false; - }*/ + } return getAbsoluteJointTranslationInRigFrame(jointIndex, position); } bool Rig::getJointRotationInWorldFrame(int jointIndex, glm::quat& result, const glm::quat& rotation) const { - // if (isIndexValid(jointIndex)) { - // result = rotation * _internalPoseSet._absolutePoses[jointIndex].rot(); - // return true; + if (QThread::currentThread() == thread()) { + if (isIndexValid(jointIndex)) { + result = rotation * _internalPoseSet._absolutePoses[jointIndex].rot(); + return true; + } + return false; + } QReadLocker readLock(&_externalPoseSetLock); if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._absolutePoses.size()) { @@ -440,6 +450,14 @@ bool Rig::getJointRotationInWorldFrame(int jointIndex, glm::quat& result, const } bool Rig::getJointRotation(int jointIndex, glm::quat& rotation) const { + if (QThread::currentThread() == thread()) { + if (isIndexValid(jointIndex)) { + rotation = _internalPoseSet._relativePoses[jointIndex].rot(); + return true; + } + return false; + } + QReadLocker readLock(&_externalPoseSetLock); if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._relativePoses.size()) { rotation = _externalPoseSet._relativePoses[jointIndex].rot();