diff --git a/rtiow/renderer/src/bvh_triangles.rs b/rtiow/renderer/src/bvh_triangles.rs index 1fe2dc9..67a598b 100644 --- a/rtiow/renderer/src/bvh_triangles.rs +++ b/rtiow/renderer/src/bvh_triangles.rs @@ -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