From c039d20304f8789e0d4a3209987a2324e6bc4738 Mon Sep 17 00:00:00 2001 From: sabrina-shanman Date: Wed, 20 Jun 2018 10:19:19 -0700 Subject: [PATCH] Fix objects snapping back when selected --- libraries/physics/src/EntityMotionState.cpp | 8 +------- libraries/physics/src/PhysicalEntitySimulation.cpp | 8 ++++++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index 594ea476f6..743d5b0c19 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -347,7 +347,7 @@ bool EntityMotionState::remoteSimulationOutOfSync(uint32_t simulationStep) { if (_numInactiveUpdates > 0) { const uint8_t MAX_NUM_INACTIVE_UPDATES = 20; - if (_numInactiveUpdates > MAX_NUM_INACTIVE_UPDATES || isServerlessMode()) { + if (_numInactiveUpdates > MAX_NUM_INACTIVE_UPDATES) { // clear local ownership (stop sending updates) and let the server clear itself _entity->clearSimulationOwnership(); return false; @@ -829,9 +829,3 @@ void EntityMotionState::clearObjectVelocities() const { } _entity->setAcceleration(glm::vec3(0.0f)); } - -bool EntityMotionState::isServerlessMode() { - EntityTreeElementPointer element = _entity->getElement(); - EntityTreePointer tree = element ? element->getTree() : nullptr; - return tree ? tree->isServerlessMode() : false; -} diff --git a/libraries/physics/src/PhysicalEntitySimulation.cpp b/libraries/physics/src/PhysicalEntitySimulation.cpp index bb8e518dc6..60b1eb9b59 100644 --- a/libraries/physics/src/PhysicalEntitySimulation.cpp +++ b/libraries/physics/src/PhysicalEntitySimulation.cpp @@ -277,12 +277,15 @@ void PhysicalEntitySimulation::getObjectsToChange(VectorOfMotionStates& result) } void PhysicalEntitySimulation::handleDeactivatedMotionStates(const VectorOfMotionStates& motionStates) { + boolean serverlessMode = getEntityTree()->isServerlessMode(); for (auto stateItr : motionStates) { ObjectMotionState* state = &(*stateItr); assert(state); if (state->getType() == MOTIONSTATE_TYPE_ENTITY) { EntityMotionState* entityState = static_cast(state); - entityState->handleDeactivation(); + if (!serverlessMode) { + entityState->handleDeactivation(); + } EntityItemPointer entity = entityState->getEntity(); _entitiesToSort.insert(entity); } @@ -379,6 +382,7 @@ void PhysicalEntitySimulation::sendOwnershipBids(uint32_t numSubsteps) { } void PhysicalEntitySimulation::sendOwnedUpdates(uint32_t numSubsteps) { + boolean serverlessMode = getEntityTree()->isServerlessMode(); PROFILE_RANGE_EX(simulation_physics, "Update", 0x00000000, (uint64_t)_owned.size()); uint32_t i = 0; while (i < _owned.size()) { @@ -390,7 +394,7 @@ void PhysicalEntitySimulation::sendOwnedUpdates(uint32_t numSubsteps) { } _owned.remove(i); } else { - if (_owned[i]->shouldSendUpdate(numSubsteps)) { + if (!serverlessMode && _owned[i]->shouldSendUpdate(numSubsteps)) { _owned[i]->sendUpdate(_entityPacketSender, numSubsteps); } ++i;