perf(layout): Prune force-overlap resolution with a uniform spatial grid#87
Merged
Merged
Conversation
Replace the all-pairs O(N^2) scan in resolve_force_overlaps with a uniform spatial grid that bins nodes by their top-left corner. Cell size is chosen so any two padded AABBs that actually overlap fall into the same or an adjacent cell, letting the per-pass cost scale with locality instead of N^2. Candidate pairs are sorted before traversal so HashMap iteration order does not affect output, and a 6x6 stress test guards against missed pairs.
Code Metrics Report
Details | | main (2a84f2a) | #87 (6720382) | +/- |
|---------------------|----------------|---------------|-------|
+ | Coverage | 94.6% | 94.7% | +0.0% |
| Files | 77 | 77 | 0 |
| Lines | 34196 | 34255 | +59 |
+ | Covered | 32383 | 32442 | +59 |
+ | Test Execution Time | 1m26s | 1m22s | -4s |Code coverage of files in pull request scope (95.7% → 95.7%)
Reported by octocov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Changes
cell_size = max(W, H) + padding, the threshold above which two padded AABBs cannot overlap(1,0),(0,1),(1,1),(-1,1)so each cross-cell pair is reported exactly once andsort_unstablemakes traversal independent ofHashMapiteration ordertest_resolve_force_overlaps_grid_handles_many_nodescovering a dense overlapping grid to lock in the spatial-pruning correctness