From 031b3985b03bf120fff8cb1822d0db34f77a94fa Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Wed, 18 Nov 2020 23:14:34 -0500 Subject: [PATCH 1/5] Fix for Issue 869 This excludes the local and avatar entities from what is returns by Entities.getChildrenIDs to avoid the selection tools of the Zone entities to be considered as Children of it. This was necessary for the display of the hierarchy status, but also for the "Add Children to Selection". --- scripts/system/create/edit.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 099cb94988b..a8b829c5518 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -2908,7 +2908,7 @@ function zoneSortOrder(a, b) { function getParentState(id) { var state = "NONE"; var properties = Entities.getEntityProperties(id, ["parentID"]); - var children = Entities.getChildrenIDs(id); + var children = getDomainOnlyChildrenIDs(id); if (properties.parentID !== Uuid.NULL) { if (children.length > 0) { state = "PARENT_CHILDREN"; @@ -2923,4 +2923,17 @@ function getParentState(id) { return state; } +function getDomainOnlyChildrenIDs(id) { + var allChildren = Entities.getChildrenIDs(id); + var domainOnlyChildren = []; + var properties; + for (var i = 0; i < allChildren.length; i++) { + properties = Entities.getEntityProperties(allChildren[i], ["entityHostType"]); + if (properties.entityHostType == "domain") { + domainOnlyChildren.push(allChildren[i]); + } + } + return domainOnlyChildren; +} + }()); // END LOCAL_SCOPE From 22abf1c2c47aca06e7637b4a3aea48b9b4e26115 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Wed, 18 Nov 2020 23:15:23 -0500 Subject: [PATCH 2/5] Fix for Issue 869 This excludes the local and avatar entities from what is returns by Entities.getChildrenIDs to avoid the selection tools of the Zone entities to be considered as Children of it. This was necessary for the display of the hierarchy status, but also for the "Add Children to Selection". --- .../create/entitySelectionTool/entitySelectionTool.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/system/create/entitySelectionTool/entitySelectionTool.js b/scripts/system/create/entitySelectionTool/entitySelectionTool.js index 71edbde7657..f9a30ef6a53 100644 --- a/scripts/system/create/entitySelectionTool/entitySelectionTool.js +++ b/scripts/system/create/entitySelectionTool/entitySelectionTool.js @@ -724,12 +724,12 @@ SelectionManager = (function() { that.addChildrenToSelection = function() { if (that.hasSelection()) { for (var i = 0; i < that.selections.length; i++) { - var childrenIDs = Entities.getChildrenIDs(that.selections[i]); - var collectNewChildren; + var childrenIDs = getDomainOnlyChildrenIDs(that.selections[i]); + var collectNewChildren; var j; var k = 0; do { - collectNewChildren = Entities.getChildrenIDs(childrenIDs[k]); + collectNewChildren = getDomainOnlyChildrenIDs(childrenIDs[k]); if (collectNewChildren.length > 0) { for (j = 0; j < collectNewChildren.length; j++) { childrenIDs.push(collectNewChildren[j]); @@ -746,7 +746,7 @@ SelectionManager = (function() { that._update(true, this); } else { audioFeedback.rejection(); - Window.notifyEditError("You have nothing selected."); + Window.notifyEditError("You have nothing selected."); } }; @@ -832,7 +832,7 @@ SelectionDisplay = (function() { const BOUNDING_EDGE_OFFSET = 0.5; - const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 }; + const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 }; const CTRL_KEY_CODE = 16777249; From 00575ae8f88c40f67679277cbdbe6fc8cc8f5996 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:43:12 -0500 Subject: [PATCH 3/5] Excluding EntityShapeVisualizer from Children list Excluding EntityShapeVisualizer from Children list Now a name is given to the EntityShape of the EntityShapeVisualizer (used to display the zone) so we can now exclude them from the children list when it's time to figure if there are children for an entity. (This is a better approach than excluding al the local entities) The name has been used because it gives better results than trying to use the id map that arrive always too late. The name is unique for a session, it includes a UUID. --- scripts/system/create/edit.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index a8b829c5518..3c6f43d3a15 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -117,8 +117,10 @@ var gridTool = new GridTool({ }); gridTool.setVisible(false); +var entityShapeVisualizerSessionName = "SHAPE_VISUALIZER_" + Uuid.generate(); + var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js'); -var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"]); +var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName); var entityListTool = new EntityListTool(shouldUseEditTabletApp); @@ -2925,15 +2927,15 @@ function getParentState(id) { function getDomainOnlyChildrenIDs(id) { var allChildren = Entities.getChildrenIDs(id); - var domainOnlyChildren = []; + var realChildren = []; var properties; for (var i = 0; i < allChildren.length; i++) { - properties = Entities.getEntityProperties(allChildren[i], ["entityHostType"]); - if (properties.entityHostType == "domain") { - domainOnlyChildren.push(allChildren[i]); + properties = Entities.getEntityProperties(allChildren[i], ["name"]); + if (properties.name !== entityShapeVisualizerSessionName && properties.name !== undefined) { + realChildren.push(allChildren[i]); } } - return domainOnlyChildren; + return realChildren; } }()); // END LOCAL_SCOPE From b633bc4a164ecfa44ce7b063b5bf2e676d2b4672 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 15:44:15 -0500 Subject: [PATCH 4/5] Excluding EntityShapeVisualizer from Children list Excluding EntityShapeVisualizer from Children list Now a name is given to the EntityShape of the EntityShapeVisualizer (used to display the zone) so we can now exclude them from the children list when it's time to figure if there are children for an entity. (This is a better approach than excluding al the local entities) The name has been used because it gives better results than trying to use the id map that arrive always too late. The name is unique for a session, it includes a UUID. --- .../system/create/modules/entityShapeVisualizer.js | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/scripts/system/create/modules/entityShapeVisualizer.js b/scripts/system/create/modules/entityShapeVisualizer.js index dbf09a1cb72..45cf68fdb52 100644 --- a/scripts/system/create/modules/entityShapeVisualizer.js +++ b/scripts/system/create/modules/entityShapeVisualizer.js @@ -116,12 +116,14 @@ function deepCopy(v) { return JSON.parse(JSON.stringify(v)); } -function EntityShape(entityID) { +function EntityShape(entityID, entityShapeVisualizerSessionName) { this.entityID = entityID; + this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName; + var propertiesForType = getEntityShapePropertiesForType(Entities.getEntityProperties(entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES)); this.previousPropertiesForType = propertiesForType; - + this.initialize(propertiesForType); } @@ -130,6 +132,7 @@ EntityShape.prototype = { // Create new instance of JS object: var overlayProperties = deepCopy(properties); + overlayProperties.name = this.entityShapeVisualizerSessionName; overlayProperties.localPosition = Vec3.ZERO; overlayProperties.localRotation = Quat.IDENTITY; overlayProperties.canCastShadows = false; @@ -172,11 +175,11 @@ EntityShape.prototype = { } }; -function EntityShapeVisualizer(visualizedTypes) { +function EntityShapeVisualizer(visualizedTypes, entityShapeVisualizerSessionName) { this.acceptedEntities = []; this.ignoredEntities = []; this.entityShapes = {}; - + this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName; this.visualizedTypes = visualizedTypes; } @@ -185,7 +188,7 @@ EntityShapeVisualizer.prototype = { if (this.entityShapes[entityID]) { return; } - this.entityShapes[entityID] = new EntityShape(entityID); + this.entityShapes[entityID] = new EntityShape(entityID, this.entityShapeVisualizerSessionName); }, updateEntity: function(entityID) { From 343ded8c6f9cea43e1570e31d50c531ee18307e8 Mon Sep 17 00:00:00 2001 From: Alezia Kurdis <60075796+AleziaKurdis@users.noreply.github.com> Date: Sat, 21 Nov 2020 22:02:49 -0500 Subject: [PATCH 5/5] Minor code adjustments Minor code adjustments --- scripts/system/create/edit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/system/create/edit.js b/scripts/system/create/edit.js index 3c6f43d3a15..bc7afd8dc3f 100644 --- a/scripts/system/create/edit.js +++ b/scripts/system/create/edit.js @@ -2931,7 +2931,7 @@ function getDomainOnlyChildrenIDs(id) { var properties; for (var i = 0; i < allChildren.length; i++) { properties = Entities.getEntityProperties(allChildren[i], ["name"]); - if (properties.name !== entityShapeVisualizerSessionName && properties.name !== undefined) { + if (properties.name !== undefined && properties.name !== entityShapeVisualizerSessionName) { realChildren.push(allChildren[i]); } }