Skip to content

Commit

Permalink
Fix auto smooth normals
Browse files Browse the repository at this point in the history
  • Loading branch information
neo2068 committed Jan 30, 2024
1 parent 3cb5435 commit ea6b067
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions export/mesh_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def convert(obj, mesh_key, depsgraph, luxcore_scene, is_viewport_render, use_ins
return None

custom_normals = None
mesh.calc_normals_split()
if mesh.has_custom_normals:
start = time()
custom_normals = get_custom_normals_slow(mesh)
Expand Down Expand Up @@ -141,26 +140,23 @@ def _prepare_mesh(obj, depsgraph):
# if not mesh.has_custom_normals and object_eval.matrix_world.determinant() < 0.0:
# # Does not handle custom normals
# mesh.flip_normals()

mesh.calc_loop_triangles()
if not mesh.loop_triangles:
object_eval.to_mesh_clear()
mesh = None

if mesh:
if bpy.app.version > (3, 9, 9):
if 'sharp_face' in mesh.attributes:
mesh.split_faces()
if mesh.has_custom_normals:
mesh.calc_normals_split()
else:
if mesh.use_auto_smooth:
if not mesh.has_custom_normals:
mesh.calc_normals()
mesh.split_faces()

mesh.calc_loop_triangles()
mesh.calc_loop_triangles()

if mesh.has_custom_normals:
mesh.calc_normals_split()
if mesh.has_custom_normals:
mesh.calc_normals_split()

yield mesh
finally:
Expand Down

0 comments on commit ea6b067

Please sign in to comment.