fix stock intersection test logic for long moves

This commit is contained in:
Stewart Allen 2025-12-19 18:18:09 -05:00
commit 3ba7aae26a
2 changed files with 12 additions and 9 deletions

View file

@ -13,7 +13,8 @@ export class OpHelical extends CamOp {
async slice(progress) {
let { op, state } = this;
let { settings, addSlices, widget, updateToolDiams } = state;
let { addSlices, color, settings, updateToolDiams, widget } = state;
let { stock } = settings
let {
cylinders,
forceStartAng,
@ -29,8 +30,6 @@ export class OpHelical extends CamOp {
entry,
entryOffset,
} = op;
let { color } = state;
let { stock } = settings
let tool = new Tool(settings, op.tool),
toolDiam = tool.fluteDiameter(),
@ -240,10 +239,11 @@ export class OpHelical extends CamOp {
}
async prepare(ops, progress) {
let { polyEmit, printPoint, setTool } = ops;
let { clearTravelBounds, polyEmit, printPoint, setNextIsMove, setTool } = ops;
let { tool, spindle, rate, feed } = this.op;
setTool(tool, feed, rate);
clearTravelBounds();
let [ polys ] = this.sliceOut.map((s) => s.camLines);
polys = polys.slice();
@ -267,6 +267,7 @@ export class OpHelical extends CamOp {
if (!closest) break;
poly = polys[closestI]
polys[closestI] = null;
printPoint = polyEmit(poly);
}
}

View file

@ -454,10 +454,9 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
// * rapid to just above stock
// * continue plunge as cut
if (isMove && deltaZ < 0 && printPoint.z > stockZ && point.z < stockZ) {
if (debug) console.log('detected plunge cut as rapid move', printPoint.z, stockZ, point.z);
if (debug) console.log('detected plunge cut as rapid move', printPoint.z, point.z);
layerPush(point.clone().setZ(zSafe), 0, 0, tool);
// change to cutting move for remainder of plunge
emit = 1;
newLayer();
} else
// convert short planar moves to cuts when not lasering
@ -502,15 +501,16 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
}
lastTravelBounds = undefined;
} else
// for longer moves, check the terrain to see if we need to go up and over
// for longer moves
if (isMove) {
const bigXY = (deltaXY > shortCut && !lasering);
const bigZ = (absDeltaZ > toolDiam / 2 && deltaXY > tolerance);
const midZ = (tolerance && absDeltaZ >= tolerance);
const inStock = printPoint.z < stockZ || point.z < stockZ;
if (bigXY || bigZ || midZ) {
if (debug) console.log({ fromz: printPoint.z, toz: point.z });
// for big moves inside stock...
if (camForceZMax || printPoint.z < stockZ) {
// for big moves intersecting stock...
if (camForceZMax || inStock) {
upAndOver = true;
}
}
@ -849,6 +849,7 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
let ops = {
addGCode,
camOut,
clearTravelBounds() { setTravelBoundary() },
depthOutlinePath,
emitDrills,
emitTraces,
@ -866,6 +867,7 @@ export async function prepare_one(widget, settings, print, firstPoint, update) {
setSpindle,
setTolerance,
setTool,
setTravelBoundary,
tip2tipEmit,
widget,
zSafe,