Skip to content

Overlap Performance (Minimal)#27

Open
AmityWilder wants to merge 3 commits into
bsiever:masterfrom
AmityWilder:bsiever-overlap-perf-min
Open

Overlap Performance (Minimal)#27
AmityWilder wants to merge 3 commits into
bsiever:masterfrom
AmityWilder:bsiever-overlap-perf-min

Conversation

@AmityWilder

@AmityWilder AmityWilder commented Jun 8, 2026

Copy link
Copy Markdown

While this does not improve the overall algorithm of identifying what is overlapping what, it improves the overlap performance significantly through just one change that doesn't rely on structure implementations or hardware expectations.

The current implementation iterates over every selected element, checks against each unselected element, and then WITHIN each of those iterations, if there isn't an intersection, it iterates over every unselected element, again, within the "every unselected element" loop, to check a condition that gets cancelled out if an upcoming element is intersecting. This transforms a roughly $O(n^2)$ operation into an $O(n^3)$ operation that can be avoided by simply keeping track of whether there was an intersection at all and performing the "no intersections" branch all in one go.

The proposed solution does this: keeping track of whether a selected element is intersecting any unselected element and only performing the extra checks, once per selected element, if there are no intersections.

@AmityWilder AmityWilder changed the title Overlap Performance (Minimum) Overlap Performance (Minimal) Jun 8, 2026
@AmityWilder

Copy link
Copy Markdown
Author

Related to #7, but hopefully more agreeable due to only involving the reordering of conditions; not duplicating elements into temporary containers or using potentially faulty bounding boxes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant