From: Mikko Rasa Date: Mon, 6 May 2019 06:08:19 +0000 (+0300) Subject: Fix some errors in the triangulation algorithm X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=e55b081c9b9927168530fdf7fafcae5aed295569;p=libs%2Fgl.git Fix some errors in the triangulation algorithm Normals were reversed and edge links were not being updated properly. --- 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]