From f0fb9966ada9f89ec58ba5612cfae35adb1e9156 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Sun, 6 Dec 2015 12:34:41 -0800 Subject: [PATCH] expose parent-joint-index to edit.js --- examples/html/entityProperties.html | 9 +++++++ .../entities/src/EntityScriptingInterface.cpp | 27 +++++++------------ 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/examples/html/entityProperties.html b/examples/html/entityProperties.html index bef5c825c2..186b2ee828 100644 --- a/examples/html/entityProperties.html +++ b/examples/html/entityProperties.html @@ -226,6 +226,7 @@ var elRescaleDimensionsButton = document.getElementById("dimension-rescale-button"); var elParentID = document.getElementById("property-parent-id"); + var elParentJointIndex = document.getElementById("property-parent-joint-index"); var elRegistrationX = document.getElementById("property-reg-x"); var elRegistrationY = document.getElementById("property-reg-y"); @@ -456,6 +457,7 @@ elDimensionsZ.value = properties.dimensions.z.toFixed(2); elParentID.value = properties.parentID; + elParentJointIndex.value = properties.parentJointIndex; elRegistrationX.value = properties.registrationPoint.x.toFixed(2); elRegistrationY.value = properties.registrationPoint.y.toFixed(2); @@ -671,6 +673,7 @@ elDimensionsZ.addEventListener('change', dimensionsChangeFunction); elParentID.addEventListener('change', createEmitTextPropertyUpdateFunction('parentID')); + elParentJointIndex.addEventListener('change', createEmitNumberPropertyUpdateFunction('parentJointIndex')); var registrationChangeFunction = createEmitVec3PropertyUpdateFunction( 'registrationPoint', elRegistrationX, elRegistrationY, elRegistrationZ); @@ -1067,6 +1070,12 @@ +
+ ParentJointIndex +
+ +
+
Registration
diff --git a/libraries/entities/src/EntityScriptingInterface.cpp b/libraries/entities/src/EntityScriptingInterface.cpp index 23fbac13cf..2488470bfa 100644 --- a/libraries/entities/src/EntityScriptingInterface.cpp +++ b/libraries/entities/src/EntityScriptingInterface.cpp @@ -201,28 +201,21 @@ QUuid EntityScriptingInterface::editEntity(QUuid id, EntityItemProperties script bool updatedEntity = false; _entityTree->withWriteLock([&] { - if (scriptSideProperties.parentDependentPropertyChanged()) { - // if the script set a location property but didn't include parent information, grab the needed - // properties from the entity. - if (!scriptSideProperties.parentIDChanged() || !scriptSideProperties.parentJointIndexChanged()) { - EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); - if (entity && !scriptSideProperties.parentIDChanged()) { - properties.setParentID(entity->getParentID()); - } - if (entity && !scriptSideProperties.parentJointIndexChanged()) { - properties.setParentJointIndex(entity->getParentJointIndex()); - } + if (scriptSideProperties.parentDependentPropertyChanged() || + scriptSideProperties.parentIDChanged() || scriptSideProperties.parentJointIndexChanged()) { + // All of parentID, parentJointIndex, position, rotation are needed to make sense of any of them. + // If any of these changed, pull any missing properties from the entity. + EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); + if (entity && !scriptSideProperties.parentIDChanged()) { + properties.setParentID(entity->getParentID()); + } + if (entity && !scriptSideProperties.parentJointIndexChanged()) { + properties.setParentJointIndex(entity->getParentJointIndex()); } - } - if (scriptSideProperties.parentIDChanged() || scriptSideProperties.parentJointIndexChanged()) { - // if the script set parentID or parentJointIndex but didn't include position and rotation, grab - // the missing properties from the entity if (!scriptSideProperties.localPositionChanged() && !scriptSideProperties.positionChanged()) { - EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); properties.setPosition(entity->getPosition()); } if (!scriptSideProperties.localRotationChanged() && !scriptSideProperties.rotationChanged()) { - EntityItemPointer entity = _entityTree->findEntityByEntityItemID(entityID); properties.setRotation(entity->getOrientation()); } }