From a9e22e802f604c7fb7213eb17ae7b8bdbfddd3ea Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sat, 10 Jul 2021 22:57:32 -0400 Subject: [PATCH] enable wasm acceleration for layer diffs --- src/geo/polygons.js | 2 +- src/mode/fdm/slice.js | 9 ++++++--- src/mode/sla/slice.js | 5 ++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/geo/polygons.js b/src/geo/polygons.js index 4dd6107f..9ad3c305 100644 --- a/src/geo/polygons.js +++ b/src/geo/polygons.js @@ -314,7 +314,7 @@ opt.prof.call = (opt.prof.call || 0) + 1; } - if (false && opt.wasm) { + if (opt.wasm && geo.wasm) { let oA = outA ? [] : undefined; let oB = outB ? [] : undefined; geo.wasm.js.diff(setA, setB, z, oA, oB); diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index c62c18f5..6195bdd9 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -448,7 +448,7 @@ if (solidLayers && !vaseMode && !isSynth) { profileStart("delta"); forSlices(0.2, 0.34, slice => { - if (slice.index > 0) doDiff(slice, solidMinArea); + if (slice.index > 0) doDiff(slice, solidMinArea, { wasm: useAssembly }); }, "layer deltas"); profileEnd(); profileStart("delta-project"); @@ -1038,10 +1038,11 @@ * Used to calculate bridges, flats and then solid projections. * 'expand' is used for top offsets in SLA mode */ - function doDiff(slice, minArea, sla, fakedown) { + function doDiff(slice, minArea, options = {}) { if (slice.index === 0 && !fakedown) { return; } + const { sla, fakedown } = options; const top = slice, down = slice.down || (fakedown ? newSlice(-1) : null), topInner = sla ? top.topPolys() : top.topInners(), @@ -1056,7 +1057,9 @@ return; } - POLY.subtract(topInner, downInner, bridges, flats, slice.z, minArea); + POLY.subtract(topInner, downInner, bridges, flats, slice.z, minArea, { + wasm: options.wasm + }); }; /** diff --git a/src/mode/sla/slice.js b/src/mode/sla/slice.js index e30b9200..ccf6c01d 100644 --- a/src/mode/sla/slice.js +++ b/src/mode/sla/slice.js @@ -144,7 +144,10 @@ }, "shells"); forSlices(slices, 10, (slice) => { if (slice.synth) return; - FDM.doDiff(slice, 0.000001, true, !process.slaOpenBase); + FDM.doDiff(slice, 0.000001, { + sla: true, + fakedown: !process.slaOpenBase + }); }, "delta"); if (solidLayers) { forSlices(slices, 10, (slice) => {