Merge pull request #12770 from sethalves/pr12769-for-rc66

Fix move after import
This commit is contained in:
John Conklin II 2018-04-03 13:41:56 -07:00 committed by GitHub
commit 5151041e4a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1618,8 +1618,18 @@ SelectionDisplay = (function() {
grid.snapToGrid(Vec3.sum(cornerPosition, vector), constrainMajorOnly), grid.snapToGrid(Vec3.sum(cornerPosition, vector), constrainMajorOnly),
cornerPosition); cornerPosition);
for (var i = 0; i < SelectionManager.selections.length; i++) { // editing a parent will cause all the children to automatically follow along, so don't
var properties = SelectionManager.savedProperties[SelectionManager.selections[i]]; // edit any entity who has an ancestor in SelectionManager.selections
var toMove = SelectionManager.selections.filter(function (selection) {
if (SelectionManager.selections.indexOf(SelectionManager.savedProperties[selection].parentID) >= 0) {
return false; // a parent is also being moved, so don't issue an edit for this entity
} else {
return true;
}
});
for (var i = 0; i < toMove.length; i++) {
var properties = SelectionManager.savedProperties[toMove[i]];
if (!properties) { if (!properties) {
continue; continue;
} }
@ -1628,7 +1638,7 @@ SelectionDisplay = (function() {
y: 0, y: 0,
z: vector.z z: vector.z
}); });
Entities.editEntity(SelectionManager.selections[i], { Entities.editEntity(toMove[i], {
position: newPosition position: newPosition
}); });
@ -1727,9 +1737,19 @@ SelectionDisplay = (function() {
Vec3.print(" newIntersection:", newIntersection); Vec3.print(" newIntersection:", newIntersection);
Vec3.print(" vector:", vector); Vec3.print(" vector:", vector);
} }
for (var i = 0; i < SelectionManager.selections.length; i++) { // editing a parent will cause all the children to automatically follow along, so don't
var id = SelectionManager.selections[i]; // edit any entity who has an ancestor in SelectionManager.selections
var toMove = SelectionManager.selections.filter(function (selection) {
if (SelectionManager.selections.indexOf(SelectionManager.savedProperties[selection].parentID) >= 0) {
return false; // a parent is also being moved, so don't issue an edit for this entity
} else {
return true;
}
});
for (var i = 0; i < toMove.length; i++) {
var id = toMove[i];
var properties = SelectionManager.savedProperties[id]; var properties = SelectionManager.savedProperties[id];
var newPosition = Vec3.sum(properties.position, vector); var newPosition = Vec3.sum(properties.position, vector);
Entities.editEntity(id, { position: newPosition }); Entities.editEntity(id, { position: newPosition });
@ -2166,8 +2186,19 @@ SelectionDisplay = (function() {
// the selections center point. Otherwise, the rotation will be around the entities // the selections center point. Otherwise, the rotation will be around the entities
// registration point which does not need repositioning. // registration point which does not need repositioning.
var reposition = (SelectionManager.selections.length > 1); var reposition = (SelectionManager.selections.length > 1);
for (var i = 0; i < SelectionManager.selections.length; i++) {
var entityID = SelectionManager.selections[i]; // editing a parent will cause all the children to automatically follow along, so don't
// edit any entity who has an ancestor in SelectionManager.selections
var toRotate = SelectionManager.selections.filter(function (selection) {
if (SelectionManager.selections.indexOf(SelectionManager.savedProperties[selection].parentID) >= 0) {
return false; // a parent is also being moved, so don't issue an edit for this entity
} else {
return true;
}
});
for (var i = 0; i < toRotate.length; i++) {
var entityID = toRotate[i];
var initialProperties = SelectionManager.savedProperties[entityID]; var initialProperties = SelectionManager.savedProperties[entityID];
var newProperties = { var newProperties = {