mirror of
https://github.com/BelfrySCAD/BOSL2.git
synced 2025-01-04 03:09:45 +00:00
Speed optimizations to triangulate_faces()
This commit is contained in:
parent
857e7a94fb
commit
2b2012d1d1
2 changed files with 9 additions and 10 deletions
|
@ -89,9 +89,10 @@ function _check_point_in_ear(point, tests) =
|
||||||
// Arguments:
|
// Arguments:
|
||||||
// v = The array to normalize.
|
// v = The array to normalize.
|
||||||
function normalize_vertex_perimeter(v) =
|
function normalize_vertex_perimeter(v) =
|
||||||
(len(v) < 2)? v :
|
let(lv = len(v))
|
||||||
(v[len(v)-1] != v[0])? v :
|
(lv < 2)? v :
|
||||||
[for (i=[0:1:len(v)-2]) v[i]]
|
(v[lv-1] != v[0])? v :
|
||||||
|
[for (i=[0:1:lv-2]) v[i]]
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,12 +182,10 @@ function triangulate_face(points, face) =
|
||||||
// faces = Array of faces for the polyhedron. Each face is a list of 3 or more indices into the `points` array.
|
// faces = Array of faces for the polyhedron. Each face is a list of 3 or more indices into the `points` array.
|
||||||
function triangulate_faces(points, faces) =
|
function triangulate_faces(points, faces) =
|
||||||
[
|
[
|
||||||
for (i=[0:1:len(faces)-1])
|
for (face=faces) each
|
||||||
let(facet = normalize_vertex_perimeter(faces[i]))
|
len(face)==3? [face] :
|
||||||
for (face = triangulate_face(points, facet))
|
triangulate_face(points, normalize_vertex_perimeter(face))
|
||||||
if (face[0]!=face[1] && face[1]!=face[2] && face[2]!=face[0]) face
|
];
|
||||||
]
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
// vim: noexpandtab tabstop=4 shiftwidth=4 softtabstop=4 nowrap
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
BOSL_VERSION = [2,0,245];
|
BOSL_VERSION = [2,0,246];
|
||||||
|
|
||||||
|
|
||||||
// Section: BOSL Library Version Functions
|
// Section: BOSL Library Version Functions
|
||||||
|
|
Loading…
Reference in a new issue