Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 16 files). Show all
Unified · Split
| @@ -36,7 +36,7 @@ EntityScriptingInterface::EntityScriptingInterface(bool bidOnSimulationOwnership · 35 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | void EntityScriptingInterface::queueEntityMessage(PacketType packetType, |
| 38 | 38 | EntityItemID entityID, const EntityItemProperties& properties) { |
| 39 | − getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties); | |
| 39 | + getEntityPacketSender()->queueEditEntityMessage(packetType, _entityTree, entityID, properties); | |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | bool EntityScriptingInterface::canAdjustLocks() { |
| @@ -123,9 +123,10 @@ EntityItemProperties convertLocationFromScriptSemantics(const EntityItemProperti · 80 unmodified lines | ||
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | |
| 126 | −QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties) { | |
| 126 | +QUuid EntityScriptingInterface::addEntity(const EntityItemProperties& properties, bool clientOnly) { | |
| 127 | 127 | EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties); |
| 128 | 128 | propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged()); |
| 129 | + propertiesWithSimID = clientOnly; | |
| 129 | 130 | |
| 130 | 131 | auto dimensions = propertiesWithSimID.getDimensions(); |
| 131 | 132 | float volume = dimensions.x * dimensions.y * dimensions.z; |
| @@ -272,13 +273,15 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 140 unmodified lines | ||
| 272 | 273 | |
| 273 | 274 | bool updatedEntity = false; |
| 274 | 275 | _entityTree->withWriteLock([&] { |
| 276 | + EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | |
| 277 | + if (!entity) { | |
| 278 | + return; | |
| 279 | + } | |
| 280 | + | |
| 275 | 281 | if (scriptSideProperties.parentRelatedPropertyChanged()) { |
| 276 | 282 | // All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them. |
| 277 | 283 | // If any of these changed, pull any missing properties from the entity. |
| 278 | − EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | |
| 279 | − if (!entity) { | |
| 280 | − return; | |
| 281 | − } | |
| 284 | + | |
| 282 | 285 | //existing entity, retrieve old velocity for check down below |
| 283 | 286 | oldVelocity = entity->getVelocity().length(); |
| 284 | 287 | |
| @@ -296,6 +299,8 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 11 unmodified lines | ||
| 296 | 299 | } |
| 297 | 300 | } |
| 298 | 301 | properties = convertLocationFromScriptSemantics(properties); |
| 302 | + properties.setClientOnly(entity->getClientOnly()); | |
| 303 | + properties.setOwningAvatarID(entity->getOwningAvatarID()); | |
| 299 | 304 | |
| 300 | 305 | float cost = calculateCost(density * volume, oldVelocity, newVelocity); |
| 301 | 306 | cost *= costMultiplier; |