rtiow: BVHTriangles use BVHNode::cost for readability.
This commit is contained in:
parent
450342c3d4
commit
0158f9ea15
@ -27,6 +27,11 @@ impl BVHNode {
|
||||
fn is_leaf(&self) -> bool {
|
||||
self.tri_count > 0
|
||||
}
|
||||
|
||||
fn cost(&self) -> f32 {
|
||||
let area = self.aabb.area();
|
||||
self.tri_count as f32 * area
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, PartialEq)]
|
||||
@ -236,16 +241,14 @@ where
|
||||
axis: best_axis,
|
||||
}
|
||||
}
|
||||
fn subdivide(&mut self, idx: usize) {
|
||||
let node = &self.bvh_nodes[idx];
|
||||
let parent_area = node.aabb.area();
|
||||
let parent_cost = node.tri_count as f32 * parent_area;
|
||||
|
||||
fn subdivide(&mut self, idx: usize) {
|
||||
let (left_first, tri_count, left_count, i) = {
|
||||
let node = &self.bvh_nodes[idx];
|
||||
let split = self.find_best_split_plane(&node);
|
||||
let no_split_cost = node.cost();
|
||||
// Stop subdividing if it isn't getting any better.
|
||||
if split.cost >= parent_cost {
|
||||
if split.cost >= no_split_cost {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user