summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
Diffstat (limited to 'scene')
-rw-r--r--scene/main/node.cpp17
-rw-r--r--scene/main/node.h1
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 */