cleanups, diff minimization

This commit is contained in:
Seth Alves 2015-04-20 16:51:28 -07:00
parent 6107682658
commit 4a5631fca6
3 changed files with 5 additions and 7 deletions

View file

@ -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) {

View file

@ -65,6 +65,7 @@ void setSimId(EntityItemProperties& propertiesWithSimID, EntityItem* entity) {
auto nodeList = DependencyManager::get<NodeList>();
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

View file

@ -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) {