godotengine / godot

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

3D Armature with BoneAttachment Glitches on Reimport #82466

Closed slumberface closed 12 months ago

slumberface commented 1 year ago

Godot version

4.1.1

System information

Windows 10 - Godot v4.1.1 - Vulkan(Forward+) - dedicated

Issue description

If a model with an armature AND with direct object-to-bone parenting (imported as BoneAttachment3D in Godot) is changed in blender and reimported, it can break instances of the model's armature under specific circumstances.

Use Cases: A character is rigged with an armature using vertex weights, except for a weapon parented to the hand bone, or a hat parented to the head bone.

Of Note:

Before: image

After another BoneAttachement3D is added over head: image

Steps to reproduce

Step 1: Import model to Godot. The model is then dragged into a scene AND "Editable Children" is toggled. If a model is turned into a "new inherited scene", the bug will occur without needing to toggle "Editable Children".

Step 2: In Blender, add another object that is parented directly to a bone. Export to Godot, overwriting the previous version. image image

Step 3: Upon importing, instances of the armature within scenes will bug out. Some bones will now be oriented in erroneous directions, and some previously existing BoneAttachement3Ds may no longer have the correct "Bone Idx" (1 value off if the new object precedes it in the hierarchy).

For simple reproduction, a project zip has been included which contains a README with instructions and models already setup to reproduce the bug. You will need Blender 3.6 to reproduce the bug. This bug has been reproduced with the following file types: .fbx, .gltf, .blend. For the sake of unified export options, this reproduction uses .blend

Minimal reproduction project

Bug Report Bone Attachement 3d.zip

bitsawer commented 1 year ago

Also tested on current master (545d1c0adbf340310e1531710eb31bd5267704d5), the result seems also broken but in a slightly different way. Changes might be influenced by https://github.com/godotengine/godot/pull/81695 or something else. Almost looks like many left side bones of the model are more messed up for some reason, right side seems to match the new pose a bit better, Also possibly related: https://github.com/godotengine/godot/issues/64512

bones

SaracenOne commented 1 year ago

Hmm, I'm guessing this is a consequence of the newer dynamic reimport system. When reloading, it copies all properties of all nodes from the previous scene to the new one. This should be fine for the bone names even if the structure of the skeleton changes, but since the idx is generated programmatically and is a still a front-facing property, if this is getting overwritten and not being properly refreshed, I could see how it might cause a bug like this. Will investigate.

SaracenOne commented 1 year ago

Okay, when I wrote the reimport system, I added special NOTIFICATION_NODE_RECACHE_REQUESTED for instances like this. If I make the BoneAttachments respond to this notification and rebind themselves, this should hopefully fix this bug.

SaracenOne commented 1 year ago

Nope, still investigating.

SaracenOne commented 1 year ago

Okay, forcing the bone poses to reset seems to fix it.