summaryrefslogtreecommitdiffstats
path: root/editor/scene_tree_dock.cpp
diff options
context:
space:
mode:
authorSofox <sofoxx@gmail.com>2023-12-15 19:34:32 +0000
committerSofox <sofoxx@gmail.com>2023-12-22 15:20:08 +0000
commited648799aed3c2637e80415c4dcacdb896b350d4 (patch)
tree96e3246e260dc6005f2c569d30cc96aea1d254a7 /editor/scene_tree_dock.cpp
parentf8a2a9193662b2e8c1d04d65e647399dee94f31e (diff)
downloadredot-engine-ed648799aed3c2637e80415c4dcacdb896b350d4.tar.gz
Fixed duplicating nodes at different depths in SceneTreeDock
Diffstat (limited to 'editor/scene_tree_dock.cpp')
-rw-r--r--editor/scene_tree_dock.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/editor/scene_tree_dock.cpp b/editor/scene_tree_dock.cpp
index c12e53fc88..0f0e6eb6b4 100644
--- a/editor/scene_tree_dock.cpp
+++ b/editor/scene_tree_dock.cpp
@@ -713,7 +713,14 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
selection.sort_custom<Node::Comparator>();
- Node *add_below_node = selection.back()->get();
+ HashMap<const Node *, Node *> add_below_map;
+
+ for (List<Node *>::Element *E = selection.back(); E; E = E->prev()) {
+ Node *node = E->get();
+ if (!add_below_map.has(node->get_parent())) {
+ add_below_map.insert(node->get_parent(), node);
+ }
+ }
for (Node *node : selection) {
Node *parent = node->get_parent();
@@ -740,7 +747,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
dup->set_name(parent->validate_child_name(dup));
- undo_redo->add_do_method(add_below_node, "add_sibling", dup, true);
+ undo_redo->add_do_method(add_below_map[parent], "add_sibling", dup, true);
for (Node *F : owned) {
if (!duplimap.has(F)) {
@@ -759,7 +766,7 @@ void SceneTreeDock::_tool_selected(int p_tool, bool p_confirm_override) {
undo_redo->add_do_method(ed, "live_debug_duplicate_node", edited_scene->get_path_to(node), dup->get_name());
undo_redo->add_undo_method(ed, "live_debug_remove_node", NodePath(String(edited_scene->get_path_to(parent)).path_join(dup->get_name())));
- add_below_node = dup;
+ add_below_map[parent] = dup;
}
undo_redo->commit_action();