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 | void EntityScriptingInterface::queueEntityMessage(PacketType packetType, | 37 | void EntityScriptingInterface::queueEntityMessage(PacketType packetType, |
| 38 | EntityItemID entityID, const EntityItemProperties& properties) { | 38 | EntityItemID entityID, const EntityItemProperties& properties) { |
| 39 | getEntityPacketSender()->queueEditEntityMessage(packetType, entityID, properties); | 39 | getEntityPacketSender()->queueEditEntityMessage(packetType, _entityTree, entityID, properties); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | bool EntityScriptingInterface::canAdjustLocks() { | 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 | EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties); | 127 | EntityItemProperties propertiesWithSimID = convertLocationFromScriptSemantics(properties); |
| 128 | propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged()); | 128 | propertiesWithSimID.setDimensionsInitialized(properties.dimensionsChanged()); |
| 129 | propertiesWithSimID = clientOnly; | ||
| 129 | 130 | ||
| 130 | auto dimensions = propertiesWithSimID.getDimensions(); | 131 | auto dimensions = propertiesWithSimID.getDimensions(); |
| 131 | float volume = dimensions.x * dimensions.y * dimensions.z; | 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 | bool updatedEntity = false; | 274 | bool updatedEntity = false; |
| 274 | _entityTree->withWriteLock([&] { | 275 | _entityTree->withWriteLock([&] { |
| 276 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | ||
| 277 | if (!entity) { | ||
| 278 | return; | ||
| 279 | } | ||
| 280 | |||
| 275 | if (scriptSideProperties.parentRelatedPropertyChanged()) { | 281 | if (scriptSideProperties.parentRelatedPropertyChanged()) { |
| 276 | // All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them. | 282 | // All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them. |
| 277 | // If any of these changed, pull any missing properties from the entity. | 283 | // If any of these changed, pull any missing properties from the entity. |
| 278 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | 284 | |
| 279 | if (!entity) { | ||
| 280 | return; | ||
| 281 | } | ||
| 282 | //existing entity, retrieve old velocity for check down below | 285 | //existing entity, retrieve old velocity for check down below |
| 283 | oldVelocity = entity->getVelocity().length(); | 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 | properties = convertLocationFromScriptSemantics(properties); | 301 | properties = convertLocationFromScriptSemantics(properties); |
| 302 | properties.setClientOnly(entity->getClientOnly()); | ||
| 303 | properties.setOwningAvatarID(entity->getOwningAvatarID()); | ||
| 299 | 304 | ||
| 300 | float cost = calculateCost(density * volume, oldVelocity, newVelocity); | 305 | float cost = calculateCost(density * volume, oldVelocity, newVelocity); |
| 301 | cost *= costMultiplier; | 306 | cost *= costMultiplier; |