Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 3 files). Show all
Unified · Split
| @@ -65,6 +65,7 @@ void setSimId(EntityItemProperties& propertiesWithSimID, EntityItem* entity) { · 64 unmodified lines | ||
| 65 | 65 | auto nodeList = DependencyManager::get<NodeList>(); |
| 66 | 66 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 67 | 67 | |
| 68 | + // if this entity has non-zero physics/simulation related values, claim simulation ownership | |
| 68 | 69 | if (propertiesWithSimID.velocityChanged() || |
| 69 | 70 | propertiesWithSimID.rotationChanged() || |
| 70 | 71 | propertiesWithSimID.containsPositionChange()) { |
| @@ -83,7 +84,6 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 12 unmodified lines | ||
| 83 | 84 | // The application will keep track of creatorTokenID |
| 84 | 85 | uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID(); |
| 85 | 86 | |
| 86 | − // This Node is creating a new object. If it's in motion, set this Node as the simulator. | |
| 87 | 87 | EntityItemProperties propertiesWithSimID = properties; |
| 88 | 88 | |
| 89 | 89 | EntityItemID id(NEW_ENTITY, creatorTokenID, false ); |
| @@ -92,6 +92,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 2 unmodified lines | ||
| 92 | 92 | if (_entityTree) { |
| 93 | 93 | _entityTree->lockForWrite(); |
| 94 | 94 | EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID); |
| 95 | + // This Node is creating a new object. If it's in motion, set this Node as the simulator. | |
| 95 | 96 | setSimId(propertiesWithSimID, entity); |
| 96 | 97 | _entityTree->unlock(); |
| 97 | 98 | } |
| @@ -160,7 +161,6 @@ EntityItemID EntityScriptingInterface::editEntity(EntityItemID entityID, const E · 62 unmodified lines | ||
| 160 | 161 | } |
| 161 | 162 | } |
| 162 | 163 | |
| 163 | − // if this Node is changing a physics-related property, claim simulation ownership. | |
| 164 | 164 | EntityItemProperties propertiesWithSimID = properties; |
| 165 | 165 | |
| 166 | 166 | // If we have a local entity tree set, then also update it. We can do this even if we don't know |