mirror of
https://github.com/godotengine/godot.git
synced 2024-11-10 14:12:51 +00:00
Fix owner when importing meshes
Handle the case correctly, that a child of a replaced node has
as owner an ancestor of the replaced node.
(cherry picked from commit c58607c32f
)
This commit is contained in:
parent
3d4c2fa7da
commit
17e50c629c
@ -2829,17 +2829,24 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) {
|
|||||||
remove_child(child);
|
remove_child(child);
|
||||||
if (!child->is_owned_by_parent()) {
|
if (!child->is_owned_by_parent()) {
|
||||||
// add the custom children to the p_node
|
// add the custom children to the p_node
|
||||||
|
Node *child_owner = child->get_owner() == this ? p_node : child->get_owner();
|
||||||
|
child->set_owner(nullptr);
|
||||||
p_node->add_child(child);
|
p_node->add_child(child);
|
||||||
|
child->set_owner(child_owner);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p_node->set_owner(owner);
|
p_node->set_owner(owner);
|
||||||
for (Node *E : owned) {
|
for (Node *E : owned) {
|
||||||
E->set_owner(p_node);
|
if (E->data.owner != p_node) {
|
||||||
|
E->set_owner(p_node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Node *E : owned_by_owner) {
|
for (Node *E : owned_by_owner) {
|
||||||
E->set_owner(owner);
|
if (E->data.owner != owner) {
|
||||||
|
E->set_owner(owner);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p_node->set_scene_file_path(get_scene_file_path());
|
p_node->set_scene_file_path(get_scene_file_path());
|
||||||
|
Loading…
Reference in New Issue
Block a user