Skip to content

fix(bvh): run check on root-level pairs in leaf_pairs - #465

Open
dundysm wants to merge 1 commit into
dimforge:masterfrom
dundysm:fix-leaf-pairs-root-check
Open

dundysm wants to merge 1 commit into
dimforge:masterfrom
dundysm:fix-leaf-pairs-root-check

Conversation

@dundysm

@dundysm dundysm commented Nov 11, 2026

Copy link
Copy Markdown

fixes #461

what

Bvh::leaf_pairs seeded its traversal with the root-level node pairs (next plus up to three stack entries) without calling check on them. LeafPairs::next returns any leaf/leaf pair it pops, so for trees of one or two leaves, or trees whose root has a leaf child, pairs that check rejects were yielded anyway. with the report's two disjoint trees it returned [(0, 0), (1, 0), (1, 1), (0, 1)] instead of [].

this runs check on every seeded pair before it is queued, the same way Leaves::new already does for the single-tree iterator (#372). the seeded next also requires both left roots to hold a leaf, so an empty root never comes out as a pair.

tests

  • new test_leaf_pairs_checks_root_pairs in bvh_tests.rs: disjoint trees of 1, 2 and 3 leaves yield nothing, and partially overlapping trees (1x1 up to 16x9 leaves) match a brute-force aabb check. it fails on master (1 leaves: unexpected pairs [(0, 0)]) and passes with the fix.
  • cargo test -p parry3d --lib (81 passed), cargo test -p parry2d --lib (98 passed), cargo test -p parry2d-f64 --lib bvh (5 passed).

leaf_pairs seeded its traversal with the root-level node pairs without
calling check on them, so a pair of root leaves was yielded even when
check rejected it. run check on every seeded pair, like Leaves::new does
for the single-tree iterator, and add a regression test.

Fixes dimforge#461

Signed-off-by: Dundy Pasupuleti <dundysm@gmail.com>
@dundysm

dundysm commented Nov 11, 2026

Copy link
Copy Markdown
Author

@sebcrozet small fix for #461; leaf_pairs now runs check on the seeded root-level pairs like Leaves::new does, with a regression test that fails on master. would appreciate a review when you have a moment.

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.

BUG: Bvh::leaf_pairs yields root-level leaf pairs without calling the check

1 participant