wip
This commit is contained in:
parent
49a5acf73b
commit
5123573822
@ -1,3 +1,5 @@
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
use crate::{aabb::Aabb,integer::Planar64Vec3};
|
||||
|
||||
//da algaritum
|
||||
@ -57,18 +59,29 @@ impl<L> BvhNode<L>{
|
||||
},
|
||||
}
|
||||
}
|
||||
pub fn sample_ray<C:SampleRayContext>(&self,ray:&Ray,context:&mut C){
|
||||
fn populate_nodes<T>(&self,ray:&Ray,start_time:T,nodes:&mut BTreeMap<T,&BvhNode<L>>){
|
||||
// Am I an upcoming superstar?
|
||||
if let Some(t)=self.aabb.intersect_ray(ray){
|
||||
if start_time<t{
|
||||
nodes.insert(t,self);
|
||||
}
|
||||
}
|
||||
match &self.content{
|
||||
RecursiveContent::Leaf(model)=>context.sample(model),
|
||||
RecursiveContent::Branch(children)=>{
|
||||
if self.aabb.contains(ray.origin){
|
||||
for child in children{
|
||||
child.sample_ray(aabb,f);
|
||||
}
|
||||
RecursiveContent::Leaf(_)=>(),
|
||||
RecursiveContent::Branch(children)=>for child in children{
|
||||
if child.aabb.contains(point){
|
||||
child.populate_nodes(point,f);
|
||||
}else{
|
||||
// check if child will
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
pub fn sample_ray<F:FnMut(&L)>(&self,ray:&Ray,f:&mut F){
|
||||
let mut nodes=BTreeMap::new();
|
||||
// perform a normal sample aabb at point ray.origin
|
||||
self.populate_nodes(point,f);
|
||||
}
|
||||
pub fn into_inner(self)->(RecursiveContent<BvhNode<L>,L>,Aabb){
|
||||
(self.content,self.aabb)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user