common: bvh: rename generics

This commit is contained in:
Quaternions 2025-02-06 11:56:35 -08:00
parent aace3bb2a3
commit 57552c1a6a

@ -10,27 +10,27 @@ use crate::aabb::Aabb;
//sort the centerpoints on each axis (3 lists) //sort the centerpoints on each axis (3 lists)
//bv is put into octant based on whether it is upper or lower in each list //bv is put into octant based on whether it is upper or lower in each list
pub enum RecursiveContent<R,T>{ pub enum RecursiveContent<N,L>{
Branch(Vec<R>), Branch(Vec<N>),
Leaf(T), Leaf(L),
} }
impl<R,T> RecursiveContent<R,T>{ impl<N,L> RecursiveContent<N,L>{
pub fn empty()->Self{ pub fn empty()->Self{
Self::Branch(Vec::new()) Self::Branch(Vec::new())
} }
} }
pub struct BvhNode<T>{ pub struct BvhNode<L>{
content:RecursiveContent<BvhNode<T>,T>, content:RecursiveContent<BvhNode<L>,L>,
aabb:Aabb, aabb:Aabb,
} }
impl<T> BvhNode<T>{ impl<L> BvhNode<L>{
pub fn empty()->Self{ pub fn empty()->Self{
Self{ Self{
content:RecursiveContent::empty(), content:RecursiveContent::empty(),
aabb:Aabb::default(), aabb:Aabb::default(),
} }
} }
pub fn sample_aabb<F:FnMut(&T)>(&self,aabb:&Aabb,f:&mut F){ pub fn sample_aabb<F:FnMut(&L)>(&self,aabb:&Aabb,f:&mut F){
match &self.content{ match &self.content{
RecursiveContent::Leaf(model)=>f(model), RecursiveContent::Leaf(model)=>f(model),
RecursiveContent::Branch(children)=>for child in children{ RecursiveContent::Branch(children)=>for child in children{
@ -44,10 +44,10 @@ impl<T> BvhNode<T>{
}, },
} }
} }
pub fn into_inner(self)->(RecursiveContent<BvhNode<T>,T>,Aabb){ pub fn into_inner(self)->(RecursiveContent<BvhNode<L>,L>,Aabb){
(self.content,self.aabb) (self.content,self.aabb)
} }
pub fn into_visitor<F:FnMut(T)>(self,f:&mut F){ pub fn into_visitor<F:FnMut(L)>(self,f:&mut F){
match self.content{ match self.content{
RecursiveContent::Leaf(model)=>f(model), RecursiveContent::Leaf(model)=>f(model),
RecursiveContent::Branch(children)=>for child in children{ RecursiveContent::Branch(children)=>for child in children{