Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 1 file). Show all
Unified · Split
| @@ -242,13 +242,12 @@ QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties · 241 unmodified lines | |||
| 242 | _activityTracking.addedEntityCount++; | 242 | _activityTracking.addedEntityCount++; |
| 243 | 243 | ||
| 244 | auto nodeList = DependencyManager::get<NodeList>(); | 244 | auto nodeList = DependencyManager::get<NodeList>(); |
| 245 | auto sessionID = nodeList->getSessionUUID(); | 245 | const auto sessionID = nodeList->getSessionUUID(); |
| 246 | 246 | ||
| 247 | EntityItemProperties propertiesWithSimID = properties; | 247 | EntityItemProperties propertiesWithSimID = properties; |
| 248 | if (clientOnly) { | 248 | if (clientOnly) { |
| 249 | const QUuid myNodeID = sessionID; | ||
| 250 | propertiesWithSimID.setClientOnly(clientOnly); | 249 | propertiesWithSimID.setClientOnly(clientOnly); |
| 251 | propertiesWithSimID.setOwningAvatarID(myNodeID); | 250 | propertiesWithSimID.setOwningAvatarID(sessionID); |
| 252 | } | 251 | } |
| 253 | 252 | ||
| 254 | propertiesWithSimID.setLastEditedBy(sessionID); | 253 | propertiesWithSimID.setLastEditedBy(sessionID); |
| @@ -530,8 +529,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 275 unmodified lines | |||
| 530 | 529 | ||
| 531 | _activityTracking.editedEntityCount++; | 530 | _activityTracking.editedEntityCount++; |
| 532 | 531 | ||
| 533 | auto nodeList = DependencyManager::get<NodeList>(); | 532 | const auto sessionID = DependencyManager::get<NodeList>()->getSessionUUID(); |
| 534 | auto sessionID = nodeList->getSessionUUID(); | ||
| 535 | 533 | ||
| 536 | EntityItemProperties properties = scriptSideProperties; | 534 | EntityItemProperties properties = scriptSideProperties; |
| 537 | properties.setLastEditedBy(sessionID); | 535 | properties.setLastEditedBy(sessionID); |
| @@ -550,7 +548,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 12 unmodified lines | |||
| 550 | return; | 548 | return; |
| 551 | } | 549 | } |
| 552 | 550 | ||
| 553 | if (entity->getClientOnly() && entity->getOwningAvatarID() != nodeList->getSessionUUID()) { | 551 | if (entity->getClientOnly() && entity->getOwningAvatarID() != sessionID) { |
| 554 | // don't edit other avatar's avatarEntities | 552 | // don't edit other avatar's avatarEntities |
| 555 | return; | 553 | return; |
| 556 | } | 554 | } |
| @@ -600,10 +598,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 43 unmodified lines | |||
| 600 | bool hasTransformOrVelocityChanges = properties.hasTransformOrVelocityChanges(); | 598 | bool hasTransformOrVelocityChanges = properties.hasTransformOrVelocityChanges(); |
| 601 | bool hasPhysicsChanges = properties.hasMiscPhysicsChanges() || hasTransformOrVelocityChanges; | 599 | bool hasPhysicsChanges = properties.hasMiscPhysicsChanges() || hasTransformOrVelocityChanges; |
| 602 | if (_bidOnSimulationOwnership && hasPhysicsChanges) { | 600 | if (_bidOnSimulationOwnership && hasPhysicsChanges) { |
| 603 | auto nodeList = DependencyManager::get<NodeList>(); | 601 | if (entity->getSimulatorID() == sessionID) { |
| 604 | const QUuid myNodeID = nodeList->getSessionUUID(); | ||
| 605 | |||
| 606 | if (entity->getSimulatorID() == myNodeID) { | ||
| 607 | // we think we already own the simulation, so make sure to send the full transform and all velocities | 602 | // we think we already own the simulation, so make sure to send the full transform and all velocities |
| 608 | if (hasTransformOrVelocityChanges) { | 603 | if (hasTransformOrVelocityChanges) { |
| 609 | entity->getTransformAndVelocityProperties(properties); | 604 | entity->getTransformAndVelocityProperties(properties); |
| @@ -618,11 +613,11 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 8 unmodified lines | |||
| 618 | 613 | ||
| 619 | if (entity->getSimulationPriority() < SCRIPT_POKE_SIMULATION_PRIORITY) { | 614 | if (entity->getSimulationPriority() < SCRIPT_POKE_SIMULATION_PRIORITY) { |
| 620 | // we re-assert our simulation ownership at a higher priority | 615 | // we re-assert our simulation ownership at a higher priority |
| 621 | properties.setSimulationOwner(myNodeID, SCRIPT_POKE_SIMULATION_PRIORITY); | 616 | properties.setSimulationOwner(sessionID, SCRIPT_POKE_SIMULATION_PRIORITY); |
| 622 | } | 617 | } |
| 623 | } else { | 618 | } else { |
| 624 | // we make a bid for simulation ownership | 619 | // we make a bid for simulation ownership |
| 625 | properties.setSimulationOwner(myNodeID, SCRIPT_POKE_SIMULATION_PRIORITY); | 620 | properties.setSimulationOwner(sessionID, SCRIPT_POKE_SIMULATION_PRIORITY); |
| 626 | entity->setScriptSimulationPriority(SCRIPT_POKE_SIMULATION_PRIORITY); | 621 | entity->setScriptSimulationPriority(SCRIPT_POKE_SIMULATION_PRIORITY); |
| 627 | } | 622 | } |
| 628 | } | 623 | } |