From 7fa24efca0b050ca0579b1ccd6fd9780961409f6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 7 Sep 2019 18:08:28 -0700 Subject: [PATCH] add a way to query Rig to see if a joint has been overridden by a script --- libraries/animation/src/Rig.cpp | 16 +++++++++++++++- libraries/animation/src/Rig.h | 4 +++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/libraries/animation/src/Rig.cpp b/libraries/animation/src/Rig.cpp index 5fe2cb33ff..19e3878d84 100644 --- a/libraries/animation/src/Rig.cpp +++ b/libraries/animation/src/Rig.cpp @@ -715,7 +715,7 @@ void Rig::reset(const HFMModel& hfmModel) { } } -bool Rig::jointStatesEmpty() { +bool Rig::jointStatesEmpty() const { return _internalPoseSet._relativePoses.empty(); } @@ -878,6 +878,20 @@ void Rig::setJointRotation(int index, bool valid, const glm::quat& rotation, flo } } +bool Rig::getIsJointOverridden(int jointIndex) const { + if (QThread::currentThread() == thread()) { + if (isIndexValid(jointIndex)) { + return _internalPoseSet._overrideFlags[jointIndex]; + } + } else { + QReadLocker readLock(&_externalPoseSetLock); + if (jointIndex >= 0 && jointIndex < (int)_externalPoseSet._overrideFlags.size()) { + return _externalPoseSet._overrideFlags[jointIndex]; + } + } + return false; +} + bool Rig::getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const { bool success { false }; glm::vec3 originalPosition = position; diff --git a/libraries/animation/src/Rig.h b/libraries/animation/src/Rig.h index 99794fd0a7..a70659b0ae 100644 --- a/libraries/animation/src/Rig.h +++ b/libraries/animation/src/Rig.h @@ -135,7 +135,7 @@ public: void initJointStates(const HFMModel& hfmModel, const glm::mat4& modelOffset); void reset(const HFMModel& hfmModel); - bool jointStatesEmpty(); + bool jointStatesEmpty() const; int getJointStateCount() const; int indexOfJoint(const QString& jointName) const; QString nameOfJoint(int jointIndex) const; @@ -163,6 +163,8 @@ public: void setJointTranslation(int index, bool valid, const glm::vec3& translation, float priority); void setJointRotation(int index, bool valid, const glm::quat& rotation, float priority); + bool getIsJointOverridden(int jointIndex) const; + // if translation and rotation is identity, position will be in rig space bool getJointPositionInWorldFrame(int jointIndex, glm::vec3& position, glm::vec3 translation, glm::quat rotation) const;