diff --git a/lib/common/src/bvh.rs b/lib/common/src/bvh.rs index 836cf8c..938cffe 100644 --- a/lib/common/src/bvh.rs +++ b/lib/common/src/bvh.rs @@ -154,7 +154,12 @@ impl<L> BvhNode<L>{ F:Fn(&L,&Ray)->Option<T>, { match &self.content{ - RecursiveContent::Leaf(leaf)=>collector.collect(f(leaf,ray).map(|time|TimedInstruction{time:time.into(),instruction:leaf})), + RecursiveContent::Leaf(leaf)=>if let Some(time)=f(leaf,ray){ + let ins=TimedInstruction{time:time.into(),instruction:leaf}; + if start_time.lt_ratio(ins.time)&&ins.time.lt_ratio(collector.time()){ + collector.collect(Some(ins)); + } + }, RecursiveContent::Branch(children)=>for child in children{ if child.aabb.contains(ray.origin){ child.populate_nodes(collector,nodes,ray,start_time,f); @@ -197,7 +202,12 @@ impl<L> BvhNode<L>{ break; } match &node.content{ - RecursiveContent::Leaf(leaf)=>collector.collect(f(leaf,ray).map(|time|TimedInstruction{time:time.into(),instruction:leaf})), + RecursiveContent::Leaf(leaf)=>if let Some(time)=f(leaf,ray){ + let ins=TimedInstruction{time:time.into(),instruction:leaf}; + if start_time.lt_ratio(ins.time)&&ins.time.lt_ratio(collector.time()){ + collector.collect(Some(ins)); + } + }, // break open the node and predict collisions with the child nodes RecursiveContent::Branch(children)=>for child in children{ // Am I an upcoming superstar?