[Bf-extensions-cvs] [4feb9204] blender-v3.3-release: glTF exporter: Fix color attribute export

Julien Duroure noreply at git.blender.org
Wed Sep 28 08:26:03 CEST 2022


Commit: 4feb92043cbd412f1ba69ea3fe2768169db48d91
Author: Julien Duroure
Date:   Wed Sep 28 08:25:51 2022 +0200
Branches: blender-v3.3-release
https://developer.blender.org/rBA4feb92043cbd412f1ba69ea3fe2768169db48d91

glTF exporter: Fix color attribute export

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

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

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index b3327fd3..7ae843d5 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, 3, 31),
+    "version": (3, 3, 32),
     '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..fd1dce31 100755
--- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py
@@ -35,20 +35,16 @@ def extract_primitives(blender_mesh, uuid_for_skined_data, blender_vertex_groups
         if blender_mesh.uv_layers.active:
             tex_coord_max = len(blender_mesh.uv_layers)
 
-    color_max = 0
-    if export_settings[gltf2_blender_export_keys.COLORS]:
-        color_max = len(blender_mesh.vertex_colors)
-
     colors_attributes = []
-    rendered_color_idx = blender_mesh.attributes.render_color_index
-
-    if color_max > 0:
-        colors_attributes.append(rendered_color_idx)
-        # Then find other ones
-        colors_attributes.extend([
-            i for i in range(len(blender_mesh.color_attributes)) if i != rendered_color_idx \
-                and blender_mesh.vertex_colors.find(blender_mesh.color_attributes[i].name) != -1
-        ])
+    if export_settings[gltf2_blender_export_keys.COLORS]:
+        rendered_color_idx = blender_mesh.attributes.render_color_index
+
+        if rendered_color_idx > -1:
+            colors_attributes.append(rendered_color_idx)
+            # Then find other ones
+            colors_attributes.extend([
+                i for i in range(len(blender_mesh.color_attributes)) if i != rendered_color_idx
+            ])
 
 
     armature = None



More information about the Bf-extensions-cvs mailing list