Skip to content
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

Exporter fails when exporting an armature with one or more non-deforming root bones with "Export Deformation Bones Only" and "Remove Armature Object" options enabled #2394

Open
samcook5343 opened this issue Nov 2, 2024 · 2 comments · May be fixed by #2397
Labels
bug Something isn't working

Comments

@samcook5343
Copy link

Describe the bug
When exporting a scene containing an armature with one or more non-deforming root bones with both the "Export Deformation Bones Only" and "Remove Armature Object" options enabled, the exporter raises the following error:

Python: Traceback (most recent call last):
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/__init__.py", line 1289, in execute
    res = gltf2_blender_export.save(context, export_settings)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 37, in save
    json, buffer = __export(export_settings)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 55, in __export
    __gather_gltf(exporter, export_settings)
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 202, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 31, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 37, in wrapper_cached
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather.py", line 94, in __gather_scene
    node = gltf2_blender_gather_nodes.gather_node(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 48, in gather_node
    children=__gather_children(vnode, export_settings),
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py", line 130, in __gather_children
    joint = gltf2_blender_gather_joints.gather_joint_vnode(bone_uuid, export_settings)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather_cache.py", line 37, in wrapper_cached
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/snap/blender/5438/4.2/scripts/addons_core/io_scene_gltf2/blender/exp/gltf2_blender_gather_joints.py", line 52, in gather_joint_vnode
    blender_bone = vtree.nodes[vnode].blender_bone
                   ~~~~~~~~~~~^^^^^^^
KeyError: 'cdfb2ad9-b573-4109-8c2b-f91abed960dd'

To Reproduce
Steps to reproduce the behavior:

  1. Open the attached example.blend
  2. Go to the glTF exporter (File > Export > glTF 2.0 (.glb/.gltf))
  3. Enable both the "Export Deformation Bones Only" and "Remove Armature Object" options under Data > Armature in the exporter properties
  4. Attempt to export the file

Expected behavior
The export should not fail and, if removing the non-deforming bones from the armature yields an armature with a single root bone, the Armature object should not be present in the exported glTF file.

.blend file/ .gltf (mandatory)
example.zip

Version

  • OS: Kubuntu 22.04
  • Blender Version 4.2.3 LTS
@julienduroure
Copy link
Collaborator

Confirmed

@julienduroure julienduroure added the bug Something isn't working label Nov 2, 2024
@julienduroure
Copy link
Collaborator

Root cause:
Check if we can remove the armature object use some functions that bakes bone lists.
This check is done before the filter of non deformation bone.
So when we want to get this list, as it's cached, we get the list with non deformation bones, so try to access a bone that is filtered

Additional bug when we want to export only DEF bones :
the check is done on all bugs, not only deformation bones, if we want to get only def bones.
So having at root a DEF and a nonDEF bone => Check will failed and said we can't remove armature

julienduroure added a commit that referenced this issue Nov 5, 2024
@julienduroure julienduroure linked a pull request Nov 5, 2024 that will close this issue
@julienduroure julienduroure added this to the Blender 4.2 LTS milestone Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants