Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/partitioning/bvh/bvh_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2376,6 +2376,14 @@ impl Bvh {

// Now we can just clear the right leaf.
self.nodes[0].right = BvhNode::zeros();

// Clean up orphaned nodes. With a partial root, only node[0] is
// reachable. Previous removes may have left orphaned wide nodes
// that were waiting for refit to compact them. If we don't truncate
// here, the tree appears as a single-leaf tree with unreachable
// nodes, which corrupts optimize_incremental.
self.nodes.truncate(1);
self.parents.truncate(1);
} else {
// The sibling isn’t a leaf. It becomes the new root at index 0.
self.nodes[0] = self.nodes[self.nodes[sibling].children as usize];
Expand Down
Loading