History

if script sets parent or jointIndex, don't pop entity off to someplace

Seth Alves committed 10 years ago

Commit d518a451 parent 1f0150f1 file · +13 −1Browse files

Showing the changes to libraries/entities/src/EntityScriptingInterface.cpp (1 of 1 file). Show all

Unified · Split

libraries/entities/src/EntityScriptingInterface.cpp+13−1
@@ -202,7 +202,7 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script · 201 unmodified lines
202202 bool updatedEntity = false;
203203 _entityTree->withWriteLock([&] {
204204 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
206206 // properties from the entity.
207207 if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) {
208208 EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID);
@@ -214,6 +214,18 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script · 5 unmodified lines
214214 }
215215 }
216216 }
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+ }
217229 properties = convertLocationFromScriptSemantics(properties);
218230 updatedEntity = _entityTree->updateEntity(entityID, properties);
219231 });