godotengine / godot

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

Irreversible broken `Skeleton3D` in editable children but new instances looks fine #91211

Open ydeltastar opened 5 months ago

ydeltastar commented 5 months ago

Tested versions

v4.3.dev.custom_build [c7f56d327] Test with https://github.com/godotengine/godot/pull/91122 to avoid crashes while reimporting.

System information

Windows 10 - Forward+

Issue description

Skeleton3D can become irreversibly broken throughout the back-and-forth process of modifying the source model and reimporting when using Editable Children.

Probably, the issue happens when bone hierarch changes and the glTF reimports. The button on the scene toolbar Skeleton3D > Reset All Bone Poses doesn't fix it. There are no properties in the inspector that I can modify or reset to fix it either.

New instances of the glTF look right.

image

Steps to reproduce

Minimal reproduction project (MRP)

broken-skeleton.zip

ydeltastar commented 5 months ago

By the way, test with https://github.com/godotengine/godot/pull/91122 to avoid crashes while reimporting. I added it to the description.

ydeltastar commented 5 months ago

https://github.com/godotengine/godot/pull/91122 was required to reimport without crashes but it doesn't fix this issue.

fire commented 2 months ago

Some fixes were done to the reload scene system, I'm not sure how it interacts with the bug.

ydeltastar commented 2 months ago

Tested with latest. The issue still happens.

SaracenOne commented 1 month ago

Okay, I'm looking into this now. It seems to be a complex edge case based around unique qualities of the skeleton node in relation to how the scene importer attempts to save and restore state. It seems that the wonky bone hierarchy has become embedded in the actor_x.tscn in the same fashion as any other modifiable property in scene. One key difference with the skeleton inspector is none of the direct bone properties are revertable (they probably should be though if those changes are serializable). This problem kind of has different levels to it though. By the rules of the system, those bone hierarchy changes actually SHOULD attempt to preserve these changes, so the behaviour observed when reimporting with the actor_x scene open seems the most correct.

Why these changes occur in the first place in another matter though and will require further investigation. May take some time and may require a bunch of special case code when dealing with armatures. It's supposedly just a natural occurance of modifying the base model with editable children open, right? In which case, this is all likely a byproduct of Skeleton3D all being contained as editable node properties when it probably should have been data and subject to similar safety checks I implemented for other imported types to prevent edits and corruption.

SaracenOne commented 1 month ago

@ydeltastar The two PRs I've referenced do attempt to address two aspects I've observed in with this issue: The change to the reimport behaviour should resolve the reimported model appearing demangled (but actually is still mangeld in game or upon reloading the scene), and the reset support added to the skeleton editor will at the very least give the user a means to easily demangle a model without having to manually edit a scene file in a text editor.

The only issue that now remains is the underlying cause of the mangling which is mentioned as when bone hierarch changes and the glTF reimports. Could more information be provided about this? Ideally, from what I understand, the system shouldn't mangle the the skeleton, even with editable children is enabled unless the bone hierarchy was modified manually. The changes to the reimport system might fix this, but I require more information.

ydeltastar commented 1 month ago

@SaracenOne I'm not sure how it happens. My only guess is that when I reparent bones. For example, the original skeleton was imported with an upper arm and a bottom arm. Then if I add an elbow bone between them and other similar edits, the skeleton could break when reimported.

As long as I iterated between Blender and Godot, characters eventually got broken when using this multiple editable children scene setup. Now I avoid this scene setup and it hasn't happened since.