diff options
author | hilfazer <az13337@gmail.com> | 2021-02-21 09:19:48 +0100 |
---|---|---|
committer | hilfazer <az13337@gmail.com> | 2021-02-21 11:58:31 +0100 |
commit | 442e550114d3de9648b5b5788a174b876c32eb90 (patch) | |
tree | 0e99d7368c8a1983b130277f3e5b2f4e46fbb57f /scene/main | |
parent | 3bb628d8fe26abad258a222a5e22b644e2b73a01 (diff) |
Prevent selecting hidden nodes in 3D and Canvas Item editors
Diffstat (limited to 'scene/main')
-rw-r--r-- | scene/main/node.cpp | 17 | ||||
-rw-r--r-- | scene/main/node.h | 1 |
2 files changed, 18 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; } diff --git a/scene/main/node.h b/scene/main/node.h index b3979993e0..249a0ff86e 100644 --- a/scene/main/node.h +++ b/scene/main/node.h @@ -330,6 +330,7 @@ public: void set_editable_instance(Node *p_node, bool p_editable); bool is_editable_instance(const Node *p_node) const; + Node *get_deepest_editable_node(Node *p_start_node) const; /* NOTIFICATIONS */ |