diff options
author | Julien Duroure <julien.duroure@gmail.com> | 2020-09-17 19:53:03 +0300 |
---|---|---|
committer | Julien Duroure <julien.duroure@gmail.com> | 2020-09-17 19:53:03 +0300 |
commit | 051770b36de923a34a023ccd598dd315d2428f3a (patch) | |
tree | 2f642864d3680bc00c9d5fddb4ed11d76ac2deb3 /io_scene_gltf2/blender | |
parent | f8e313f6267742a10b8df07977182e179fa0e6f4 (diff) |
glTF exporter: Fix T79104: avoid zero normals when degenerate tris
Diffstat (limited to 'io_scene_gltf2/blender')
-rwxr-xr-x | io_scene_gltf2/blender/exp/gltf2_blender_extract.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py index ca38aa72..5b9e68f5 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_extract.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_extract.py @@ -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 |