summaryrefslogtreecommitdiff
path: root/scene/main/node.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <remi@verschelde.fr>2021-02-21 14:39:34 +0100
committerGitHub <noreply@github.com>2021-02-21 14:39:34 +0100
commit6fed9eb28788efbf9f4dd589b7742f24a6afbfd7 (patch)
treeb4d8816d07b9c257bca2da204ad7433cb5987f37 /scene/main/node.cpp
parentff8a1fdc19842aaa52a23e303425f5a703e8317b (diff)
parent442e550114d3de9648b5b5788a174b876c32eb90 (diff)
Merge pull request #46279 from hilfazer/prevent_select_noneditable_nodes_in_editors
Prevent selecting hidden nodes in 3D and Canvas Item editors
Diffstat (limited to 'scene/main/node.cpp')
-rw-r--r--scene/main/node.cpp17
1 files changed, 17 insertions, 0 deletions
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<SceneState> &p_state) {
data.instance_state = p_state;
}