From 442e550114d3de9648b5b5788a174b876c32eb90 Mon Sep 17 00:00:00 2001 From: hilfazer Date: Sun, 21 Feb 2021 09:19:48 +0100 Subject: Prevent selecting hidden nodes in 3D and Canvas Item editors --- scene/main/node.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'scene/main/node.cpp') diff --git a/scene/main/node.cpp b/scene/main/node.cpp index f6a0f5a6c0..f0c562260f 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1966,6 +1966,23 @@ bool Node::is_editable_instance(const Node *p_node) const { return p_node->data.editable_instance; } +Node *Node::get_deepest_editable_node(Node *p_start_node) const { + ERR_FAIL_NULL_V(p_start_node, nullptr); + ERR_FAIL_COND_V(!is_a_parent_of(p_start_node), nullptr); + + Node const *iterated_item = p_start_node; + Node *node = p_start_node; + + while (iterated_item->get_owner() && iterated_item->get_owner() != this) { + if (!is_editable_instance(iterated_item->get_owner())) + node = iterated_item->get_owner(); + + iterated_item = iterated_item->get_owner(); + } + + return node; +} + void Node::set_scene_instance_state(const Ref &p_state) { data.instance_state = p_state; } -- cgit v1.2.3