Skip to content

Commit

Permalink
Misc code clean up in kdtree build
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Oom committed Mar 25, 2024
1 parent 67b751f commit 1a826ab
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions kdtree/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,18 @@ where
B: KdTreeBuilder,
{
if depth >= max_depth || parent.triangle_indices.is_empty() {
return Box::new(KdNode::Leaf(parent.triangle_indices));
return KdNode::new_leaf(parent.triangle_indices);
}

match builder.find_best_split(depth, &parent) {
None => Box::new(KdNode::Leaf(parent.triangle_indices)),
None => KdNode::new_leaf(parent.triangle_indices),
Some(split) if builder.terminate(&parent, &split) => {
Box::new(KdNode::Leaf(parent.triangle_indices))
KdNode::new_leaf(parent.triangle_indices)
}
Some(split) => {
let left = build_helper(builder, max_depth, depth + 1, split.left);
let right = build_helper(builder, max_depth, depth + 1, split.right);
Box::new(KdNode::Node {
plane: split.plane,
left,
right,
})
KdNode::new_node(split.plane, left, right)
}
}
}
Expand Down

0 comments on commit 1a826ab

Please sign in to comment.