From 3a97253473a053a1a8d667e2a3367465a323ea05 Mon Sep 17 00:00:00 2001 From: AJ Isaacs Date: Tue, 7 Apr 2026 15:55:22 -0400 Subject: [PATCH] perf: add bounding box pre-check before Path.IsVisible in hover detection Path.IsVisible was consuming 52% of CPU on mouse move. Add a cheap GetBounds().Contains() check first so only parts under the cursor hit the expensive GDI+ path test. Co-Authored-By: Claude Opus 4.6 (1M context) --- OpenNest/Controls/PlateView.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OpenNest/Controls/PlateView.cs b/OpenNest/Controls/PlateView.cs index e6b1674..f57373a 100644 --- a/OpenNest/Controls/PlateView.cs +++ b/OpenNest/Controls/PlateView.cs @@ -355,7 +355,8 @@ namespace OpenNest.Controls LayoutPart hitPart = null; for (var i = parts.Count - 1; i >= 0; --i) { - if (parts[i].Path.IsVisible(graphPt)) + if (parts[i].Path.GetBounds().Contains(graphPt) && + parts[i].Path.IsVisible(graphPt)) { hitPart = parts[i]; break;