[Bf-extensions-cvs] [fea0e8e3] master: glTF exporter: Fix export VertexColor for loose edges & vertices

Julien Duroure noreply at git.blender.org
Mon Dec 12 11:38:15 CET 2022


Commit: fea0e8e32e2fdb6e400ebd766628311453f5bed7
Author: Julien Duroure
Date:   Mon Dec 12 11:38:05 2022 +0100
Branches: master
https://developer.blender.org/rBAfea0e8e32e2fdb6e400ebd766628311453f5bed7

glTF exporter: Fix export VertexColor for loose edges & vertices

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

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

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

diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py
index 2da12265..32bda219 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, 5, 6),
+    "version": (3, 5, 7),
     'blender': (3, 4, 0),
     'location': 'File > Import-Export',
     'description': 'Import-Export as glTF 2.0',
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py
index c7d2a966..27290e65 100644
--- a/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py
+++ b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py
@@ -558,16 +558,28 @@ class PrimitiveCreator:
         self.blender_mesh.color_attributes[blender_color_idx].data.foreach_get('color', colors)
         if attr['blender_domain'] == "POINT":
             colors = colors.reshape(-1, 4)
-            colors = colors[self.dots['vertex_index']]
+            data_dots = colors[self.dots['vertex_index']]
+            if self.export_settings['gltf_loose_edges']:
+                data_dots_edges = colors[self.dots_edges['vertex_index']]
+            if self.export_settings['gltf_loose_points']:
+                data_dots_points = colors[self.dots_points['vertex_index']]
+
         elif attr['blender_domain'] == "CORNER":
             colors = colors.reshape(-1, 4)
-        # colors are already linear, no need to switch color space
-        self.dots[attr['gltf_attribute_name'] + '0'] = colors[:, 0]
-        self.dots[attr['gltf_attribute_name'] + '1'] = colors[:, 1]
-        self.dots[attr['gltf_attribute_name'] + '2'] = colors[:, 2]
-        self.dots[attr['gltf_attribute_name'] + '3'] = colors[:, 3]
+            data_dots = colors[self.dots['vertex_index']]
+            if self.export_settings['gltf_loose_edges'] and attr['blender_domain'] == "POINT":
+                data_dots_edges = colors[self.dots_edges['vertex_index']]
+            if self.export_settings['gltf_loose_points'] and attr['blender_domain'] == "POINT":
+                data_dots_points = colors[self.dots_points['vertex_index']]
+
         del colors
 
+        for i in range(4):
+            self.dots[attr['gltf_attribute_name'] + str(i)] = data_dots[:, i]
+            if self.export_settings['gltf_loose_edges'] and attr['blender_domain'] == "POINT":
+                self.dots_edges[attr['gltf_attribute_name'] + str(i)] = data_dots_edges[:, i]
+            if self.export_settings['gltf_loose_points'] and attr['blender_domain'] == "POINT":
+                self.dots_points[attr['gltf_attribute_name'] + str(i)] = data_dots_points[:, i]
 
     def __get_layer_attribute(self, attr):
         if attr['blender_domain'] in ['CORNER']:



More information about the Bf-extensions-cvs mailing list