fix belt layout, diff with anchors

This commit is contained in:
Stewart Allen 2022-03-03 12:27:49 -05:00
commit 703e63e08e
3 changed files with 28 additions and 32 deletions

View file

@ -26,6 +26,7 @@
* `C` add parameterized control of bridge/flat and infill print speeds * `C` add parameterized control of bridge/flat and infill print speeds
* `P` template vars: nozzles used and layers until next use (IDEX) * `P` template vars: nozzles used and layers until next use (IDEX)
* `-` improved vertex replacement and widget update matrix tracking * `-` improved vertex replacement and widget update matrix tracking
* `-` api control over (non) threaded workloads and wasm
## Mesh:Tool ## Mesh:Tool

View file

@ -1064,7 +1064,7 @@ function doSparseLayerFill(slice, options = {}) {
*/ */
function doDiff(slice, options = {}) { function doDiff(slice, options = {}) {
const { sla, fakedown, grow, min } = options; const { sla, fakedown, grow, min } = options;
if (slice.index === 0 && !fakedown) { if (slice.index <= 0 && !fakedown) {
return; return;
} }
const top = slice, const top = slice,

View file

@ -567,47 +567,23 @@ function platformLayout(event, gap) {
// space parts to account for anchor in belt mode // space parts to account for anchor in belt mode
if (isBelt) { if (isBelt) {
gap += process.firstLayerBeltLead || 0; gap += process.firstLayerBeltLead || 0;
}
let i, m, sz = isBelt ? {
x: 1,
y: 100000
} : space.platform.size(),
mp = [sz.x, sz.y],
ms = [mp[0] / 2, mp[1] / 2],
c = Widget.Groups.blocks().sort(moto.Sort),
p = new kiri.Pack(ms[0], ms[1], gap).fit(c);
while (!p.packed) {
ms[0] *= 1.1;
ms[1] *= 1.1;
p = new kiri.Pack(ms[0], ms[1], gap).fit(c);
}
for (i = 0; i < c.length; i++) {
m = c[i];
m.fit.x += m.w / 2 + p.pad;
m.fit.y += m.h / 2 + p.pad;
m.move(p.max.w / 2 - m.fit.x, p.max.h / 2 - m.fit.y, 0, true);
// m.material.visible = true;
}
if (isBelt) {
const WIDGETS = api.widgets.all(); const WIDGETS = api.widgets.all();
let bounds = platformUpdateBounds(), let bounds = platformUpdateBounds(),
movey = -(device.bedDepth / 2 + bounds.min.y); movey = -(device.bedDepth / 2);
api.widgets.each(widget => { for (let widget of WIDGETS) {
let ylen = widget.track.box.h;
// only move the root widget in the group // only move the root widget in the group
if (widget.id === widget.group.id) { if (widget.id === widget.group.id) {
widget.move(0, movey, 0); widget.move(0, movey + ylen/2, 0, true);
movey += ylen + gap;
} }
}); }
if (controller.spaceLayout === 0) { if (controller.spaceLayout === 0) {
let sum = 0; let sum = 0;
let sorted = WIDGETS.sort((a, b) => a.track.pos.y - b.track.pos.y); let sorted = WIDGETS.sort((a, b) => a.track.pos.y - b.track.pos.y);
sorted.forEach(w => { sorted.forEach(w => {
w.move(0, sum, 0); w.move(0, sum, 0);
sum += w.track.box.d + 1; sum += w.track.box.d + 1 + gap;
}); });
} }
if (controller.spaceRandoX) { if (controller.spaceRandoX) {
@ -617,6 +593,25 @@ function platformLayout(event, gap) {
0, 0); 0, 0);
} }
} }
} else {
let i, m, sz = space.platform.size(),
mp = [sz.x, sz.y],
ms = [mp[0] / 2, mp[1] / 2],
c = Widget.Groups.blocks().sort(moto.Sort),
p = new kiri.Pack(ms[0], ms[1], gap).fit(c);
while (!p.packed) {
ms[0] *= 1.1;
ms[1] *= 1.1;
p = new kiri.Pack(ms[0], ms[1], gap).fit(c);
}
for (i = 0; i < c.length; i++) {
m = c[i];
m.fit.x += m.w / 2 + p.pad;
m.fit.y += m.h / 2 + p.pad;
m.move(p.max.w / 2 - m.fit.x, p.max.h / 2 - m.fit.y, 0, true);
}
} }
platform.update_origin(); platform.update_origin();