Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -523,6 +523,27 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, const EntityItemProperties& · 522 unmodified lines | ||
| 523 | 523 | } |
| 524 | 524 | } |
| 525 | 525 | }); |
| 526 | + } else { | |
| 527 | + // Sometimes ESS don't have the entity they are trying to edit in their local tree. In this case, | |
| 528 | + // convertPropertiesFromScriptSemantics doesn't get called and local* edits will get dropped. | |
| 529 | + // This is because, on the script side, "position" is in world frame, but in the network | |
| 530 | + // protocol and in the internal data-structures, "position" is "relative to parent". | |
| 531 | + // Compensate here. The local* versions will get ignored during the edit-packet encoding. | |
| 532 | + if (properties.localPositionChanged()) { | |
| 533 | + properties.setPosition(properties.getLocalPosition()); | |
| 534 | + } | |
| 535 | + if (properties.localRotationChanged()) { | |
| 536 | + properties.setRotation(properties.getLocalRotation()); | |
| 537 | + } | |
| 538 | + if (properties.localVelocityChanged()) { | |
| 539 | + properties.setVelocity(properties.getLocalVelocity()); | |
| 540 | + } | |
| 541 | + if (properties.localAngularVelocityChanged()) { | |
| 542 | + properties.setAngularVelocity(properties.getLocalAngularVelocity()); | |
| 543 | + } | |
| 544 | + if (properties.localDimensionsChanged()) { | |
| 545 | + properties.setDimensions(properties.getLocalDimensions()); | |
| 546 | + } | |
| 526 | 547 | } |
| 527 | 548 | }); |
| 528 | 549 | if (!entityFound) { |