WIP bugfix for existing connections

This commit is contained in:
Juan Linietsky 2016-07-19 20:04:06 -03:00
parent 4bf1654272
commit 9de33e18f1
4 changed files with 140 additions and 15 deletions

View file

@ -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());