directly visit all bvh nodes

This commit is contained in:
Quaternions 2024-07-24 14:41:35 -07:00
parent 33aa8d5d9c
commit 7e91c85822

View File

@ -40,6 +40,14 @@ impl<T:Copy+Eq+std::hash::Hash> BvhNode<T>{
}, },
} }
} }
pub fn into_visitor<F:FnMut(T)>(self,f:&mut F){
match self.content{
BvhNodeContent::Leaf(model)=>f(model),
BvhNodeContent::Branch(children)=>for child in children{
child.into_visitor(f)
},
}
}
} }
pub fn generate_bvh<T:Copy+Eq+std::hash::Hash>(boxen:Vec<(T,Aabb)>)->BvhNode<T>{ pub fn generate_bvh<T:Copy+Eq+std::hash::Hash>(boxen:Vec<(T,Aabb)>)->BvhNode<T>{