pub struct Aabb {
pub min: Vec3,
pub max: Vec3,
}Expand description
Axis-aligned bounding box for broad-phase collision detection.
Fields§
§min: Vec3Minimum corner of the bounding box.
max: Vec3Maximum corner of the bounding box.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub fn intersects(&self, other: &Aabb) -> bool
pub fn intersects(&self, other: &Aabb) -> bool
Check whether this AABB intersects another.
Sourcepub fn merge(&self, other: &Aabb) -> Self
pub fn merge(&self, other: &Aabb) -> Self
Merge this AABB with another, returning the smallest AABB containing both.
Sourcepub fn contains_point(&self, point: &Vec3) -> bool
pub fn contains_point(&self, point: &Vec3) -> bool
Check if a point is inside the AABB.
Sourcepub fn half_extents(&self) -> Vec3
pub fn half_extents(&self) -> Vec3
Half-extents of the AABB.
Sourcepub fn surface_area(&self) -> Real
pub fn surface_area(&self) -> Real
Surface area of the AABB.
Source§impl Aabb
impl Aabb
Sourcepub fn from_center_half_extents(center: Vec3, half_extents: Vec3) -> Self
pub fn from_center_half_extents(center: Vec3, half_extents: Vec3) -> Self
Create an AABB from a center point and half-extents.
Sourcepub fn from_points(points: &[Vec3]) -> Option<Self>
pub fn from_points(points: &[Vec3]) -> Option<Self>
Create an AABB enclosing a set of points.
Sourcepub fn longest_axis(&self) -> usize
pub fn longest_axis(&self) -> usize
Longest axis (0=x, 1=y, 2=z).
Source§impl Aabb
impl Aabb
Sourcepub fn ray_intersect(&self, ray: &Ray) -> Option<RayAabbHit>
pub fn ray_intersect(&self, ray: &Ray) -> Option<RayAabbHit>
Test whether ray intersects this AABB using the slab method.
Returns Some(hit) with the entry/exit t values if the ray hits,
or None if it misses. Handles degenerate (zero-direction) rays.
Sourcepub fn ray_hit_t(&self, ray: &Ray) -> Option<Real>
pub fn ray_hit_t(&self, ray: &Ray) -> Option<Real>
Test ray against AABB and return just the entry t (simpler API).
Sourcepub fn swept_aabb(half_extents: Vec3, from: &Transform, to: &Transform) -> Aabb
pub fn swept_aabb(half_extents: Vec3, from: &Transform, to: &Transform) -> Aabb
Compute the AABB of the swept volume as the box moves from transform_a
to transform_b (uses the merge of two oriented boxes).
Sourcepub fn oriented_box_aabb(half_extents: Vec3, transform: &Transform) -> Aabb
pub fn oriented_box_aabb(half_extents: Vec3, transform: &Transform) -> Aabb
Compute the AABB enclosing an oriented box (defined by half-extents and a transform).
Sourcepub fn intersection(&self, other: &Aabb) -> Option<Aabb>
pub fn intersection(&self, other: &Aabb) -> Option<Aabb>
Compute the intersection (overlap) AABB of two boxes.
Returns None if the boxes do not overlap.
Sourcepub fn sq_distance_to_point(&self, point: &Vec3) -> Real
pub fn sq_distance_to_point(&self, point: &Vec3) -> Real
Compute the squared distance from a point to the nearest point on the AABB surface.
Returns 0 if the point is inside the AABB.
Sourcepub fn closest_point(&self, point: &Vec3) -> Vec3
pub fn closest_point(&self, point: &Vec3) -> Vec3
Return the closest point on (or inside) the AABB to point.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin for Aabb
impl UnsafeUnpin for Aabb
impl UnwindSafe for Aabb
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.