add support for avatar set/get parent Joint Index, as well

This commit is contained in:
Seth Alves 2016-01-18 13:09:09 -08:00
parent 5ee1acc1ea
commit 41c46423ba
2 changed files with 28 additions and 2 deletions

View file

@ -1209,3 +1209,27 @@ void Avatar::updatePalms() {
_leftPalmPositionCache.set(leftPalmPosition); _leftPalmPositionCache.set(leftPalmPosition);
_rightPalmPositionCache.set(rightPalmPosition); _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.";
}
}
}

View file

@ -167,9 +167,11 @@ public:
using SpatiallyNestable::setOrientation; using SpatiallyNestable::setOrientation;
virtual void setOrientation(const glm::quat& orientation) override; 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 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: public slots: