diff --git a/interface/src/avatar/Avatar.cpp b/interface/src/avatar/Avatar.cpp index 7cde674e52..7f0201d714 100644 --- a/interface/src/avatar/Avatar.cpp +++ b/interface/src/avatar/Avatar.cpp @@ -1209,3 +1209,27 @@ void Avatar::updatePalms() { _leftPalmPositionCache.set(leftPalmPosition); _rightPalmPositionCache.set(rightPalmPosition); } + +void Avatar::setParentID(const QUuid& parentID) { + bool success; + Transform beforeChangeTransform = getTransform(success); + SpatiallyNestable::setParentID(parentID); + if (success) { + setTransform(beforeChangeTransform, success); + if (!success) { + qDebug() << "Avatar::setParentID failed to reset avatar's location."; + } + } +} + +void Avatar::setParentJointIndex(quint16 parentJointIndex) { + bool success; + Transform beforeChangeTransform = getTransform(success); + SpatiallyNestable::setParentJointIndex(parentJointIndex); + if (success) { + setTransform(beforeChangeTransform, success); + if (!success) { + qDebug() << "Avatar::setParentJointIndex failed to reset avatar's location."; + } + } +} diff --git a/interface/src/avatar/Avatar.h b/interface/src/avatar/Avatar.h index d8cb73d25c..b3f27c474b 100644 --- a/interface/src/avatar/Avatar.h +++ b/interface/src/avatar/Avatar.h @@ -167,9 +167,11 @@ public: using SpatiallyNestable::setOrientation; virtual void setOrientation(const glm::quat& orientation) override; - // these just call through to the SpatiallyNestable versions, but they are here to expose these to javascript. + // these call through to the SpatiallyNestable versions, but they are here to expose these to javascript. Q_INVOKABLE virtual QUuid getParentID() const { return SpatiallyNestable::getParentID(); } - Q_INVOKABLE virtual void setParentID(const QUuid& parentID) { SpatiallyNestable::setParentID(parentID); } + Q_INVOKABLE virtual void setParentID(const QUuid& parentID); + Q_INVOKABLE virtual quint16 getParentJointIndex() const { return SpatiallyNestable::getParentJointIndex(); } + Q_INVOKABLE virtual void setParentJointIndex(quint16 parentJointIndex); public slots: