allow infill cloning to work with threading

This commit is contained in:
Stewart Allen 2021-07-10 22:09:44 -04:00
commit 87642e8cf3
3 changed files with 16 additions and 28 deletions

View file

@ -871,9 +871,6 @@
flatten(polys).sort((a,b) => { flatten(polys).sort((a,b) => {
return a.area() > b.area(); return a.area() > b.area();
}).forEach(p => { }).forEach(p => {
// finger.push(p.area());
// finger.push(p.perimeter());
// finger.push(p.bounds);
finger.push({ finger.push({
c: p.circularityDeep(), c: p.circularityDeep(),
p: p.perimeterDeep(), p: p.perimeterDeep(),
@ -913,20 +910,6 @@
return false; return false;
} }
} }
// for (let i=0; i<a.length; i += 3) {
// if (Math.abs(a[i] - b[i]) > 0.001) {
// return false;
// }
// if (Math.abs(a[i+1] - b[i+1]) > 0.0001) {
// return false;
// }
// if (Math.abs(a[i+2].centerx() - b[i+2].centerx()) > 0.0001) {
// return false;
// }
// if (Math.abs(a[i+2].centery() - b[i+2].centery()) > 0.0001) {
// return false;
// }
// }
return true; return true;
} }

View file

@ -190,7 +190,7 @@ if (!self.window) (function() {
free: exports.mem_clr, free: exports.mem_clr,
set_debug: exports.set_debug set_debug: exports.set_debug
}; };
wasm.shared = wasm.malloc(1024 * 1024 * 32), wasm.shared = wasm.malloc(1024 * 1024 * 30),
wasm.fn = { wasm.fn = {
diff: exports.poly_diff, diff: exports.poly_diff,
union: exports.poly_union, union: exports.poly_union,

View file

@ -479,7 +479,7 @@
if (!isSynth && !vaseMode) { if (!isSynth && !vaseMode) {
// sparse layers only present when non-vase mose and sparse % > 0 // sparse layers only present when non-vase mose and sparse % > 0
let lastType; let lastType;
let promises = false && isConcurrent ? [] : undefined; let promises = isConcurrent ? [] : undefined;
forSlices(0.5, promises ? 0.55 : 0.7, slice => { forSlices(0.5, promises ? 0.55 : 0.7, slice => {
let params = slice.params || process; let params = slice.params || process;
if (!params.sliceFillSparse) { if (!params.sliceFillSparse) {
@ -496,7 +496,7 @@
bounds: widget.getBoundingBox(), bounds: widget.getBoundingBox(),
height: sliceHeight, height: sliceHeight,
type: newType, type: newType,
cache: params._range !== true && lastType === newType && !isConcurrent, cache: params._range !== true && lastType === newType,
promises promises
}); });
lastType = newType; lastType = newType;
@ -506,6 +506,16 @@
trackupdate(i / t, 0.55, 0.7); trackupdate(i / t, 0.55, 0.7);
}); });
} }
// back-fill slices marked for infill cloning
for (let slice of slices) {
if (slice._clone_sparse) {
let tops = slice.tops;
let down = slice.down.tops;
for (let i=0; i<tops.length; i++) {
tops[i].fill_sparse = down[i].fill_sparse.map(p => p.cloneZ(slice.z));
}
}
}
} else if (isSynth) { } else if (isSynth) {
// fill manual supports differently // fill manual supports differently
let promises = isConcurrent ? [] : undefined; let promises = isConcurrent ? [] : undefined;
@ -943,20 +953,15 @@
if (skippable && slice.fingerprintSame(down)) { if (skippable && slice.fingerprintSame(down)) {
// the fill fingerprint can slightly different because of solid projections // the fill fingerprint can slightly different because of solid projections
if (down._fill_finger && POLY.fingerprintCompare(slice._fill_finger, down._fill_finger)) { if (down._fill_finger && POLY.fingerprintCompare(slice._fill_finger, down._fill_finger)) {
// console.log({fill_clone: down.index});
for (let i=0; i<tops.length; i++) { for (let i=0; i<tops.length; i++) {
// the layer below may not have infill computed if it's solid // the layer below may not have infill computed if it's solid
if (down.tops[i].fill_sparse) { if (!down.tops[i].fill_sparse) {
// tops[i].fill_sparse = down.tops[i].fill_sparse.map(p => p.cloneZ(slice.z));
tops[i].fill_sparse = down.tops[i].fill_sparse.map(poly => {
return poly.clone().setZ(slice.z);
});
} else {
miss = true; miss = true;
} }
} }
// if any of the fills as missing from below, re-compute // mark for infill cloning if nothing is missing
if (!miss) { if (!miss) {
slice._clone_sparse = true;
return; return;
} }
} }