bug fixes

This commit is contained in:
Adrian Mariano 2021-09-15 20:03:15 -04:00
parent d78eb5213e
commit d957f556d6
2 changed files with 7 additions and 2 deletions

View File

@ -1599,16 +1599,20 @@ function point_in_polygon(point, poly, nonzero=false, eps=EPSILON) =
// vnf_wireframe(vnf_tri, d=.15);
function polygon_triangulate(poly, ind, eps=EPSILON) =
let(a=echo(poly=poly)echo(ind=ind))
assert(is_path(poly), "Polygon `poly` should be a list of 2d or 3d points")
assert(is_undef(ind)
|| (is_vector(ind) && min(ind)>=0 && max(ind)<len(poly) ),
"Improper or out of bounds list of indices")
let( ind = deduplicate_indexed(poly,is_undef(ind) ? count(len(poly)) : ind) )
len(ind) < 3 ? [] :
len(ind) == 3 ? [ind] :
len(poly[ind[0]]) == 3
? // represents the polygon projection on its plane as a 2d polygon
let(
pts = select(poly,ind),
nrm = polygon_normal(pts)
nrm = polygon_normal(pts),
a=echo(pts=pts)echo(nrm=nrm)
)
// here, instead of an error, it might return [] or undef
assert( nrm!=undef,

View File

@ -1958,7 +1958,8 @@ function rounded_prism(bottom, top, joint_bot=0, joint_top=0, joint_sides=0, k_b
vnf = vnf_merge([ each subindex(top_samples,0),
each subindex(bot_samples,0),
for(pts=edge_points) vnf_vertex_array(pts),
vnf_triangulate(vnf_add_faces(EMPTY_VNF,faces))
debug ? vnf_add_faces(EMPTY_VNF,faces)
: vnf_triangulate(vnf_add_faces(EMPTY_VNF,faces))
])
)
debug ? [concat(top_patch, bot_patch), vnf] : vnf;