From 7642aaab7b72c68d5293f3d31bbf131d9d521782 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Mon, 5 Jan 2026 00:14:19 -0500 Subject: [PATCH] rewrite gpu flatness detection to use same algorithm as cpu code --- src/kiri/mode/cam/topo3.js | 42 ++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/src/kiri/mode/cam/topo3.js b/src/kiri/mode/cam/topo3.js index 196ddf88..e5a7dbd7 100644 --- a/src/kiri/mode/cam/topo3.js +++ b/src/kiri/mode/cam/topo3.js @@ -265,24 +265,40 @@ export class Topo { // drop interior points along a continuous slope for (let poly of lines) { let { points } = poly; + if (points.length < 2) continue; let merged = [ points[0] ]; - let lp = points[1]; - let dz = points[0].z - lp.z; - for (let i=2; i flatness) { - // slope changed - merged.push(lp); - dz = ndz; - } else if (curvesOnly && Math.abs(ndz) < flatness) { + let lastP = points[0]; + let latent = null; + let lastSlope = undefined; + for (let i=1; i