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) <noreply@anthropic.com>
This commit is contained in:
2026-04-07 15:55:22 -04:00
parent 3eab3c5946
commit 3a97253473

View File

@@ -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;