From 4a5631fca6ad359c802d9df587dfd92f63a680f6 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Mon, 20 Apr 2015 16:51:28 -0700 Subject: [PATCH] cleanups, diff minimization --- libraries/entities/src/EntityItem.cpp | 4 ++-- libraries/entities/src/EntityScriptingInterface.cpp | 4 ++-- libraries/physics/src/EntityMotionState.cpp | 4 +--- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index d221c0bba4..4875069aae 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -405,8 +405,6 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef quint64 lastEditedFromBuffer = 0; quint64 lastEditedFromBufferAdjusted = 0; - bool ignoreServerPacket = false; - // TODO: we could make this encoded as a delta from _created // _lastEdited memcpy(&lastEditedFromBuffer, dataAt, sizeof(lastEditedFromBuffer)); @@ -432,6 +430,8 @@ int EntityItem::readEntityDataFromBuffer(const unsigned char* data, int bytesLef qCDebug(entities) << " fromSameServerEdit:" << fromSameServerEdit; #endif + bool ignoreServerPacket = false; + // If this packet is from the same server edit as the last packet we accepted from the server // we probably want to use it. if (fromSameServerEdit) { diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 6bd988ec90..53335beda0 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -65,6 +65,7 @@ void setSimId(EntityItemProperties& propertiesWithSimID, EntityItem* entity) { auto nodeList = DependencyManager::get(); const QUuid myNodeID = nodeList->getSessionUUID(); + // if this entity has non-zero physics/simulation related values, claim simulation ownership if (propertiesWithSimID.velocityChanged() || propertiesWithSimID.rotationChanged() || propertiesWithSimID.containsPositionChange()) { @@ -83,7 +84,6 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro // The application will keep track of creatorTokenID uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID(); - // This Node is creating a new object. If it's in motion, set this Node as the simulator. EntityItemProperties propertiesWithSimID = properties; EntityItemID id(NEW_ENTITY, creatorTokenID, false ); @@ -92,6 +92,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro if (_entityTree) { _entityTree->lockForWrite(); EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID); + // This Node is creating a new object. If it's in motion, set this Node as the simulator. setSimId(propertiesWithSimID, entity); _entityTree->unlock(); } @@ -160,7 +161,6 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E } } - // if this Node is changing a physics-related property, claim simulation ownership. EntityItemProperties propertiesWithSimID = properties; // If we have a local entity tree set, then also update it. We can do this even if we don't know diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index e188bad613..e689ac21bc 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -217,9 +217,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ if (glm::length(_measuredAcceleration) < MEASURED_ACCELERATION_CLOSE_TO_ZERO) { _entity->setAcceleration(glm::vec3(0)); } else { - // _entity->setAcceleration(_entity->getGravity()); - // XXX - _entity->setAcceleration(glm::vec3(0)); + _entity->setAcceleration(_entity->getGravity()); } if (_outgoingPacketFlags & EntityItem::DIRTY_POSITION) {