From 41d95c5585144e4c5db8009279adba230f362843 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Wed, 4 Nov 2020 11:13:06 -0500 Subject: [PATCH] fix progressive shadows in rough/outline by using terrain top/bottom derived from new fit option --- src/geo/polygon.js | 1 - src/kiri/slicer2.js | 26 ++++++++++++++++++-------- src/mode/cam/driver.js | 17 +++++++++++------ 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/src/geo/polygon.js b/src/geo/polygon.js index 9338031d..79093be3 100644 --- a/src/geo/polygon.js +++ b/src/geo/polygon.js @@ -1313,7 +1313,6 @@ if (src[0].isEquivalent(dst[0]) && src[1].isEquivalent(dst[1])) { return null; } - return union; } return union; } diff --git a/src/kiri/slicer2.js b/src/kiri/slicer2.js index 3b706dfc..5c09db54 100644 --- a/src/kiri/slicer2.js +++ b/src/kiri/slicer2.js @@ -253,25 +253,35 @@ interval(step, options) { let opt = options || {}, bounds = this.bounds, - boff = opt.boff || 0, // bottom offset - toff = opt.toff || 0, // top offset + boff = opt.boff || opt.off || 0, // bottom offset + toff = opt.toff || opt.off || 0, // top offset zmin = (opt.min || this.bounds.min.z) + boff, zmax = (opt.max || this.bounds.max.z) - toff, - count = Math.floor((zmax - zmin) / step), - array = new Array(count); + steps = (zmax - zmin) / step, + count = Math.floor(steps), + array = []; + + if (opt.fit) { + count++; + step = (zmax - zmin) / count; + } if (opt.down) { - for (let i=0, il=array.length; i { console.log('terrain', index, total, data); tshadow = POLY.union(tshadow.appendAll(data.tops), 0.01, true); tslices.push(data.slice); onupdate(0.0 + (index/total) * 0.1, "mapping"); }, genso: true }); + let shadowTop = terrain[terrain.length - 1]; + let shadowBase = terrain[0]; console.log({slicer, tzindex, tshadow, terrain}); if (procDrillReg) { @@ -849,20 +851,22 @@ // identify through holes thruHoles = tshadow.map(p => p.inner || []).flat(); + console.log({thruHoles}) // create roughing slices if (procRough) { - - let shadow = []; + let shadow = shadowTop.tops; let slices = []; slicer.slice(slicer.interval(roughDown, { down: true, min: zBottom }), { each: (data, index, total) => { shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true); data.shadow = shadow.clone(true); data.slice.camMode = CPRO.ROUGH; data.slice.shadow = data.shadow; + // data.slice.tops[0].inner = shadow.clone(true); slices.push(data.slice); onupdate(0.1 + (index/total) * 0.1, "roughing"); }, genso: true }); + shadow = POLY.union(shadow.appendAll(shadowBase.tops), 0.01, true); // inset or eliminate thru holes from shadow shadow = POLY.flatten(shadow.clone(true), [], true); @@ -890,7 +894,7 @@ // create outline slices if (procOutline) { - let shadow = []; + let shadow = shadowTop.tops; let slices = []; slicer.slice(slicer.interval(outlineDown, { down: true, min: zBottom }), { each: (data, index, total) => { shadow = POLY.union(shadow.appendAll(data.tops), 0.01, true); @@ -901,6 +905,7 @@ slices.push(data.slice); onupdate(0.2 + (index/total) * 0.1, "outlines"); }, genso: true }); + shadow = POLY.union(shadow.appendAll(shadowBase.tops), 0.01, true); shellOutline = tshadow;