From 839c3bd1bff722974d80f1d799916e558d2a10eb Mon Sep 17 00:00:00 2001 From: Emmanuel Barroga Date: Thu, 4 Jul 2019 06:41:21 -0700 Subject: [PATCH] Resolves Issue #30271 Reparent selection without flattening When reparenting a multi-selection via drag and drop, the hierarchy was flattened. This change resolves that issue. --- editor/scene_tree_dock.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp index 442de08ffa0..f17476d49b1 100644 --- a/editor/scene_tree_dock.cpp +++ b/editor/scene_tree_dock.cpp @@ -2225,23 +2225,20 @@ void SceneTreeDock::_script_dropped(String p_file, NodePath p_to) { void SceneTreeDock::_nodes_dragged(Array p_nodes, NodePath p_to, int p_type) { - Vector nodes; - Node *to_node; + List selection = editor_selection->get_selected_node_list(); - for (int i = 0; i < p_nodes.size(); i++) { - Node *n = get_node((p_nodes[i])); - if (n) { - nodes.push_back(n); - } - } + if (selection.empty()) + return; //nothing to reparent - if (nodes.size() == 0) - return; - - to_node = get_node(p_to); + Node *to_node = get_node(p_to); if (!to_node) return; + Vector nodes; + for (List::Element *E = selection.front(); E; E = E->next()) { + nodes.push_back(E->get()); + } + int to_pos = -1; _normalize_drop(to_node, to_pos, p_type);