From e55b081c9b9927168530fdf7fafcae5aed295569 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 6 May 2019 09:08:19 +0300 Subject: [PATCH] Fix some errors in the triangulation algorithm Normals were reversed and edge links were not being updated properly. --- blender/io_mspgl/mesh.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index 08f0bb4a..c3767bd9 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -296,7 +296,7 @@ class Mesh: normals = [] for j in range(nverts): - normals.append(edge_vecs[j].cross(edge_vecs[j-1]).normalized()) + normals.append(edge_vecs[j-1].cross(edge_vecs[j]).normalized()) # Check which diagonal results in a flatter triangulation flatness1 = normals[0].dot(normals[2]) @@ -333,6 +333,10 @@ class Mesh: else: nf.edges = [f.edges[1], f.edges[2], ne] f.edges = [f.edges[0], ne, f.edges[3]] + for e in nf.edges: + if e!=ne: + e.faces.remove(f) + e.faces.append(nf) f.normal = normals[1-cut_index] nf.normal = normals[3-cut_index] -- 2.45.2