From 98a8d3361bde86aaf83d9291357a060405e74a79 Mon Sep 17 00:00:00 2001 From: David Back Date: Mon, 16 Jul 2018 18:21:58 -0700 Subject: [PATCH 1/2] stop findGroupParent at cloneable --- libraries/entities/src/EntityItemProperties.cpp | 1 + .../controllers/controllerModules/highlightNearbyEntities.js | 2 +- .../controllers/controllerModules/nearParentGrabEntity.js | 3 ++- scripts/system/libraries/controllerDispatcherUtils.js | 5 ++++- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index efd2376677..650e391378 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -3676,6 +3676,7 @@ bool EntityItemProperties::verifyStaticCertificateProperties() { void EntityItemProperties::convertToCloneProperties(const EntityItemID& entityIDToClone) { setName(getName() + "-clone-" + entityIDToClone.toString()); setLocked(false); + setParentID(QUuid()); setLifetime(getCloneLifetime()); setDynamic(getCloneDynamic()); setClientOnly(getCloneAvatarEntity()); diff --git a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js index bc09ebee7a..2fecf2947e 100644 --- a/scripts/system/controllers/controllerModules/highlightNearbyEntities.js +++ b/scripts/system/controllers/controllerModules/highlightNearbyEntities.js @@ -47,7 +47,7 @@ var canGrabEntity = false; if (dispatcherUtils.entityIsGrabbable(props) || entityIsCloneable(props)) { // if we've attempted to grab a child, roll up to the root of the tree - var groupRootProps = dispatcherUtils.findGroupParent(controllerData, props); + var groupRootProps = dispatcherUtils.findGroupParent(controllerData, props, false); canGrabEntity = true; if (!dispatcherUtils.entityIsGrabbable(groupRootProps)) { canGrabEntity = false; diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index 00d7ad0491..3152f74e79 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -254,7 +254,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); this.hapticTargetID = props.id; } // if we've attempted to grab a child, roll up to the root of the tree - var groupRootProps = findGroupParent(controllerData, props); + var stopAtCloneable = true; + var groupRootProps = findGroupParent(controllerData, props, stopAtCloneable); if (entityIsGrabbable(groupRootProps)) { return groupRootProps; } diff --git a/scripts/system/libraries/controllerDispatcherUtils.js b/scripts/system/libraries/controllerDispatcherUtils.js index 5dfb0d5b69..87176501b2 100644 --- a/scripts/system/libraries/controllerDispatcherUtils.js +++ b/scripts/system/libraries/controllerDispatcherUtils.js @@ -355,10 +355,13 @@ ensureDynamic = function (entityID) { } }; -findGroupParent = function (controllerData, targetProps) { +findGroupParent = function (controllerData, targetProps, stopAtCloneable) { while (targetProps.parentID && targetProps.parentID !== Uuid.NULL && Entities.getNestableType(targetProps.parentID) == "entity") { + if (stopAtCloneable && entityIsCloneable(targetProps)) { + break; + } var parentProps = Entities.getEntityProperties(targetProps.parentID, DISPATCHER_PROPERTIES); if (!parentProps) { break; From 0b9e520b53c912c5e38d203a5f6d190b164148c7 Mon Sep 17 00:00:00 2001 From: David Back Date: Wed, 1 Aug 2018 16:00:25 -0700 Subject: [PATCH 2/2] fix grab cloning parented entitiy --- libraries/entities/src/EntityItemProperties.cpp | 2 ++ .../controllerModules/nearActionGrabEntity.js | 10 ++++++---- .../controllerModules/nearParentGrabEntity.js | 10 ++++++---- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/libraries/entities/src/EntityItemProperties.cpp b/libraries/entities/src/EntityItemProperties.cpp index 1f9bf2eb18..27fe55673f 100644 --- a/libraries/entities/src/EntityItemProperties.cpp +++ b/libraries/entities/src/EntityItemProperties.cpp @@ -3743,6 +3743,8 @@ bool EntityItemProperties::verifyStaticCertificateProperties() { void EntityItemProperties::convertToCloneProperties(const EntityItemID& entityIDToClone) { setName(getName() + "-clone-" + entityIDToClone.toString()); setLocked(false); + setParentID(QUuid()); + setParentJointIndex(-1); setLifetime(getCloneLifetime()); setDynamic(getCloneDynamic()); setClientOnly(getCloneAvatarEntity()); diff --git a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js index f528c6f80f..a8de76aebd 100644 --- a/scripts/system/controllers/controllerModules/nearActionGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearActionGrabEntity.js @@ -174,10 +174,12 @@ Script.include("/~/system/libraries/cloneEntityUtils.js"); Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); this.hapticTargetID = props.id; } - // if we've attempted to grab a child, roll up to the root of the tree - var groupRootProps = findGroupParent(controllerData, props); - if (entityIsGrabbable(groupRootProps)) { - return groupRootProps; + if (!entityIsCloneable(props)) { + // if we've attempted to grab a non-cloneable child, roll up to the root of the tree + var groupRootProps = findGroupParent(controllerData, props); + if (entityIsGrabbable(groupRootProps)) { + return groupRootProps; + } } return props; } diff --git a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js index a0a4608fbc..3089545dc1 100644 --- a/scripts/system/controllers/controllerModules/nearParentGrabEntity.js +++ b/scripts/system/controllers/controllerModules/nearParentGrabEntity.js @@ -268,10 +268,12 @@ Script.include("/~/system/libraries/controllers.js"); Controller.triggerHapticPulse(HAPTIC_PULSE_STRENGTH, HAPTIC_PULSE_DURATION, this.hand); this.hapticTargetID = props.id; } - // if we've attempted to grab a child, roll up to the root of the tree - var groupRootProps = findGroupParent(controllerData, props); - if (entityIsGrabbable(groupRootProps)) { - return groupRootProps; + if (!entityIsCloneable(props)) { + // if we've attempted to grab a non-cloneable child, roll up to the root of the tree + var groupRootProps = findGroupParent(controllerData, props); + if (entityIsGrabbable(groupRootProps)) { + return groupRootProps; + } } return props; }