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 | auto nodeList = DependencyManager::get<NodeList>(); | 65 | auto nodeList = DependencyManager::get<NodeList>(); |
| 66 | const QUuid myNodeID = nodeList->getSessionUUID(); | 66 | const QUuid myNodeID = nodeList->getSessionUUID(); |
| 67 | 67 | ||
| 68 | // if this entity has non-zero physics/simulation related values, claim simulation ownership | ||
| 68 | if (propertiesWithSimID.velocityChanged() || | 69 | if (propertiesWithSimID.velocityChanged() || |
| 69 | propertiesWithSimID.rotationChanged() || | 70 | propertiesWithSimID.rotationChanged() || |
| 70 | propertiesWithSimID.containsPositionChange()) { | 71 | propertiesWithSimID.containsPositionChange()) { |
| @@ -83,7 +84,6 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 12 unmodified lines | |||
| 83 | // The application will keep track of creatorTokenID | 84 | // The application will keep track of creatorTokenID |
| 84 | uint32_t creatorTokenID = EntityItemID::getNextCreatorTokenID(); | 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 | EntityItemProperties propertiesWithSimID = properties; | 87 | EntityItemProperties propertiesWithSimID = properties; |
| 88 | 88 | ||
| 89 | EntityItemID id(NEW_ENTITY, creatorTokenID, false ); | 89 | EntityItemID id(NEW_ENTITY, creatorTokenID, false ); |
| @@ -92,6 +92,7 @@ EntityItemID EntityScriptingInterface::addEntity(const EntityItemProperties& pro · 2 unmodified lines | |||
| 92 | if (_entityTree) { | 92 | if (_entityTree) { |
| 93 | _entityTree->lockForWrite(); | 93 | _entityTree->lockForWrite(); |
| 94 | EntityItem* entity = _entityTree->addEntity(id, propertiesWithSimID); | 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 | setSimId(propertiesWithSimID, entity); | 96 | setSimId(propertiesWithSimID, entity); |
| 96 | _entityTree->unlock(); | 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 | EntityItemProperties propertiesWithSimID = properties; | 164 | EntityItemProperties propertiesWithSimID = properties; |
| 165 | 165 | ||
| 166 | // If we have a local entity tree set, then also update it. We can do this even if we don't know | 166 | // If we have a local entity tree set, then also update it. We can do this even if we don't know |