From: Mikko Rasa Date: Wed, 11 Sep 2013 09:06:30 +0000 (+0300) Subject: Deal with some irregularities in the Blender exporter X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=commitdiff_plain;h=a6d952c0a2effd65ee4e82caffe1b96ccd36f84e Deal with some irregularities in the Blender exporter Things like loose vertices, non-manifold edges or zero-length edges should no longer cause crashes. --- diff --git a/blender/io_mspgl/mesh.py b/blender/io_mspgl/mesh.py index a41cbc13..88758730 100644 --- a/blender/io_mspgl/mesh.py +++ b/blender/io_mspgl/mesh.py @@ -34,6 +34,12 @@ class Edge: else: return self.faces[0] + def other_vertex(self, v): + if v.index==self.vertices[0].index: + return self.vertices[1] + else: + return self.vertices[0] + class Vertex: def __init__(self, mv): @@ -248,26 +254,35 @@ class Mesh: v.index = len(self.vertices) self.vertices.append(v) + v_edges = [] + v_edge_keys = set() for f in g: - for j in range(len(f.edges)): - e = f.edges[j] - - if self.vertices[i] not in e.vertices: + for e in f.edges: + if e.key in v_edge_keys or self.vertices[i] not in e.vertices: continue - if e.other_face(f) not in g and len(e.faces)>=2: - e.faces.remove(f) - e = Edge(e) - f.edges[j] = e - e.faces.append(f) - else: - del self.edges[e.key] + e_faces_in_g = [c for c in e.faces if c in g] + boundary = len(e_faces_in_g)