From 1119b9f29c92ce049a91f6c46abce7edf7d64def Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Sep 2019 15:05:37 -0700 Subject: [PATCH 1/4] update local QueryAACube on deactivation --- libraries/physics/src/EntityMotionState.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index de82dd6ace..7e4723a7d1 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -122,6 +122,13 @@ 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. This HACK updates the local + // QueryAACube but the one on the ES will still be broken. + _entity->updateQueryAACube(); + } } // virtual From 54d3ceda284057ea55ecc4dbb4466900ba472ce6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Sep 2019 15:31:16 -0700 Subject: [PATCH 2/4] update QueryAACube of kinematic things with known parentage --- libraries/entities/src/EntitySimulation.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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); } From 5ad0dd20acfabf1f891794b3ab8f50ae15621af6 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Sep 2019 15:43:53 -0700 Subject: [PATCH 3/4] update QueryAACube of unowned moving physical entities --- libraries/physics/src/PhysicalEntitySimulation.cpp | 2 ++ 1 file changed, 2 insertions(+) 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(); } } } From 434f5ff300bd8814fce2206f681ef6594ab1e416 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 17 Sep 2019 15:57:20 -0700 Subject: [PATCH 4/4] fix comment --- libraries/physics/src/EntityMotionState.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 7e4723a7d1..e48f0603bd 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -125,8 +125,7 @@ void EntityMotionState::handleDeactivation() { 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. This HACK updates the local - // QueryAACube but the one on the ES will still be broken. + // on a simulation owner to update the QueryAACube on the entity-server. _entity->updateQueryAACube(); } }