Skip to content

Commit

Permalink
Merge pull request #88497 from Sauermann/fix-owner-import
Browse files Browse the repository at this point in the history
Fix owner when importing meshes
  • Loading branch information
akien-mga committed Feb 27, 2024
2 parents f80cdeb + c58607c commit 3dca3c2
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions scene/main/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2958,17 +2958,24 @@ void Node::replace_by(Node *p_node, bool p_keep_groups) {
remove_child(child);
if (!child->is_owned_by_parent()) {
// 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);
child->set_owner(child_owner);
}
}

p_node->set_owner(owner);
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) {
E->set_owner(owner);
if (E->data.owner != owner) {
E->set_owner(owner);
}
}

p_node->set_scene_file_path(get_scene_file_path());
Expand Down

0 comments on commit 3dca3c2

Please sign in to comment.