From cd8387f2f965ff9fca8b0eaeb023d1e7d2597fac Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 31 Jan 2023 13:32:20 +0100 Subject: [PATCH] converter: Put morph targets on separate GeomVertexArray These never need to be uploaded anyway--and this fixes a crash when the number of morph targets causes the array to exceed the maximum stride supported by OpenGL implementations, besides being more efficient Fixes #117 --- gltf/converter.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/gltf/converter.py b/gltf/converter.py index a2bca20..a47b44d 100644 --- a/gltf/converter.py +++ b/gltf/converter.py @@ -940,6 +940,7 @@ def load_primitive(self, geom_node, gltf_primitive, gltf_mesh, gltf_data): vformat = GeomVertexFormat() varray_vert = GeomVertexArrayFormat() varray_skin = GeomVertexArrayFormat() + varray_morph = GeomVertexArrayFormat() skip_columns = ( InternalName.get_transform_index(), @@ -948,9 +949,15 @@ def load_primitive(self, geom_node, gltf_primitive, gltf_mesh, gltf_data): ) for arr in reg_format.get_arrays(): for column in arr.get_columns(): - varray = varray_skin if column.get_name() in skip_columns else varray_vert + column_name = column.get_name() + if column_name in skip_columns: + varray = varray_skin + elif column_name.parent.basename == "morph": + varray = varray_morph + else: + varray = varray_vert varray.add_column( - column.get_name(), + column_name, column.get_num_components(), column.get_numeric_type(), column.get_contents() @@ -969,6 +976,9 @@ def load_primitive(self, geom_node, gltf_primitive, gltf_mesh, gltf_data): vformat.add_array(varray_blends) vformat.add_array(varray_skin) + if targets: + vformat.add_array(varray_morph) + reg_format = GeomVertexFormat.register_format(vformat) vdata = vdata.convert_to(reg_format)