From 32ff742d0e98c133b32ce4bff0fb59e4991ade10 Mon Sep 17 00:00:00 2001 From: Alex Matulich Date: Sun, 20 Apr 2025 17:45:25 -0700 Subject: [PATCH] fix bunching in vnf_tri_array --- vnf.scad | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/vnf.scad b/vnf.scad index 3b512602..d08f875a 100644 --- a/vnf.scad +++ b/vnf.scad @@ -311,7 +311,7 @@ function vnf_vertex_array( texture, tex_reps, tex_size, tex_samples, tex_inset=false, tex_rot=0, tex_depth=1, tex_extra, tex_skip, sidecaps,sidecap1,sidecap2, normals ) = - assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2"])) + assert(in_list(style,["default","alt","quincunx", "convex","concave", "min_edge","min_area","flip1","flip2","diagnormals"])) assert(is_matrix(points[0], n=3),"\nPoint array has the wrong shape or points are not 3d.") assert(is_consistent(points), "\nNon-rectangular or invalid point array.") assert(is_bool(triangulate)) @@ -347,6 +347,7 @@ function vnf_vertex_array( ) mean([pts[i1], pts[i2], pts[i3], pts[i4]]) ], + surfnorms = style=="diagnormals" ? surface_normals(points, row_wrap=row_wrap, col_wrap=col_wrap) : [], allfaces = [ if (cap1) count(cols,reverse=!reverse), if (cap2) count(cols,(rows-1)*cols, reverse=reverse), @@ -401,6 +402,16 @@ function vnf_vertex_array( : [[i1,i3,i2],[i1,i4,i3]] ) concavefaces + : style=="diagnormals"? + let( + ang13 = vector_angle(surfnorms[r][c],surfnorms[(r+1)%rows][(c+1)%cols]), + ang24 = vector_angle(surfnorms[(r+1)%rows][c],surfnorms[r][(c+1)%cols]), + smallang = ang24=n1 && t2>=n2 ? trilist : - _lofttri(p1, p2, i1offset, i2offset, n1, n2, reverse, concat(trilist, [triangle]), d12=n1?i1:t1) : i1, userow==2 ? (t2>=n2?i2:t2) : i2, tc1, tc2, trimax) : // equal row lengths let(n=n1, i=i1, @@ -606,7 +628,7 @@ function _lofttri(p1, p2, i1offset, i2offset, n1, n2, reverse=false, trilist=[], [i2offset+t, i1offset+t, d12=n ? trilist : - _lofttri(p1, p2, i1offset, i2offset, n, n, reverse, concat(trilist, [triangle1, triangle2]), t, t); + _lofttri(p1, p2, i1offset, i2offset, n, n, reverse, concat(trilist, [triangle1, triangle2]), t, t, 0,0,trimax); // Function: vnf_join()