Skip to content

Commit 60e59ab

Browse files
authored
Merge pull request #874 from AleziaKurdis/CreateApp_Issue869
Fix new Zones appearing as parent of a ghost child
2 parents 0157d5f + 343ded8 commit 60e59ab

File tree

3 files changed

+30
-12
lines changed

3 files changed

+30
-12
lines changed

scripts/system/create/edit.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,8 +117,10 @@ var gridTool = new GridTool({
117117
});
118118
gridTool.setVisible(false);
119119

120+
var entityShapeVisualizerSessionName = "SHAPE_VISUALIZER_" + Uuid.generate();
121+
120122
var EntityShapeVisualizer = Script.require('./modules/entityShapeVisualizer.js');
121-
var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"]);
123+
var entityShapeVisualizer = new EntityShapeVisualizer(["Zone"], entityShapeVisualizerSessionName);
122124

123125
var entityListTool = new EntityListTool(shouldUseEditTabletApp);
124126

@@ -2908,7 +2910,7 @@ function zoneSortOrder(a, b) {
29082910
function getParentState(id) {
29092911
var state = "NONE";
29102912
var properties = Entities.getEntityProperties(id, ["parentID"]);
2911-
var children = Entities.getChildrenIDs(id);
2913+
var children = getDomainOnlyChildrenIDs(id);
29122914
if (properties.parentID !== Uuid.NULL) {
29132915
if (children.length > 0) {
29142916
state = "PARENT_CHILDREN";
@@ -2923,4 +2925,17 @@ function getParentState(id) {
29232925
return state;
29242926
}
29252927

2928+
function getDomainOnlyChildrenIDs(id) {
2929+
var allChildren = Entities.getChildrenIDs(id);
2930+
var realChildren = [];
2931+
var properties;
2932+
for (var i = 0; i < allChildren.length; i++) {
2933+
properties = Entities.getEntityProperties(allChildren[i], ["name"]);
2934+
if (properties.name !== undefined && properties.name !== entityShapeVisualizerSessionName) {
2935+
realChildren.push(allChildren[i]);
2936+
}
2937+
}
2938+
return realChildren;
2939+
}
2940+
29262941
}()); // END LOCAL_SCOPE

scripts/system/create/entitySelectionTool/entitySelectionTool.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,12 +724,12 @@ SelectionManager = (function() {
724724
that.addChildrenToSelection = function() {
725725
if (that.hasSelection()) {
726726
for (var i = 0; i < that.selections.length; i++) {
727-
var childrenIDs = Entities.getChildrenIDs(that.selections[i]);
728-
var collectNewChildren;
727+
var childrenIDs = getDomainOnlyChildrenIDs(that.selections[i]);
728+
var collectNewChildren;
729729
var j;
730730
var k = 0;
731731
do {
732-
collectNewChildren = Entities.getChildrenIDs(childrenIDs[k]);
732+
collectNewChildren = getDomainOnlyChildrenIDs(childrenIDs[k]);
733733
if (collectNewChildren.length > 0) {
734734
for (j = 0; j < collectNewChildren.length; j++) {
735735
childrenIDs.push(collectNewChildren[j]);
@@ -746,7 +746,7 @@ SelectionManager = (function() {
746746
that._update(true, this);
747747
} else {
748748
audioFeedback.rejection();
749-
Window.notifyEditError("You have nothing selected.");
749+
Window.notifyEditError("You have nothing selected.");
750750
}
751751
};
752752

@@ -832,7 +832,7 @@ SelectionDisplay = (function() {
832832

833833
const BOUNDING_EDGE_OFFSET = 0.5;
834834

835-
const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 };
835+
const DUPLICATOR_OFFSET = { x: 0.6, y: 0, z: 0.6 };
836836

837837
const CTRL_KEY_CODE = 16777249;
838838

scripts/system/create/modules/entityShapeVisualizer.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,14 @@ function deepCopy(v) {
116116
return JSON.parse(JSON.stringify(v));
117117
}
118118

119-
function EntityShape(entityID) {
119+
function EntityShape(entityID, entityShapeVisualizerSessionName) {
120120
this.entityID = entityID;
121+
this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName;
122+
121123
var propertiesForType = getEntityShapePropertiesForType(Entities.getEntityProperties(entityID, REQUESTED_ENTITY_SHAPE_PROPERTIES));
122124

123125
this.previousPropertiesForType = propertiesForType;
124-
126+
125127
this.initialize(propertiesForType);
126128
}
127129

@@ -130,6 +132,7 @@ EntityShape.prototype = {
130132
// Create new instance of JS object:
131133
var overlayProperties = deepCopy(properties);
132134

135+
overlayProperties.name = this.entityShapeVisualizerSessionName;
133136
overlayProperties.localPosition = Vec3.ZERO;
134137
overlayProperties.localRotation = Quat.IDENTITY;
135138
overlayProperties.canCastShadows = false;
@@ -172,11 +175,11 @@ EntityShape.prototype = {
172175
}
173176
};
174177

175-
function EntityShapeVisualizer(visualizedTypes) {
178+
function EntityShapeVisualizer(visualizedTypes, entityShapeVisualizerSessionName) {
176179
this.acceptedEntities = [];
177180
this.ignoredEntities = [];
178181
this.entityShapes = {};
179-
182+
this.entityShapeVisualizerSessionName = entityShapeVisualizerSessionName;
180183
this.visualizedTypes = visualizedTypes;
181184
}
182185

@@ -185,7 +188,7 @@ EntityShapeVisualizer.prototype = {
185188
if (this.entityShapes[entityID]) {
186189
return;
187190
}
188-
this.entityShapes[entityID] = new EntityShape(entityID);
191+
this.entityShapes[entityID] = new EntityShape(entityID, this.entityShapeVisualizerSessionName);
189192

190193
},
191194
updateEntity: function(entityID) {

0 commit comments

Comments
 (0)