Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 1 file). Show all
Unified · Split
| @@ -202,7 +202,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script · 201 unmodified lines | |||
| 202 | bool updatedEntity = false; | 202 | bool updatedEntity = false; |
| 203 | _entityTree->withWriteLock([&] { | 203 | _entityTree->withWriteLock([&] { |
| 204 | if (scriptSideProperties.parentDependentPropertyChanged()) { | 204 | if (scriptSideProperties.parentDependentPropertyChanged()) { |
| 205 | // if the script sets a location property but didn't include parent information, grab the needed | 205 | // if the script set a location property but didn't include parent information, grab the needed |
| 206 | // properties from the entity. | 206 | // properties from the entity. |
| 207 | if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) { | 207 | if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) { |
| 208 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | 208 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); |
| @@ -214,6 +214,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script · 5 unmodified lines | |||
| 214 | } | 214 | } |
| 215 | } | 215 | } |
| 216 | } | 216 | } |
| 217 | if (scriptSideProperties.parentIDChanged() || scriptSideProperties.parentJointIndexChanged()) { | ||
| 218 | // if the script set parentID or parentJointIndex but didn't include position and rotation, grab | ||
| 219 | // the missing properties from the entity | ||
| 220 | if (!scriptSideProperties.localPositionChanged() && !scriptSideProperties.positionChanged()) { | ||
| 221 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | ||
| 222 | properties.setPosition(entity->getPosition()); | ||
| 223 | } | ||
| 224 | if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) { | ||
| 225 | EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); | ||
| 226 | properties.setRotation(entity->getOrientation()); | ||
| 227 | } | ||
| 228 | } | ||
| 217 | properties = convertLocationFromScriptSemantics(properties); | 229 | properties = convertLocationFromScriptSemantics(properties); |
| 218 | updatedEntity = _entityTree->updateEntity(entityID, properties); | 230 | updatedEntity = _entityTree->updateEntity(entityID, properties); |
| 219 | }); | 231 | }); |