godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
91.16k stars 21.19k forks source link

`get_child` error when duplicating .GLB model nodes with animations #96246

Open retexcraft opened 2 months ago

retexcraft commented 2 months ago

Tested versions

reproducible in 4.3 stable not reproducible in 4.2 stable not tested in other builds

System information

Godot v4.3.stable - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 1070 (NVIDIA; 31.0.15.5161) - Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz (8 Threads)

Issue description

when attempting to duplicate() a GLB node with animations under its animation player it is unable to understand the children and produces this error

E 0:00:00:0862   node_3d.gd:5 @ _ready(): Index p_index = 1 is out of bounds ((int)data.children_cache.size() = 1).
  <C++ Source>   scene/main/node.cpp:1688 @ get_child()
  <Stack Trace>  node_3d.gd:5 @ _ready()

that also causes the next error in the debugger

E 0:00:00:0863   node_3d.gd:5 @ _ready(): Child node disappeared while duplicating.
  <C++ Error>    Parameter "copy_child" is null.
  <C++ Source>   scene/main/node.cpp:2926 @ _duplicate_properties()
  <Stack Trace>  node_3d.gd:5 @ _ready()

Steps to reproduce

import a .GLB model with a animation into a scene and call the duplicate function on it

Minimal reproduction project (MRP)

glb-duplicate-test.zip

matheusmdx commented 2 months ago

Bisecting points to #91677 as the culprit, @KoBeWi

image


This looks not related to animation, but a problem with internal nodes, while duplicating this part discards the Skeleton3D internal node for the new node:

https://github.com/godotengine/godot/blob/61598c5c88d95b96811d386cb20d714c35f4c6d7/scene/main/node.cpp#L2715-L2722


Which results in a difference in child count here, p_original has two childs (the internal bone node and the cube) while p_copy has one (the cube):

https://github.com/godotengine/godot/blob/61598c5c88d95b96811d386cb20d714c35f4c6d7/scene/main/node.cpp#L2954-L2958

image

image


Commenting line 2720 preserves the internal node and stop the error but probably is not the correct fix, but at least give some idea what's going on

KoBeWi commented 2 months ago

Bisecting points to https://github.com/godotengine/godot/pull/91677 as the culprit

91677 only added a null check. The MRP crashes otherwise.

matheusmdx commented 2 months ago

Bisecting points to #91677 as the culprit

91677 only added a null check. The MRP crashes otherwise.

image