diff options
author | Tomasz Chabora <kobewi4e@gmail.com> | 2019-09-22 12:44:59 +0200 |
---|---|---|
committer | Tomasz Chabora <kobewi4e@gmail.com> | 2019-09-22 12:44:59 +0200 |
commit | 48ca6ec657630983843bb104ab31a842c15b435b (patch) | |
tree | bd11c7320b98ddc2e6f3a81d79451140d9cae2a9 | |
parent | 2e065d8ad07bb20fede0d0c0b2d33d6628033024 (diff) |
Perform reparent if position changes
-rw-r--r-- | editor/scene_tree_dock.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index e45b08c992..2ddf1f7056 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -1552,18 +1552,20 @@ void SceneTreeDock::_do_reparent(Node *p_new_parent, int p_position_in_parent, V if (p_nodes.size() == 0) return; // Nothing to reparent. - bool same_parent = true; + p_nodes.sort_custom<Node::Comparator>(); //Makes result reliable. + + bool no_change = true; for (int ni = 0; ni < p_nodes.size(); ni++) { if (p_nodes[ni] == p_new_parent) return; // Attempt to reparent to itself. - if (p_nodes[ni]->get_parent() != p_new_parent) - same_parent = false; + if (p_nodes[ni]->get_parent() != p_new_parent || p_position_in_parent + ni != p_nodes[ni]->get_position_in_parent()) + no_change = false; } - if (same_parent) - return; // No new parent changes. + if (no_change) + return; // Position and parent didn't change. Node *validate = new_parent; while (validate) { |