feat: sort face vertices before tessellation
This commit is contained in:
parent
6398b4f987
commit
016e5a2949
1 changed files with 5 additions and 2 deletions
7
map.py
7
map.py
|
@ -73,8 +73,11 @@ class Face:
|
|||
def __init__(self, vs):
|
||||
self.vertices = vs
|
||||
self.tris = []
|
||||
for i in range(1, len(vs)-1):
|
||||
self.tris.append(Triangle(vs[0], vs[i], vs[i+1]))
|
||||
# Sort vertices so that so that the normal points "outward"
|
||||
if np.dot(self.vertices[0], np.cross(self.vertices[1] - self.vertices[0], self.vertices[2] - self.vertices[0])) < 0:
|
||||
self.vertices = self.vertices[::-1]
|
||||
for i in range(1, len(self.vertices)-1):
|
||||
self.tris.append(Triangle(self.vertices[0], self.vertices[i], self.vertices[i+1]))
|
||||
self.plane_coords = [self.tris[0].plane_coords(v) for v in self.vertices]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue