common: aabb: make function inline-able
This commit is contained in:
@@ -7,44 +7,55 @@ pub struct Aabb{
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Aabb{
|
impl Default for Aabb{
|
||||||
|
#[inline]
|
||||||
fn default()->Self{
|
fn default()->Self{
|
||||||
Self{min:vec3::MAX,max:vec3::MIN}
|
Self{min:vec3::MAX,max:vec3::MIN}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Aabb{
|
impl Aabb{
|
||||||
|
#[inline]
|
||||||
pub const fn new(min:Planar64Vec3,max:Planar64Vec3)->Self{
|
pub const fn new(min:Planar64Vec3,max:Planar64Vec3)->Self{
|
||||||
Self{min,max}
|
Self{min,max}
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub const fn max(&self)->Planar64Vec3{
|
pub const fn max(&self)->Planar64Vec3{
|
||||||
self.max
|
self.max
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub const fn min(&self)->Planar64Vec3{
|
pub const fn min(&self)->Planar64Vec3{
|
||||||
self.min
|
self.min
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn grow(&mut self,point:Planar64Vec3){
|
pub fn grow(&mut self,point:Planar64Vec3){
|
||||||
self.min=self.min.min(point);
|
self.min=self.min.min(point);
|
||||||
self.max=self.max.max(point);
|
self.max=self.max.max(point);
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn join(&mut self,aabb:&Aabb){
|
pub fn join(&mut self,aabb:&Aabb){
|
||||||
self.min=self.min.min(aabb.min);
|
self.min=self.min.min(aabb.min);
|
||||||
self.max=self.max.max(aabb.max);
|
self.max=self.max.max(aabb.max);
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn inflate(&mut self,hs:Planar64Vec3){
|
pub fn inflate(&mut self,hs:Planar64Vec3){
|
||||||
self.min-=hs;
|
self.min-=hs;
|
||||||
self.max+=hs;
|
self.max+=hs;
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn contains(&self,point:Planar64Vec3)->bool{
|
pub fn contains(&self,point:Planar64Vec3)->bool{
|
||||||
let bvec=self.min.lt(point)&point.lt(self.max);
|
let bvec=self.min.lt(point)&point.lt(self.max);
|
||||||
bvec.all()
|
bvec.all()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn intersects(&self,aabb:&Aabb)->bool{
|
pub fn intersects(&self,aabb:&Aabb)->bool{
|
||||||
let bvec=self.min.lt(aabb.max)&aabb.min.lt(self.max);
|
let bvec=self.min.lt(aabb.max)&aabb.min.lt(self.max);
|
||||||
bvec.all()
|
bvec.all()
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn size(&self)->Planar64Vec3{
|
pub fn size(&self)->Planar64Vec3{
|
||||||
self.max-self.min
|
self.max-self.min
|
||||||
}
|
}
|
||||||
|
#[inline]
|
||||||
pub fn center(&self)->Planar64Vec3{
|
pub fn center(&self)->Planar64Vec3{
|
||||||
self.min.map_zip(self.max,|(min,max)|min.midpoint(max))
|
self.min.map_zip(self.max,|(min,max)|min.midpoint(max))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user