wip
This commit is contained in:
@ -1,3 +1,5 @@
|
|||||||
|
use std::collections::BTreeMap;
|
||||||
|
|
||||||
use crate::{aabb::Aabb,integer::Planar64Vec3};
|
use crate::{aabb::Aabb,integer::Planar64Vec3};
|
||||||
|
|
||||||
//da algaritum
|
//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{
|
match &self.content{
|
||||||
RecursiveContent::Leaf(model)=>context.sample(model),
|
RecursiveContent::Leaf(_)=>(),
|
||||||
RecursiveContent::Branch(children)=>{
|
RecursiveContent::Branch(children)=>for child in children{
|
||||||
if self.aabb.contains(ray.origin){
|
if child.aabb.contains(point){
|
||||||
for child in children{
|
child.populate_nodes(point,f);
|
||||||
child.sample_ray(aabb,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){
|
pub fn into_inner(self)->(RecursiveContent<BvhNode<L>,L>,Aabb){
|
||||||
(self.content,self.aabb)
|
(self.content,self.aabb)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user