diff --git a/rtiow/src/bvh.rs b/rtiow/src/bvh.rs index 730cdef..38cf032 100644 --- a/rtiow/src/bvh.rs +++ b/rtiow/src/bvh.rs @@ -221,16 +221,25 @@ impl Hit for BVHNode { BVHNode::Branch { ref left, ref right, - .. - } => match (left.hit(r, t_min, t_max), right.hit(r, t_min, t_max)) { - (Some(hit_left), Some(hit_right)) => if hit_left.t < hit_right.t { - return Some(hit_left); - } else { - return Some(hit_right); - }, - (Some(hit_left), None) => Some(hit_left), - (None, Some(hit_right)) => Some(hit_right), - (None, None) => None, + ref bbox, + } => match bbox { + Some(ref bbox) => { + if bbox.hit(r, t_min, t_max) { + match (left.hit(r, t_min, t_max), right.hit(r, t_min, t_max)) { + (Some(hit_left), Some(hit_right)) => if hit_left.t < hit_right.t { + return Some(hit_left); + } else { + return Some(hit_right); + }, + (Some(hit_left), None) => return Some(hit_left), + (None, Some(hit_right)) => return Some(hit_right), + (None, None) => return None, + }; + } else { + return None; + } + } + None => None, }, } } @@ -252,7 +261,7 @@ impl BVH { let count = l.len(); let start = Instant::now(); let bvh = BVH { - root: BVHNode::new_sah(l, t_min, t_max), + root: BVHNode::new_dumb(l, t_min, t_max), }; let runtime = start.elapsed(); info!(