From 5e2a08b3c2f503a8e115a5a7b8f0bbf0b828d01e Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 25 Jun 2018 10:36:36 -0700 Subject: [PATCH 1/2] handle deactivation of avatar entities differently --- .../physics/src/PhysicalEntitySimulation.cpp | 21 ++++++++++++++++--- .../physics/src/PhysicalEntitySimulation.h | 8 +++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index 4d31067c20..b990d3612b 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -312,11 +312,26 @@ void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotio assert(state); if (state->getType() == MOTIONSTATE_TYPE_ENTITY) { EntityMotionState* entityState = static_cast(state); - if (!serverlessMode) { - entityState->handleDeactivation(); - } EntityItemPointer entity = entityState->getEntity(); _entitiesToSort.insert(entity); + if (!serverlessMode) { + if (entity->getClientOnly()) { + switch (entityState->getOwnershipState()) { + case EntityMotionState::OwnershipState::PendingBid: + _bids.removeFirst(entityState); + entityState->clearOwnershipState(); + break; + case EntityMotionState::OwnershipState::LocallyOwned: + _owned.removeFirst(entityState); + entityState->clearOwnershipState(); + break; + default: + break; + } + } else { + entityState->handleDeactivation(); + } + } } } } diff --git a/libraries/physics/src/PhysicalEntitySimulation.h b/libraries/physics/src/PhysicalEntitySimulation.h index 3f04347f18..fdf996df25 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.h +++ b/libraries/physics/src/PhysicalEntitySimulation.h @@ -37,6 +37,14 @@ public: } pop_back(); } + void removeFirst(EntityMotionState* state) { + for (uint32_t i = 0; i < size(); ++i) { + if ((*this)[i] == state) { + remove(i); + break; + } + } + } }; class PhysicalEntitySimulation : public EntitySimulation { From 756f34761fd8e3adb807daecbe672a89d663d4c5 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Mon, 25 Jun 2018 10:37:12 -0700 Subject: [PATCH 2/2] don't build AvatarMotionStates until physics enabled --- interface/src/avatar/AvatarManager.cpp | 3 ++- interface/src/avatar/AvatarMotionState.cpp | 4 ++++ interface/src/avatar/AvatarMotionState.h | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/interface/src/avatar/AvatarManager.cpp b/interface/src/avatar/AvatarManager.cpp index 4d133706e6..c63095a204 100644 --- a/interface/src/avatar/AvatarManager.cpp +++ b/interface/src/avatar/AvatarManager.cpp @@ -186,6 +186,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { uint64_t updateExpiry = startTime + UPDATE_BUDGET; int numAvatarsUpdated = 0; int numAVatarsNotUpdated = 0; + bool physicsEnabled = qApp->isPhysicsEnabled(); render::Transaction transaction; while (!sortedAvatars.empty()) { @@ -202,7 +203,7 @@ void AvatarManager::updateOtherAvatars(float deltaTime) { if (_shouldRender) { avatar->ensureInScene(avatar, qApp->getMain3DScene()); } - if (!avatar->isInPhysicsSimulation()) { + if (physicsEnabled && !avatar->isInPhysicsSimulation()) { ShapeInfo shapeInfo; avatar->computeShapeInfo(shapeInfo); btCollisionShape* shape = const_cast(ObjectMotionState::getShapeManager()->getShape(shapeInfo)); diff --git a/interface/src/avatar/AvatarMotionState.cpp b/interface/src/avatar/AvatarMotionState.cpp index 6fc1bd8196..50c715b14a 100644 --- a/interface/src/avatar/AvatarMotionState.cpp +++ b/interface/src/avatar/AvatarMotionState.cpp @@ -154,6 +154,10 @@ const QUuid AvatarMotionState::getObjectID() const { return _avatar->getSessionUUID(); } +QString AvatarMotionState::getName() const { + return _avatar->getName(); +} + // virtual QUuid AvatarMotionState::getSimulatorID() const { return _avatar->getSessionUUID(); diff --git a/interface/src/avatar/AvatarMotionState.h b/interface/src/avatar/AvatarMotionState.h index 2738aba8ee..9228641b25 100644 --- a/interface/src/avatar/AvatarMotionState.h +++ b/interface/src/avatar/AvatarMotionState.h @@ -59,6 +59,7 @@ public: virtual const QUuid getObjectID() const override; + virtual QString getName() const override; virtual QUuid getSimulatorID() const override; void setBoundingBox(const glm::vec3& corner, const glm::vec3& diagonal);