fix: correct GPU overlap detection coordinate system mismatch

The GPU pair evaluator reported false-positive overlaps for all
candidates because the bitmap coordinate system didn't account for
Part.CreateAtOrigin's Location offset. When rotation produced negative
coordinates, CreateAtOrigin sets Location = -bbox.Location (non-zero),
but the offset formula assumed Location was always (0,0).

Two fixes:
- Rasterize bitmaps from Part.CreateAtOrigin directly (new FromPart
  method) instead of separately rotating polygons and computing bbox,
  eliminating any Polygon.Rotate vs Program.Rotate mismatch
- Correct offset formula to include the Location shift:
  (Part2Offset - partB.Location) instead of raw Part2Offset

Also optimized post-kernel bounding computation: pre-compute vertices
once per rotation group and process results with Parallel.For, matching
the CPU evaluator's concurrency.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-10 07:00:21 -04:00
parent 079a44052c
commit b55aa7ab42
3 changed files with 171 additions and 61 deletions

View File

@@ -6,6 +6,7 @@ using System.Reflection;
using System.Windows.Forms;
using OpenNest.Actions;
using OpenNest.Collections;
using OpenNest.Engine.BestFit;
using OpenNest.Gpu;
using OpenNest.Geometry;
using OpenNest.IO;
@@ -41,6 +42,9 @@ namespace OpenNest.Forms
EnableCheck();
UpdateStatus();
UpdateGpuStatus();
if (GpuEvaluatorFactory.GpuAvailable)
BestFitCache.CreateEvaluator = (drawing, spacing) => GpuEvaluatorFactory.Create(drawing, spacing);
}
private string GetNestName(DateTime date, int id)