[Bf-extensions-cvs] [97bb515d] master: glTF exporter: better skin checks

Julien Duroure noreply at git.blender.org
Sun Sep 25 16:58:06 CEST 2022


Commit: 97bb515d3ac4062a8fb58544750a002433daffcc
Author: Julien Duroure
Date:   Sun Sep 25 16:57:49 2022 +0200
Branches: master
https://developer.blender.org/rBA97bb515d3ac4062a8fb58544750a002433daffcc

glTF exporter: better skin checks

===================================================================

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_extract.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py

===================================================================

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 1eeb3e11..6a7e0983 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -4,7 +4,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": (3, 4, 19),
+    "version": (3, 4, 20),
     'blender': (3, 3, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
index 61906ba0..bdea2c6f 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -6,7 +6,7 @@ from mathutils import Vector
 
 from . import gltf2_blender_export_keys
 from ...io.com.gltf2_io_debug import print_console
-from io_scene_gltf2.blender.exp import gltf2_blender_gather_skins
+from io_scene_gltf2.blender.exp import gltf2_blender_gather_nodes
 
 
 def extract_primitives(blender_mesh, uuid_for_skined_data, blender_vertex_groups, modifiers, export_settings):
@@ -73,7 +73,7 @@ def extract_primitives(blender_mesh, uuid_for_skined_data, blender_vertex_groups
             armature = None
 
         if armature:
-            skin = gltf2_blender_gather_skins.gather_skin(export_settings['vtree'].nodes[uuid_for_skined_data].armature, export_settings)
+            skin = gltf2_blender_gather_nodes.gather_skin(uuid_for_skined_data, export_settings)
             if not skin:
                 armature = None
 
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
index b68c1fdc..c95f9dec 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_animation_channels.py
@@ -155,7 +155,7 @@ def gather_animation_channels(obj_uuid: int,
 
             children_obj_parent_to_bones = []
             for bone_uuid in bones_uuid:
-                children_obj_parent_to_bones.extend([child for child in export_settings['vtree'].nodes[bone_uuid].children if export_settings['vtree'].nodes[child].blender_type != VExportNode.BONE])
+                children_obj_parent_to_bones.extend([child for child in export_settings['vtree'].nodes[bone_uuid].children if export_settings['vtree'].nodes[child].blender_type not in [VExportNode.BONE, VExportNode.ARMATURE]])
             for child_uuid in children_obj_parent_to_bones:
 
                 channels_baked = gather_channels_baked(child_uuid, export_settings)
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
index b0b2d4b8..c399a8cc 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_nodes.py
@@ -25,7 +25,7 @@ from io_scene_gltf2.blender.exp import gltf2_blender_gather_tree
 def gather_node(vnode, export_settings):
     blender_object = vnode.blender_object
 
-    skin = __gather_skin(vnode, blender_object, export_settings)
+    skin = gather_skin(vnode.uuid, export_settings)
     node = gltf2_io.Node(
         camera=__gather_camera(blender_object, export_settings),
         children=__gather_children(vnode, blender_object, export_settings),
@@ -352,7 +352,8 @@ def __gather_trans_rot_scale(vnode, export_settings):
         scale = [sca[0], sca[1], sca[2]]
     return translation, rotation, scale
 
-def __gather_skin(vnode, blender_object, export_settings):
+def gather_skin(vnode, export_settings):
+    blender_object = export_settings['vtree'].nodes[vnode].blender_object
     modifiers = {m.type: m for m in blender_object.modifiers}
     if "ARMATURE" not in modifiers or modifiers["ARMATURE"].object is None:
         return None
@@ -379,7 +380,7 @@ def __gather_skin(vnode, blender_object, export_settings):
         return None
 
     # Skins and meshes must be in the same glTF node, which is different from how blender handles armatures
-    return gltf2_blender_gather_skins.gather_skin(vnode.armature, export_settings)
+    return gltf2_blender_gather_skins.gather_skin(export_settings['vtree'].nodes[vnode].armature, export_settings)
 
 
 def __gather_weights(blender_object, export_settings):



More information about the Bf-extensions-cvs mailing list