diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 417e6008e8..6731bcc9fb 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -888,9 +888,6 @@ void EntityItem::simulateKinematicMotion(float timeElapsed, bool setFlags) { if (hasActions()) { return; } - if (!_parentID.isNull()) { - return; - } if (hasLocalAngularVelocity()) { glm::vec3 localAngularVelocity = getLocalAngularVelocity(); diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index 6b3e3806a7..11d0668001 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -422,8 +422,18 @@ void SpatiallyNestable::setVelocity(const glm::vec3& velocity, bool& success) { glm::vec3 parentVelocity = getParentVelocity(success); Transform parentTransform = getParentTransform(success); _velocityLock.withWriteLock([&] { - // TODO: take parent angularVelocity into account. - _velocity = glm::inverse(parentTransform.getRotation()) * (velocity - parentVelocity); + // HACK: until we are treating _velocity the same way we treat _position (meaning, + // _velocity is a vs parent value and any request for a world-frame velocity must + // be computed), do this to avoid equipped (parenting-grabbed) things from drifting. + // turning a zero velocity into a non-zero _velocity (because the avatar is moving) + // causes EntityItem::simulateKinematicMotion to have an effect on the equipped entity, + // which causes it to drift from the hand. + if (hasAncestorOfType(NestableType::Avatar)) { + _velocity = velocity; + } else { + // TODO: take parent angularVelocity into account. + _velocity = glm::inverse(parentTransform.getRotation()) * (velocity - parentVelocity); + } }); }