Skip to content

fix: clean up orphaned BVH nodes when remove creates a partial root#409

Open
robtfm wants to merge 1 commit intodimforge:masterfrom
robtfm:fix-bvh-remove-orphaned-nodes
Open

fix: clean up orphaned BVH nodes when remove creates a partial root#409
robtfm wants to merge 1 commit intodimforge:masterfrom
robtfm:fix-bvh-remove-orphaned-nodes

Conversation

@robtfm
Copy link
Copy Markdown
Contributor

@robtfm robtfm commented Mar 24, 2026

Summary

  • When multiple Bvh::remove calls occur without an intervening refit, orphaned wide nodes accumulate in the nodes vector (by design — the comment says "it will get cleaned up at the next refit"). However, if the root is then reduced to a single leaf (partial root), those orphaned nodes remain, causing optimize_incremental to operate on a corrupt tree structure.
  • This adds a truncate(1) for both nodes and parents after creating a partial root, since only node[0] is reachable in that state.

🤖 Generated with Claude Code

When multiple removes occur without an intervening refit, orphaned wide
nodes accumulate in the nodes vector. If the root is then reduced to a
single leaf (partial root), those orphaned nodes remain, causing
optimize_incremental to operate on a corrupt tree and eventually crash.

Truncate nodes and parents to 1 after creating a partial root, since
only node[0] is reachable in that state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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