Deduplicate face vertices before triangulation.

This commit is contained in:
Revar Desmera 2020-03-24 13:33:38 -07:00
parent 07d47f4ffc
commit b0ebc77aba
2 changed files with 40 additions and 39 deletions

View file

@ -129,10 +129,12 @@ function is_only_noncolinear_vertex(points, facelist, vertex) =
// points = Array of vertices for the polyhedron.
// face = The face, given as a list of indices into the vertex array `points`.
function triangulate_face(points, face) =
let(count=len(face))
(3==count)?
[face]
:
let(
face = deduplicate(face),
count = len(face)
)
(count < 3)? [] :
(count == 3)? [face] :
let(
facenorm=face_normal(points, face),
cv=find_convex_vertex(points, face, facenorm),
@ -167,8 +169,7 @@ function triangulate_face(points, face) =
flatten([
triangulate_face(points, select(face, cv, diagonal_point)),
triangulate_face(points, select(face, diagonal_point, cv))
])
;
]);
// Function: triangulate_faces()

View file

@ -8,7 +8,7 @@
//////////////////////////////////////////////////////////////////////
BOSL_VERSION = [2,0,220];
BOSL_VERSION = [2,0,221];
// Section: BOSL Library Version Functions