From 33e87824dc33ea92d2b19647b21e8a0d73e505f6 Mon Sep 17 00:00:00 2001 From: Julien Duroure Date: Sun, 25 Sep 2022 18:29:25 +0200 Subject: glTF exporter: fix face domain attribute export --- io_scene_gltf2/__init__.py | 2 +- .../blender/exp/gltf2_blender_gather_primitives_extract.py | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 610c061a..5f40a81a 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, 23), + "version": (3, 4, 24), '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_gather_primitives_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_gather_primitives_extract.py index 74682ce7..3e69c2c8 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 @@ -630,9 +630,15 @@ class PrimitiveCreator: elif attr['blender_domain'] in ['FACE']: if attr['len'] > 1: data = data.reshape(-1, attr['len']) - data = data.repeat(4, axis=0) + # data contains face attribute, and is len(faces) long + # We need to dispatch these len(faces) attribute in each dots lines + data_attr = np.empty(self.dots.shape[0] * attr['len'], dtype=attr['type']) + data_attr = data_attr.reshape(-1, attr['len']) + for idx, poly in enumerate(self.blender_mesh.polygons): + data_attr[list(poly.loop_indices)] = data[idx] + data_attr = data_attr.reshape(-1, attr['len']) for i in range(attr['len']): - self.dots[attr['gltf_attribute_name'] + str(i)] = data[:, i] + self.dots[attr['gltf_attribute_name'] + str(i)] = data_attr[:, i] else: print_console("ERROR", "domain not known") -- cgit v1.2.3