From 6141a024363e71ed28818d2cf5ceddcb48699684 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 19 Jul 2021 02:26:24 +0100 Subject: [PATCH] lowering: Cope when there are heavy pieces with clashing z coords Signed-off-by: Ian Jackson --- templates/script.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/templates/script.ts b/templates/script.ts index ea277306..afa0414a 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -642,6 +642,7 @@ function lower_pieces(targets_todo: LowerTodoList): // if that is below topmost light target // <- tomove_light: insert targets from * here Q -> // <- tomove_misstacked: insert non-targets from * here Q -> + // <- heavy non-targets with clashing Z Coords X -> // A // A heavy non-targets (nomove_heavy) // <- tomove_heavy: insert all heavy targets here P -> @@ -733,6 +734,22 @@ function lower_pieces(targets_todo: LowerTodoList): return 'Internal error! Lower with no targets!'; } + while (nomove_heavy.length && + nomove_heavy[nomove_heavy.length-1].p.z == q_z_top) { + // Yowzer. We have to reset the Z coordinates on these heavy + // pieces, whose Z coordinate is the same as the stuff we are not + // touching, because otherwise there is no gap. + // + // Treating them as misstacked instead is sufficient, provided + // we put them at the front (bottom end) of the misstacked list. + // + // This is X in the chart. + // + let restack = nomove_heavy.pop()!; + console.log('LOWER CLASHING Z - RESTACKING', restack); + tomove_misstacked.unshift(restack); + } + type PlanEntry = { content: Entry[], // bottom to top z_top: ZCoord, -- 2.30.2