fix: prevent PushBoundingBox from making obstacles invisible to geometry push

PushBoundingBox left exactly partSpacing between bounding boxes, but the
geometry push inflates offset lines by halfSpacing + chordTolerance per
side (totaling partSpacing + 2*chordTolerance). The 0.002 overlap caused
RayEdgeDistance to return MaxValue for negative t, making the nearest
obstacle invisible and allowing the part to push through it.

Subtract 2*ChordTolerance from the BB push distance so the gap is wide
enough for the offset geometry lines to remain non-overlapping.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-24 23:07:46 -04:00
parent f626fbe063
commit 1f159d5dcc
2 changed files with 1 additions and 3 deletions

View File

@@ -157,7 +157,7 @@ namespace OpenNest.Engine.Fill
continue;
var gap = SpatialQuery.DirectionalGap(movingBox, obstacleBoxes[i], direction);
var d = gap - partSpacing;
var d = gap - partSpacing - 2 * ChordTolerance;
if (d < 0) d = 0;
if (d < distance)
distance = d;

View File

@@ -154,11 +154,9 @@ namespace OpenNest.Actions
default: hDir = PushDirection.Left; vDir = PushDirection.Down; break;
}
// Phase 1: BB-only push to get past irregular geometry quickly.
Compactor.PushBoundingBox(movingParts, plateView.Plate, hDir);
Compactor.PushBoundingBox(movingParts, plateView.Plate, vDir);
// Phase 2: Geometry push to settle against actual contours.
Compactor.Push(movingParts, plateView.Plate, hDir);
Compactor.Push(movingParts, plateView.Plate, vDir);