This commit is contained in:
Quaternions 2024-08-27 15:34:37 -07:00
parent 8a13307d98
commit 76b1e6af54

View File

@ -1,4 +1,4 @@
use crate::integer::Planar64Vec3;
use crate::integer::{Planar64,Planar64Vec3};
#[derive(Clone)]
pub struct Aabb{
@ -8,7 +8,7 @@ pub struct Aabb{
impl Default for Aabb{
fn default()->Self{
Self{min:Planar64Vec3::MAX,max:Planar64Vec3::MIN}
Self{min:Planar64Vec3::from_value(Planar64::MAX),max:Planar64Vec3::from_value(Planar64::MAX)}
}
}
@ -35,13 +35,14 @@ impl Aabb{
self.max+=hs;
}
pub fn intersects(&self,aabb:&Aabb)->bool{
(self.min.cmplt(aabb.max)&aabb.min.cmplt(self.max)).all()
let bvec=self.min.lt(aabb.max)&aabb.min.lt(self.max);
matches!(bvec.to_array(),[true,true,true])
}
pub fn size(&self)->Planar64Vec3{
self.max-self.min
}
pub fn center(&self)->Planar64Vec3{
self.min.midpoint(self.max)
self.min+(self.max-self.min).map(|v|v>>1)
}
//probably use floats for area & volume because we don't care about precision
// pub fn area_weight(&self)->f32{