diff options
| author | Juan Linietsky | 2016-07-19 20:04:06 -0300 |
|---|---|---|
| committer | Juan Linietsky | 2016-07-19 20:20:28 -0300 |
| commit | 9de33e18f14f78165754e97ed0f7827b2e50d560 (patch) | |
| tree | 230bc432ee826a283686b7cb90cf872b9f7ec0fd /scene/main/node.cpp | |
| parent | 4bf16542720a431599127ec81323822786fa3de2 (diff) | |
| download | godot-9de33e18f14f78165754e97ed0f7827b2e50d560.tar.gz godot-9de33e18f14f78165754e97ed0f7827b2e50d560.tar.zst godot-9de33e18f14f78165754e97ed0f7827b2e50d560.zip | |
WIP bugfix for existing connections
Diffstat (limited to 'scene/main/node.cpp')
| -rw-r--r-- | scene/main/node.cpp | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 55106f5ee..a53c19d2e 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -1121,6 +1121,38 @@ Node *Node::get_owner() const { return data.owner; } + +Node* Node::find_common_parent_with(const Node *p_node) const { + + if (this==p_node) + return const_cast<Node*>(p_node); + + Set<const Node*> visited; + + const Node *n=this; + + while(n) { + + visited.insert(n); + n=n->data.parent; + } + + const Node *common_parent=p_node; + + while(common_parent) { + + if (visited.has(common_parent)) + break; + common_parent=common_parent->data.parent; + } + + if (!common_parent) + return NULL; + + return const_cast<Node*>(common_parent); + +} + NodePath Node::get_path_to(const Node *p_node) const { ERR_FAIL_NULL_V(p_node,NodePath()); |
