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
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 needed205 // 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 });