glTF exporter: Fix T79104: avoid zero normals when degenerate tris

This commit is contained in:
Julien Duroure 2020-09-17 18:53:03 +02:00
parent f8e313f626
commit 051770b36d
Notes: blender-bot 2023-02-14 18:51:10 +01:00
Referenced by issue #79104, Exporting a valid GLTF (was valid before import) causes GLTF validation errors
2 changed files with 7 additions and 1 deletions

View File

@ -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, 27),
"version": (1, 4, 28),
'blender': (2, 90, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -348,6 +348,12 @@ def __get_normals(blender_mesh, key_blocks, armature, blender_object, export_set
ns[:] = __apply_mat_to_all(normal_transform, ns)
__normalize_vecs(ns)
for ns in [normals, *morph_normals]:
# Replace zero normals with the unit UP vector.
# Seems to happen sometimes with degenerate tris?
is_zero = ~ns.any(axis=1)
ns[is_zero, 2] = 1
# glTF stores deltas in morph targets
for ns in morph_normals:
ns -= normals