enable wasm acceleration for layer diffs

This commit is contained in:
Stewart Allen 2021-07-10 22:57:32 -04:00
commit a9e22e802f
3 changed files with 11 additions and 5 deletions

View file

@ -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);

View file

@ -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
});
};
/**

View file

@ -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) => {