From c28d5d8c12afc8f5904c261ec894da8e820791b3 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Sun, 8 Mar 2026 14:20:13 -0400 Subject: [PATCH] fix: use CPU evaluator for best-fit cache, remove broken GPU dilation The GPU bitmap evaluator produces false overlap detections due to discretization errors at cell boundaries. Use the CPU PairEvaluator (exact geometric intersection) for now. Also remove the double-counted spacing dilation from GpuPairEvaluator for when GPU is revisited. Co-Authored-By: Claude Opus 4.6 --- OpenNest.Gpu/GpuPairEvaluator.cs | 7 ++++--- OpenNest/MainApp.cs | 3 --- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/OpenNest.Gpu/GpuPairEvaluator.cs b/OpenNest.Gpu/GpuPairEvaluator.cs index 8fc162d..bb985c4 100644 --- a/OpenNest.Gpu/GpuPairEvaluator.cs +++ b/OpenNest.Gpu/GpuPairEvaluator.cs @@ -33,8 +33,9 @@ namespace OpenNest.Gpu if (candidates.Count == 0) return new List(); - var dilation = _spacing / 2.0; - var bitmapA = PartBitmap.FromDrawing(_drawing, _cellSize, dilation); + // No dilation — candidate positions already include spacing + // (baked in by RotationSlideStrategy via half-spacing offset lines). + var bitmapA = PartBitmap.FromDrawing(_drawing, _cellSize); if (bitmapA.Width == 0 || bitmapA.Height == 0) return candidates.Select(c => MakeEmptyResult(c)).ToList(); @@ -53,7 +54,7 @@ namespace OpenNest.Gpu var groupItems = group.ToList(); // Rasterize B at this rotation - var bitmapB = PartBitmap.FromDrawingRotated(_drawing, rotation, _cellSize, dilation); + var bitmapB = PartBitmap.FromDrawingRotated(_drawing, rotation, _cellSize); if (bitmapB.Width == 0 || bitmapB.Height == 0) { diff --git a/OpenNest/MainApp.cs b/OpenNest/MainApp.cs index 0669280..67660c0 100644 --- a/OpenNest/MainApp.cs +++ b/OpenNest/MainApp.cs @@ -1,8 +1,6 @@ using System; using System.Windows.Forms; -using OpenNest.Engine.BestFit; using OpenNest.Forms; -using OpenNest.Gpu; namespace OpenNest { @@ -13,7 +11,6 @@ namespace OpenNest { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - BestFitCache.CreateEvaluator = GpuEvaluatorFactory.Create; Application.Run(new MainForm()); } }