From a4d6c00a8df6a8696f1daef9ce597f28639da384 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Sun, 20 Jun 2021 19:27:53 -0400 Subject: [PATCH] do not allow infill caching with concurrency --- src/kiri/slicer.js | 32 +++++++++++++++----------------- src/mode/fdm/slice.js | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/kiri/slicer.js b/src/kiri/slicer.js index efab6e25..7a434d07 100644 --- a/src/kiri/slicer.js +++ b/src/kiri/slicer.js @@ -137,7 +137,9 @@ if (bucketCount > 1) { // create empty buckets - for (i = 0; i < bucketCount + 1; i++) buckets.push([]); + for (i = 0; i < bucketCount + 1; i++) { + buckets.push({ points: []}); + } // copy triples into all matching z-buckets for (i = 0; i < points.length;) { @@ -150,11 +152,13 @@ bM = Math.ceil(zM * zScale); if (bm < 0) bm = 0; for (j = bm; j < bM; j++) { - buckets[j].push(p1); - buckets[j].push(p2); - buckets[j].push(p3); + buckets[j].points.push(p1); + buckets[j].points.push(p2); + buckets[j].points.push(p3); } } + } else { + buckets.push({ points }); } // we need Z ordered list for laser auto or adaptive fdm slicing @@ -267,7 +271,7 @@ zIndexes[i] -= -0.001; } // slice next layer and add to slices[] array - let slice = sliceZ(zIndexes[i], zHeights[i], onFlat, onLine, zThick[i]); + sliceZ(zIndexes[i], zHeights[i], onFlat, onLine, zThick[i]); onupdate(i / zIndexes.length); } @@ -365,18 +369,14 @@ function sliceZ(z, height, onflat, online, thick) { let phash = {}, lines = [], - slice = newSlice(z, options.view ? options.view.newGroup() : null), - bucket = bucketCount == 1 ? points : buckets[Math.floor(z * zScale)]; - - if (!bucket) { - return; - } + slice = newSlice(z), + points = buckets[Math.floor(z * zScale)].points; // iterate over matching buckets for this z offset - for (let i = 0; i < bucket.length;) { - p1 = bucket[i++]; - p2 = bucket[i++]; - p3 = bucket[i++]; + for (let i = 0; i < points.length; ) { + p1 = points[i++]; + p2 = points[i++]; + p3 = points[i++]; let where = {under: [], over: [], on: []}; checkUnderOverOn(p1, z, where); checkUnderOverOn(p2, z, where); @@ -447,8 +447,6 @@ }); slices.push(slice); - - return slice; } } diff --git a/src/mode/fdm/slice.js b/src/mode/fdm/slice.js index dba8eb8b..08cc8ea0 100644 --- a/src/mode/fdm/slice.js +++ b/src/mode/fdm/slice.js @@ -463,7 +463,7 @@ bounds: widget.getBoundingBox(), height: sliceHeight, type: newType, - cache: params._range !== true && lastType === newType, + cache: params._range !== true && lastType === newType && !doConcurrent, promises }); lastType = newType;