replace routing zMax with zSafe

This commit is contained in:
Stewart Allen 2025-11-30 18:23:48 -05:00
commit 761568b533

View file

@ -80,22 +80,19 @@ export function prepare_one(widget, settings, print, firstPoint, update) {
{ camStockOffset, camStockIndexed, camZClearance } = process, { camStockOffset, camStockIndexed, camZClearance } = process,
stock = settings.stock || {}, stock = settings.stock || {},
stockZ = stock.z * (camStockIndexed ? 0.5 : 1), stockZ = stock.z * (camStockIndexed ? 0.5 : 1),
outer = settings.bounds || widget.getPositionBox(), // dup of bounds?
outerZ = outer.max.z, // dup of boundsZ?
stockZClear = stockZ + camZClearance, stockZClear = stockZ + camZClearance,
widgetTrackTop = widget.track.top, widgetTrackTop = widget.track.top,
widgetTopToStock = stockZ - widgetTrackTop, widgetTopToStock = stockZ - widgetTrackTop,
bounds = widget.getBoundingBox(), bounds = widget.getBoundingBox(),
boundsZ = camStockIndexed ? stock.z / 2 : bounds.max.z + widgetTopToStock, boundsZ = camStockIndexed ? stock.z / 2 : bounds.max.z + widgetTopToStock,
zMax = outerZ + camZClearance + (camOriginOffZ || 0) + widgetTopToStock, zSafe = camStockIndexed ? Math.hypot(stock.y, stock.z) / 2 + camZClearance : stockZClear,
zSafe = camStockIndexed ? Math.hypot(bounds.dim.y, bounds.dim.z) / 2 + camZClearance : zMax,
wmpos = widget.track.pos, wmpos = widget.track.pos,
wmx = wmpos.x, wmx = wmpos.x,
wmy = wmpos.y, wmy = wmpos.y,
wmz = !camStockIndexed ? stock.z - boundsZ : alignTop ? outerZ - boundsZ : 0, wmz = !camStockIndexed ? stock.z - boundsZ : alignTop ? 0 : 0,
originx = (camOriginCenter ? 0 : -stock.x / 2) + (camOriginOffX || 0), originx = (camOriginCenter ? 0 : -stock.x / 2) + (camOriginOffX || 0),
originy = (camOriginCenter ? 0 : -stock.y / 2) + (camOriginOffY || 0), originy = (camOriginCenter ? 0 : -stock.y / 2) + (camOriginOffY || 0),
origin = newPoint(originx, originy, zMax), origin = newPoint(originx, originy, zSafe),
arcRadians = toRadians(camArcResolution), arcRadians = toRadians(camArcResolution),
arcEnabled = camArcEnabled && camArcTolerance > 0 && arcRadians > 0, arcEnabled = camArcEnabled && camArcTolerance > 0 && arcRadians > 0,
currentOp, currentOp,
@ -131,9 +128,11 @@ export function prepare_one(widget, settings, print, firstPoint, update) {
z: data.z, z: data.z,
tops: data.tops, tops: data.tops,
}; };
}) : zMax, }) : zSafe,
tolerance = 0; tolerance = 0;
console.log({ zSafe, stockZ, outerZ, boundsZ, wmz });
// console.log({ zSafe, stockZ, boundsZ, wmz });
function newLayer(op) { function newLayer(op) {
if (layerOut.length || layerOut.mode) { if (layerOut.length || layerOut.mode) {
newOutput.push(layerOut); newOutput.push(layerOut);
@ -473,7 +472,7 @@ console.log({ zSafe, stockZ, outerZ, boundsZ, wmz });
clearz = maxz; clearz = maxz;
let zIsBelow = point.z <= maxz; let zIsBelow = point.z <= maxz;
if (camForceZMax) { if (camForceZMax) {
clearz = maxz = zMax;// + zadd; clearz = maxz = zSafe;
zIsBelow = true; zIsBelow = true;
} }
// up if any point between higher than start/outline, go up first // up if any point between higher than start/outline, go up first
@ -1051,7 +1050,6 @@ console.log({ zSafe, stockZ, outerZ, boundsZ, wmz });
setTool, setTool,
tip2tipEmit, tip2tipEmit,
widget, widget,
zMax,
zSafe, zSafe,
}; };
@ -1082,7 +1080,7 @@ console.log({ zSafe, stockZ, outerZ, boundsZ, wmz });
} }
} }
// last layer/move is to zMax // last layer/move is to zSafe
// re-inject that point into the last layer generated // re-inject that point into the last layer generated
if (printPoint && newOutput.length) { if (printPoint && newOutput.length) {
let lastLayer = newOutput.filter(layer => Array.isArray(layer)).peek(); let lastLayer = newOutput.filter(layer => Array.isArray(layer)).peek();