From b8587e0711591ac852739ce300217a7a37cd405d Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 4 Apr 2016 16:06:53 -0700 Subject: [PATCH] update collision shapes of entities which are children of avatars --- libraries/entities/src/EntityItem.cpp | 6 +++++- libraries/physics/src/EntityMotionState.cpp | 7 ++++++- libraries/shared/src/SpatiallyNestable.cpp | 15 +++++++++++++++ libraries/shared/src/SpatiallyNestable.h | 2 ++ 4 files changed, 28 insertions(+), 2 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index 9fa58c9187..6306277431 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -1963,7 +1963,11 @@ QList EntityItem::getActionsOfType(EntityActionType typeToG } void EntityItem::locationChanged() { - requiresRecalcBoxes(); + _dirtyFlags |= Simulation::DIRTY_TRANSFORM; + EntityTreePointer tree = getTree(); + if (tree) { + tree->entityChanged(getThisPointer()); + } SpatiallyNestable::locationChanged(); // tell all the children, also } diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 5f168d2e33..f232827fc2 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -159,7 +159,12 @@ PhysicsMotionType EntityMotionState::computePhysicsMotionType() const { } return MOTION_TYPE_DYNAMIC; } - return (_entity->isMovingRelativeToParent() || _entity->hasActions()) ? MOTION_TYPE_KINEMATIC : MOTION_TYPE_STATIC; + if (_entity->isMovingRelativeToParent() || + _entity->hasActions() || + _entity->hasAncestorOfType(NestableType::Avatar)) { + return MOTION_TYPE_KINEMATIC; + } + return MOTION_TYPE_STATIC; } bool EntityMotionState::isMoving() const { diff --git a/libraries/shared/src/SpatiallyNestable.cpp b/libraries/shared/src/SpatiallyNestable.cpp index 3cbd3c5ac9..dfe1f2c0e4 100644 --- a/libraries/shared/src/SpatiallyNestable.cpp +++ b/libraries/shared/src/SpatiallyNestable.cpp @@ -879,3 +879,18 @@ void SpatiallyNestable::setLocalTransformAndVelocities( }); locationChanged(); } + + +bool SpatiallyNestable::hasAncestorOfType(NestableType nestableType) { + if (_nestableType == nestableType) { + return true; + } + + bool success; + SpatiallyNestablePointer parent = getParentPointer(success); + if (!success || !parent) { + return false; + } + + return parent->hasAncestorOfType(nestableType); +} diff --git a/libraries/shared/src/SpatiallyNestable.h b/libraries/shared/src/SpatiallyNestable.h index ef70d0231b..8b225d5ae8 100644 --- a/libraries/shared/src/SpatiallyNestable.h +++ b/libraries/shared/src/SpatiallyNestable.h @@ -142,6 +142,8 @@ public: bool isParentIDValid() const { bool success = false; getParentPointer(success); return success; } virtual SpatialParentTree* getParentTree() const { return nullptr; } + bool hasAncestorOfType(NestableType nestableType); + protected: const NestableType _nestableType; // EntityItem or an AvatarData QUuid _id;