Fill: plant nothing for a region that misses the object entirely
Build image / build-and-push (push) Successful in 8s

clampTo INVERTS a region lying wholly outside the object — Max clamps below
Min — rather than emptying it. The old loop-until-past-MaxX form handled that
for free by never entering the loop. Counting positions up front does not:
a region 500cm east of a bed with ±50cm local bounds produced 4 plops at
x=275, a couple of metres off the bed.

Caught by removing the guard and watching the new test fail, not by assuming
it would.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01H3zbym8Doka2d7D48maSgZ
This commit is contained in:
2026-07-21 10:13:33 -04:00
co-authored by Claude Opus 4.8
parent 45da4b15e2
commit 3af0d08779
2 changed files with 28 additions and 0 deletions
+7
View File
@@ -195,6 +195,13 @@ func hexCenters(r Region, radius, spacing float64) []localPoint {
if radius <= 0 {
return nil
}
// clampTo INVERTS a region that lies wholly outside the object (Max clamps
// below Min), and an inverted region has no inside to plant. The old
// loop-until-past-MaxX form got this for free by never entering the loop;
// counting positions up front does not, and would site a plop off the bed.
if r.MaxX < r.MinX || r.MaxY < r.MinY {
return nil
}
pitch := 2 * radius
rowH := pitch * math.Sqrt(3) / 2