Simplify the code, remove intermediate segments
This commit is contained in:
parent
0cdfee585e
commit
a7eded5156
1 changed files with 2 additions and 10 deletions
|
|
@ -1162,21 +1162,13 @@ class Polygon {
|
||||||
// When "in Ease-Down" (ie. while target Z not yet reached) - follow path while slowly decreasing Z.
|
// When "in Ease-Down" (ie. while target Z not yet reached) - follow path while slowly decreasing Z.
|
||||||
let deltaZ = fromZ - next.z;
|
let deltaZ = fromZ - next.z;
|
||||||
dist2next = last.distTo2D(next);
|
dist2next = last.distTo2D(next);
|
||||||
|
next = next.clone().setZ(fromZ - dist2next * slope);
|
||||||
|
|
||||||
if (dist2next > maxDist2d) {
|
|
||||||
// long move: synth intermediate - neccessary?
|
|
||||||
last = next = last.followTo(next, maxDist2d).setZ(last.z - maxDist2d * slope)
|
|
||||||
fromZ = next.z;
|
|
||||||
fn(next, offset++);
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
// too short: clone n move z
|
|
||||||
next = next.clone().setZ(fromZ - maxDist2d * slope);
|
|
||||||
}
|
|
||||||
fromZ = next.z;
|
fromZ = next.z;
|
||||||
} else if (offset === 0 && next.z < fromZ) {
|
} else if (offset === 0 && next.z < fromZ) {
|
||||||
// First point, move to rampZ height above next.
|
// First point, move to rampZ height above next.
|
||||||
let deltaZ = fromZ - next.z;
|
let deltaZ = fromZ - next.z;
|
||||||
|
|
||||||
fromZ = next.z + Math.min(deltaZ, rampZ)
|
fromZ = next.z + Math.min(deltaZ, rampZ)
|
||||||
next = next.clone().setZ(fromZ);
|
next = next.clone().setZ(fromZ);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue