Fix duplicating sub-scene may get two copies of internal node

Previously, internal node might be mistaken for `hidden_root` and be duplicated again.
Exclude those internal nodes to avoid this case, unless the owner is set intentionally.

(cherry picked from commit f19c419126)
This commit is contained in:
风青山 2023-11-13 09:44:07 +08:00 committed by Rémi Verschelde
parent 3553d33708
commit 261129496c
No known key found for this signature in database
GPG Key ID: C3336907360768E1

View File

@ -2510,6 +2510,11 @@ Node *Node::_duplicate(int p_flags, HashMap<const Node *, Node *> *r_duplimap) c
for (List<const Node *>::Element *N = node_tree.front(); N; N = N->next()) {
for (int i = 0; i < N->get()->get_child_count(); ++i) {
Node *descendant = N->get()->get_child(i);
if (!descendant->get_owner()) {
continue; // Internal nodes or nodes added by scripts.
}
// Skip nodes not really belonging to the instantiated hierarchy; they'll be processed normally later
// but remember non-instantiated nodes that are hidden below instantiated ones
if (!instance_roots.has(descendant->get_owner())) {