Minor stroke() bugfix.

This commit is contained in:
Revar Desmera 2020-03-09 01:04:46 -07:00
parent d5aac19ef8
commit 5c83313203
2 changed files with 14 additions and 8 deletions

View file

@ -174,15 +174,17 @@ module stroke(
[lerp(width[epos[0]], width[(epos[0]+1)%len(width)], epos[1])] [lerp(width[epos[0]], width[(epos[0]+1)%len(width)], epos[1])]
); );
if (is_path(path,2)) { if (len(path[0]) == 2) {
// Straight segments // Straight segments
for (i = idx(path2,end=-2)) { for (i = idx(path2,end=-2)) {
seg = select(path2,i,i+1); seg = select(path2,i,i+1);
delt = seg[1] - seg[0]; delt = seg[1] - seg[0];
translate(seg[0]) translate(seg[0]) {
rot(from=BACK,to=delt) rot(from=BACK,to=delt) {
trapezoid(w1=widths[i], w2=widths[i+1], h=norm(delt), anchor=FRONT); trapezoid(w1=widths[i], w2=widths[i+1], h=norm(delt), anchor=FRONT);
} }
}
}
// Joints // Joints
for (i = [1:1:len(path2)-2]) { for (i = [1:1:len(path2)-2]) {
@ -217,18 +219,22 @@ module stroke(
for (i = idx(path2,end=-2)) { for (i = idx(path2,end=-2)) {
seg = select(path2,i,i+1); seg = select(path2,i,i+1);
delt = seg[1] - seg[0]; delt = seg[1] - seg[0];
translate(seg[0]) translate(seg[0]) {
rot(from=UP,to=delt) rot(from=UP,to=delt) {
cylinder(r1=widths[i]/2, r2=widths[i+1]/2, h=norm(delt), center=false); cylinder(r1=widths[i]/2, r2=widths[i+1]/2, h=norm(delt), center=false);
} }
}
}
// Joints // Joints
for (i = [1:1:len(path2)-2]) { for (i = [1:1:len(path2)-2]) {
$fn = quantup(segs(widths[i]/2),4); $fn = quantup(segs(widths[i]/2),4);
translate(path2[i]) translate(path2[i]) {
rot(from=UP, to=path2[i]-path2[i-1]) rot(from=UP, to=path2[i]-path2[i-1]) {
sphere(d=widths[i]); sphere(d=widths[i]);
} }
}
}
// Endcap1 // Endcap1
translate(path[0]) { translate(path[0]) {

View file

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