[Bf-extensions-cvs] [7aa6363e] master: glTF exporter: Export joint indices as uint8 when possible

Julien Duroure noreply at git.blender.org
Sat Aug 8 14:48:10 CEST 2020


Commit: 7aa6363ee1fd1efb4f58419cbd6f916e10a2d109
Author: Julien Duroure
Date:   Sat Aug 8 14:47:49 2020 +0200
Branches: master
https://developer.blender.org/rBA7aa6363ee1fd1efb4f58419cbd6f916e10a2d109

glTF exporter: Export joint indices as uint8 when possible

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

M	io_scene_gltf2/__init__.py
M	io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index bafd7501..4b65741c 100755
--- a/io_scene_gltf2/__init__.py
+++ b/io_scene_gltf2/__init__.py
@@ -15,7 +15,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": (1, 4, 2),
+    "version": (1, 4, 3),
     'blender': (2, 90, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
index 8912d921..61adea89 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitive_attributes.py
@@ -161,9 +161,12 @@ def __gather_skins(blender_primitive, export_settings):
 
             # joints
             internal_joint = blender_primitive["attributes"][joint_id]
+            component_type = gltf2_io_constants.ComponentType.UnsignedShort
+            if max(internal_joint) < 256:
+                component_type = gltf2_io_constants.ComponentType.UnsignedByte
             joint = array_to_accessor(
                 internal_joint,
-                component_type=gltf2_io_constants.ComponentType.UnsignedShort,
+                component_type,
                 data_type=gltf2_io_constants.DataType.Vec4,
             )
             attributes[joint_id] = joint



More information about the Bf-extensions-cvs mailing list