-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Factorize bone attachment #98516
base: master
Are you sure you want to change the base?
Factorize bone attachment #98516
Conversation
6853538
to
beb3bab
Compare
beb3bab
to
d7e5466
Compare
I am worried that because the code isn't elegant it would be hard to fix the possible bugs in this. The node tree to skeleton tree is the most fragile part of the GLTFDocument code. Recall we had to divide one function into three methods to make verification possible. We'll have to run through the entire large suite of test cases in https://github.com/godotengine/godot-tests/tree/master/tests/gltf_skeleton_tests. Also the export and import verification |
@fire Tried to keep the changes small to discuss feasibility, can you point at what is inelegant in this implementation ? |
At the minimum, we’ll need a forward upgrade flag that enables by default but stays off for existing imports. An importer |
@fire Not sure how to do that but i'll search for feature implementing this kind of flag in the past. |
We tried an use_legacy_names option called #48058. Will try to find more details. It's been several years since we had to do that procedure. |
I added a legacy flag in import settings. |
05fc82e
to
4e764f0
Compare
4e764f0
to
045b7b1
Compare
modules/gltf/gltf_document.cpp
Outdated
@@ -5124,7 +5132,7 @@ BoneAttachment3D *GLTFDocument::_generate_bone_attachment(Ref<GLTFState> p_state | |||
Ref<GLTFNode> gltf_node = p_state->nodes[p_node_index]; | |||
Ref<GLTFNode> bone_node = p_state->nodes[p_bone_index]; | |||
BoneAttachment3D *bone_attachment = memnew(BoneAttachment3D); | |||
print_verbose("glTF: Creating bone attachment for: " + gltf_node->get_name()); | |||
print_verbose("glTF: Creating bone attachment for: " + _legacy_attachements_import ? gltf_node->get_name() : bone_node->get_name()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is causing the cicd to fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gonna remove the inline in next commit
@lyuma Do you remember how the old legacy system worked? |
I suspect this code also runs for FBX, hmm. |
Okay so the idea here is instead of trying to solve it for every case, it specifically addresses the case of bone attachments which are meshes, since AFAIK it is not possible to create these in Blender. Because it is a very specific fix, it is less likely to break one of the test cases, and with a setting, users can change it if it does. By the way, the option name misspells "attachments". Instead of calling it legacy, would a more specific name make sense the option determines if we should create bones for mesh nodes.
that's a good thing I think. I'm a bit cautious, but I know meshes inside a skeleton also being bones is a common complaint, and this doesn't change that much code. Clearly the tests need to pass.
i think the toplevel scene import options always get serialized, so it is possible to have a different default from what is initially set in the .import --- we need to make sure project settings import defaults are respected too |
@lyuma I tried to find a way to have different default value but could'nt get it to work. Right now i think it's not possible to have this kind of legacy flag. Not sure if the behavior of having mesh being bones is only linked to Blender. |
Some documentation was changed breaking the tests and we can't merge with broken tests. |
<member name="legacy_attachments_import" type="bool" setter="set_legacy_attachments_import" getter="get_legacy_attachments_import" default="true"> | ||
If [code]true[/code], use the legacy import method creating a bone and a [BoneAttachment3D] for each mesh parented to a bone. | ||
</member> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As @fire brought up, this is not exposed on GLTFDocument and should be removed.
<member name="legacy_attachments_import" type="bool" setter="set_legacy_attachments_import" getter="get_legacy_attachments_import" default="true"> | |
If [code]true[/code], use the legacy import method creating a bone and a [BoneAttachment3D] for each mesh parented to a bone. | |
</member> |
@@ -59,6 +59,9 @@ | |||
<member name="nodes/import_as_skeleton_bones" type="bool" setter="" getter="" default="false"> | |||
Treat all nodes in the imported scene as if they are bones within a single [Skeleton3D]. Can be used to guarantee that imported animations target skeleton bones rather than nodes. May also be used to assign the [code]"Root"[/code] bone in a [BoneMap]. See [url=$DOCS_URL/tutorials/assets_pipeline/retargeting_3d_skeletons.html]Retargeting 3D Skeletons[/url] for more information. | |||
</member> | |||
<member name="nodes/legacy_attachments_import" type="bool" setter="" getter="" default="true"> | |||
If [code]true[/code], use the legacy import method creating a bone and a [BoneAttachment3D] for each mesh parented to a bone. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If [code]true[/code], use the legacy import method creating a bone and a [BoneAttachment3D] for each mesh parented to a bone. | |
If [code]true[/code], uses the legacy import method, creating a bone and a [BoneAttachment3D] for each mesh parented to a bone. |
Aiming to solve #75917
Just set things in order to avoid creating bones for nodes that are meshes, this also implied to rework
BoneAttachement3D
creation.I factorized everything so meshes attached to the same bone are now sharing the same
BoneAttachement3D
.Tested using a blender model, not sure if this will fit GLTF file coming from other modelization tool.