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:
@@ -355,7 +355,8 @@ namespace OpenNest.Controls
|
|||||||
LayoutPart hitPart = null;
|
LayoutPart hitPart = null;
|
||||||
for (var i = parts.Count - 1; i >= 0; --i)
|
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];
|
hitPart = parts[i];
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user