From 1326eaff09fc7b8f8f94c7abc850a7602083be9d Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sun, 9 Mar 2025 05:35:19 +0100 Subject: [PATCH] Fix #135549 - glTF: Fix exporting only def bones + add leaf bones --- scripts/addons_core/io_scene_gltf2/__init__.py | 2 +- .../addons_core/io_scene_gltf2/blender/exp/tree.py | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/addons_core/io_scene_gltf2/__init__.py b/scripts/addons_core/io_scene_gltf2/__init__.py index e9107a10281..a8dee8b0561 100755 --- a/scripts/addons_core/io_scene_gltf2/__init__.py +++ b/scripts/addons_core/io_scene_gltf2/__init__.py @@ -5,7 +5,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (4, 4, 54), + "version": (4, 4, 55), 'blender': (4, 4, 0), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/scripts/addons_core/io_scene_gltf2/blender/exp/tree.py b/scripts/addons_core/io_scene_gltf2/blender/exp/tree.py index 0ca3f65f675..7f64b4406bb 100644 --- a/scripts/addons_core/io_scene_gltf2/blender/exp/tree.py +++ b/scripts/addons_core/io_scene_gltf2/blender/exp/tree.py @@ -772,6 +772,12 @@ class VExportTree: for bone in armature.data.edit_bones: if len(bone.children) == 0: + + # If we are exporting only deform bones, we need to check if this bone is a def bone + if self.export_settings['gltf_def_bones'] is True \ + and bone.use_deform is False: + continue + self.nodes[self.nodes[obj_uuid].bones[bone.name] ].matrix_world_tail = armature.matrix_world @ Matrix.Translation(bone.tail) @ self.axis_basis_change @@ -780,6 +786,11 @@ class VExportTree: for bone_uuid in [n for n in self.nodes if self.nodes[n].blender_type == VExportNode.BONE and len(self.nodes[n].children) == 0]: + # If we are exporting only deform bones, we need to check if this bone is a def bone + if self.export_settings['gltf_def_bones'] is True \ + and self.nodes[bone_uuid].use_deform is False: + continue + bone_node = self.nodes[bone_uuid] # Add a new node