diff --git a/libraries/entities/src/EntitySimulation.cpp b/libraries/entities/src/EntitySimulation.cpp index b5e4fed0fd..9f81572a4a 100644 --- a/libraries/entities/src/EntitySimulation.cpp +++ b/libraries/entities/src/EntitySimulation.cpp @@ -242,11 +242,21 @@ void EntitySimulation::moveSimpleKinematics(uint64_t now) { entity->getMaximumAACube(ancestryIsKnown); bool hasAvatarAncestor = entity->hasAncestorOfType(NestableType::Avatar); - if (entity->isMovingRelativeToParent() && !entity->getPhysicsInfo() && ancestryIsKnown && !hasAvatarAncestor) { + bool isMoving = entity->isMovingRelativeToParent(); + if (isMoving && !entity->getPhysicsInfo() && ancestryIsKnown && !hasAvatarAncestor) { entity->simulate(now); + if (ancestryIsKnown && !hasAvatarAncestor) { + entity->updateQueryAACube(); + } _entitiesToSort.insert(entity); ++itemItr; } else { + if (!isMoving && ancestryIsKnown && !hasAvatarAncestor) { + // HACK: This catches most cases where the entity's QueryAACube (and spatial sorting in the EntityTree) + // would otherwise be out of date at conclusion of its "unowned" simpleKinematicMotion. + entity->updateQueryAACube(); + _entitiesToSort.insert(entity); + } // the entity is no longer non-physical-kinematic itemItr = _simpleKinematicEntities.erase(itemItr); } diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index de82dd6ace..e48f0603bd 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -122,6 +122,12 @@ void EntityMotionState::handleDeactivation() { _body->setWorldTransform(worldTrans); // no need to update velocities... should already be zero } + if (!isLocallyOwned()) { + // HACK: To allow the ESS to move entities around in a kinematic way we had to remove the requirement that + // every moving+simulated entity has an authoritative simulation owner. As a result, we cannot rely + // on a simulation owner to update the QueryAACube on the entity-server. + _entity->updateQueryAACube(); + } } // virtual diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 85c53af10a..43ced16119 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -528,6 +528,8 @@ void PhysicalEntitySimulation::handleChangedMotionStates(const VectorOfMotionSta addOwnership(entityState); } else if (entityState->shouldSendBid()) { addOwnershipBid(entityState); + } else { + entityState->getEntity()->updateQueryAACube(); } } }