From 3890a71433ba67a8cfd9f09a0d738f4c5f3313e8 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 9 Apr 2016 08:37:41 -0700 Subject: [PATCH 1/2] treat children of avatars and children of entities differently until this is fixed --- libraries/shared/src/SpatiallyNestable.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index 96a5a1d8ae..7169e5c3d8 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); + } }); } From 2aa3e5d418b3180ffd1a57597194b705996f7e66 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sat, 9 Apr 2016 09:06:18 -0700 Subject: [PATCH 2/2] re-enabled EntityItem::simulateKinematicMotion for things with parents --- libraries/entities/src/EntityItem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 4cd8a34248..17b4e6a87d 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();