chiark / gitweb /
lowering: Cope when there are heavy pieces with clashing z coords
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Jul 2021 01:26:24 +0000 (02:26 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 19 Jul 2021 17:59:39 +0000 (18:59 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts

index ea277306840420bc56245182ae5d252d093a0b56..afa0414a9c24cb196cb7889aa19878be5cff5d0c 100644 (file)
@@ -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,