rtiow: remove need for right_child in BVHNode.

This commit is contained in:
Bill Thiede 2023-01-21 15:59:33 -08:00
parent 1d8aff7905
commit 4506418706

View File

@ -16,7 +16,6 @@ use crate::{
struct BVHNode {
aabb: AABB,
left_child: usize,
right_child: usize,
first_prim: usize,
prim_count: usize,
}
@ -80,7 +79,6 @@ where
let root = BVHNode {
aabb: AABB::new(0f32.into(), 0f32.into()),
left_child: 0,
right_child: 0,
first_prim: 0,
prim_count: self.triangles.len() - 1,
};
@ -139,18 +137,16 @@ where
// create child nodes
let left_child_idx = self.bvh_nodes.len();
let right_child_idx = self.bvh_nodes.len() + 1;
let right_child_idx = left_child_idx + 1;
let left = BVHNode {
aabb: AABB::new(0f32.into(), 0f32.into()),
left_child: 0,
right_child: 0,
first_prim: first_prim,
prim_count: left_count,
};
let right = BVHNode {
aabb: AABB::new(0f32.into(), 0f32.into()),
left_child: 0,
right_child: 0,
first_prim: i as usize,
prim_count: prim_count - left_count,
};
@ -158,7 +154,6 @@ where
self.bvh_nodes.push(right);
let node = &mut self.bvh_nodes[idx];
node.left_child = left_child_idx;
node.right_child = right_child_idx;
node.prim_count = 0;
// Recurse