From 82bd5060860a2cb4ab25f7c8b10bb7422434b08f Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Tue, 10 Nov 2015 14:32:57 -0800 Subject: [PATCH] adjust how EntityMotionState updates its idea of what the server knows about an entity --- .../entities/src/EntityScriptingInterface.cpp | 21 +++++++++---------- libraries/physics/src/EntityMotionState.cpp | 5 +++++ 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index e5caab3a71..bc57f2c72c 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -611,7 +611,7 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, const QVariantMap& arguments) { QUuid actionID = QUuid::createUuid(); auto actionFactory = DependencyManager::get(); - bool success = true; + bool success = false; actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) { // create this action even if the entity doesn't have physics info. it will often be the // case that a script adds an action immediately after an object is created, and the physicsInfo @@ -621,20 +621,19 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, // } EntityActionType actionType = EntityActionInterface::actionTypeFromString(actionTypeString); if (actionType == ACTION_TYPE_NONE) { - success = false; return false; } EntityActionPointer action = actionFactory->factory(actionType, actionID, entity, arguments); - if (action) { - success = entity->addAction(simulation, action); - auto nodeList = DependencyManager::get(); - const QUuid myNodeID = nodeList->getSessionUUID(); - if (entity->getSimulatorID() != myNodeID) { - entity->flagForOwnership(); - } - return false; // Physics will cause a packet to be sent, so don't send from here. + if (!action) { + return false; } - return false; + success = entity->addAction(simulation, action); + auto nodeList = DependencyManager::get(); + const QUuid myNodeID = nodeList->getSessionUUID(); + if (entity->getSimulatorID() != myNodeID) { + entity->flagForOwnership(); + } + return false; // Physics will cause a packet to be sent, so don't send from here. }); if (success) { return actionID; diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index c8a0f87b6d..2a7bde2377 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -86,6 +86,11 @@ void EntityMotionState::updateServerPhysicsVariables(const QUuid& sessionID) { return; } + if (_entity->shouldSuppressLocationEdits()) { + // if we send now, the changes will be ignored, so don't update our idea of what the server knows. + return; + } + _serverPosition = _entity->getPosition(); _serverRotation = _entity->getRotation(); _serverVelocity = _entity->getVelocity();