rtiow: remove need for right_child in BVHNode.
This commit is contained in:
parent
1d8aff7905
commit
4506418706
@ -16,7 +16,6 @@ use crate::{
|
|||||||
struct BVHNode {
|
struct BVHNode {
|
||||||
aabb: AABB,
|
aabb: AABB,
|
||||||
left_child: usize,
|
left_child: usize,
|
||||||
right_child: usize,
|
|
||||||
first_prim: usize,
|
first_prim: usize,
|
||||||
prim_count: usize,
|
prim_count: usize,
|
||||||
}
|
}
|
||||||
@ -80,7 +79,6 @@ where
|
|||||||
let root = BVHNode {
|
let root = BVHNode {
|
||||||
aabb: AABB::new(0f32.into(), 0f32.into()),
|
aabb: AABB::new(0f32.into(), 0f32.into()),
|
||||||
left_child: 0,
|
left_child: 0,
|
||||||
right_child: 0,
|
|
||||||
first_prim: 0,
|
first_prim: 0,
|
||||||
prim_count: self.triangles.len() - 1,
|
prim_count: self.triangles.len() - 1,
|
||||||
};
|
};
|
||||||
@ -139,18 +137,16 @@ where
|
|||||||
|
|
||||||
// create child nodes
|
// create child nodes
|
||||||
let left_child_idx = self.bvh_nodes.len();
|
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 {
|
let left = BVHNode {
|
||||||
aabb: AABB::new(0f32.into(), 0f32.into()),
|
aabb: AABB::new(0f32.into(), 0f32.into()),
|
||||||
left_child: 0,
|
left_child: 0,
|
||||||
right_child: 0,
|
|
||||||
first_prim: first_prim,
|
first_prim: first_prim,
|
||||||
prim_count: left_count,
|
prim_count: left_count,
|
||||||
};
|
};
|
||||||
let right = BVHNode {
|
let right = BVHNode {
|
||||||
aabb: AABB::new(0f32.into(), 0f32.into()),
|
aabb: AABB::new(0f32.into(), 0f32.into()),
|
||||||
left_child: 0,
|
left_child: 0,
|
||||||
right_child: 0,
|
|
||||||
first_prim: i as usize,
|
first_prim: i as usize,
|
||||||
prim_count: prim_count - left_count,
|
prim_count: prim_count - left_count,
|
||||||
};
|
};
|
||||||
@ -158,7 +154,6 @@ where
|
|||||||
self.bvh_nodes.push(right);
|
self.bvh_nodes.push(right);
|
||||||
let node = &mut self.bvh_nodes[idx];
|
let node = &mut self.bvh_nodes[idx];
|
||||||
node.left_child = left_child_idx;
|
node.left_child = left_child_idx;
|
||||||
node.right_child = right_child_idx;
|
|
||||||
node.prim_count = 0;
|
node.prim_count = 0;
|
||||||
|
|
||||||
// Recurse
|
// Recurse
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user