From 76b1e6af5433910a669d1bf922fca4ae942b73b3 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Tue, 27 Aug 2024 15:34:37 -0700 Subject: [PATCH] aabb --- src/aabb.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/aabb.rs b/src/aabb.rs index 7494fc4..6f9995c 100644 --- a/src/aabb.rs +++ b/src/aabb.rs @@ -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{