History

bid for ownership on script-change phys properties

Andrew Meadows committed 11 years ago

Commit c87e7c91 parent 4b299075 files · +25 −6Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+16−4
@@ -140,13 +140,17 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties proper · 139 unmodified lines
140140 if (entity) {
141141 // make sure the properties has a type, so that the encode can know which properties to include
142142 properties.setType(entity->getType());
143− if (properties.hasTerseUpdateChanges()) {
143+ bool hasTerseUpdateChanges = properties.hasTerseUpdateChanges();
144+ bool hasPhysicsChanges = properties.hasMiscPhysicsChanges() || hasTerseUpdateChanges;
145+ if (hasPhysicsChanges) {
144146 auto nodeList = DependencyManager::get<NodeList>();
145147 const QUuid myNodeID = nodeList->getSessionUUID();
146148
147149 if (entity->getSimulatorID() == myNodeID) {
148150 // we think we already own the simulation, so make sure to send ALL TerseUpdate properties
149− entity->getAllTerseUpdateProperties(properties);
151+ if (hasTerseUpdateChanges) {
152+ entity->getAllTerseUpdateProperties(properties);
153+ }
150154 // TODO: if we knew that ONLY TerseUpdate properties have changed in properties AND the object
151155 // is dynamic AND it is active in the physics simulation then we could chose to NOT queue an update
152156 // and instead let the physics simulation decide when to send a terse update. This would remove
@@ -558,7 +562,11 @@ QUuid EntityScriptingInterface::addAction(const QString& actionTypeString, · 405 unmodified lines
558562 return false;
559563 }
560564 if (actionFactory->factory(simulation, actionType, actionID, entity, arguments)) {
561− entity->flagForOwnership();
565+ auto nodeList = DependencyManager::get<NodeList>();
566+ const QUuid myNodeID = nodeList->getSessionUUID();
567+ if (entity->getSimulatorID() != myNodeID) {
568+ entity->flagForOwnership();
569+ }
562570 return true;
563571 }
564572 return false;
@@ -574,7 +582,11 @@ bool EntityScriptingInterface::updateAction(const QUuid& entityID, const QUuid& · 9 unmodified lines
574582 return actionWorker(entityID, [&](EntitySimulation* simulation, EntityItemPointer entity) {
575583 bool success = entity->updateAction(simulation, actionID, arguments);
576584 if (success) {
577− entity->flagForOwnership();
585+ auto nodeList = DependencyManager::get<NodeList>();
586+ const QUuid myNodeID = nodeList->getSessionUUID();
587+ if (entity->getSimulatorID() != myNodeID) {
588+ entity->flagForOwnership();
589+ }
578590 }
579591 return success;
580592 });