#[repr(C)]pub struct Aabb {
pub min: Vec3,
pub max: Vec3,
}Expand description
Represents an Axis-Aligned Bounding Box (AABB).
An AABB is a rectangular prism aligned with the coordinate axes, defined by its minimum and maximum corner points. It is a simple but highly efficient volume for broad-phase collision detection and visibility culling.
Fields§
§min: Vec3The corner of the box with the smallest coordinates on all axes.
max: Vec3The corner of the box with the largest coordinates on all axes.
Implementations§
Source§impl Aabb
impl Aabb
Sourcepub const INVALID: Aabb
pub const INVALID: Aabb
An invalid Aabb where min components are positive infinity and max are negative infinity.
This is useful as a neutral starting point for merging operations. Merging any
valid Aabb with INVALID will result in that valid Aabb.
Sourcepub fn from_min_max(min_pt: Vec3, max_pt: Vec3) -> Aabb
pub fn from_min_max(min_pt: Vec3, max_pt: Vec3) -> Aabb
Creates a new Aabb from two corner points.
This constructor automatically ensures that the min field holds the
component-wise minimum and max holds the component-wise maximum,
regardless of the order the points are passed in.
Sourcepub fn from_center_half_extents(center: Vec3, half_extents: Vec3) -> Aabb
pub fn from_center_half_extents(center: Vec3, half_extents: Vec3) -> Aabb
Creates a new Aabb from a center point and its half-extents.
The half-extents represent the distance from the center to the faces of the box.
The provided half_extents will be made non-negative.
Sourcepub fn from_half_extents(half_extents: Vec3) -> Aabb
pub fn from_half_extents(half_extents: Vec3) -> Aabb
Creates a new Aabb centered at the origin with the given half-extents.
Sourcepub fn from_point(point: Vec3) -> Aabb
pub fn from_point(point: Vec3) -> Aabb
Creates a degenerate Aabb containing a single point (min and max are the same).
Sourcepub fn from_points(points: &[Vec3]) -> Option<Aabb>
pub fn from_points(points: &[Vec3]) -> Option<Aabb>
Creates an Aabb that tightly encloses a given set of points.
§Returns
Returns Some(Aabb) if the input slice is not empty, otherwise None.
Sourcepub fn half_extents(&self) -> Vec3
pub fn half_extents(&self) -> Vec3
Calculates the half-extents (half the size on each axis) of the Aabb.
Sourcepub fn is_valid(&self) -> bool
pub fn is_valid(&self) -> bool
Checks if the Aabb is valid (i.e., min <= max on all axes).
Degenerate boxes where min == max are considered valid.
Sourcepub fn contains_point(&self, point: Vec3) -> bool
pub fn contains_point(&self, point: Vec3) -> bool
Checks if a point is contained within or on the boundary of the Aabb.
Sourcepub fn intersects_aabb(&self, other: &Aabb) -> bool
pub fn intersects_aabb(&self, other: &Aabb) -> bool
Checks if this Aabb intersects with another Aabb.
Two Aabbs intersect if they overlap on all three axes. Boxes that only
touch at the boundary are considered to be intersecting.
Sourcepub fn merge(&self, other: &Aabb) -> Aabb
pub fn merge(&self, other: &Aabb) -> Aabb
Creates a new Aabb that encompasses both this Aabb and another one.
Sourcepub fn merged_with_point(&self, point: Vec3) -> Aabb
pub fn merged_with_point(&self, point: Vec3) -> Aabb
Creates a new Aabb that encompasses both this Aabb and an additional point.
Sourcepub fn transform(&self, matrix: &Mat4) -> Aabb
pub fn transform(&self, matrix: &Mat4) -> Aabb
Computes the bounding box that encloses this Aabb after a transformation.
This method is more efficient than transforming all 8 corners of the box for affine transformations. It works by transforming the center of the box and then calculating the new extents by projecting the original extents onto the axes of the transformed space.
§Note
This method is designed for affine transformations (like rotation, translation, scale). It may not produce the tightest-fitting box for transformations involving perspective.
Sourcepub fn surface_area(&self) -> f32
pub fn surface_area(&self) -> f32
Calculates the surface area of the Aabb.
Useful for SAH (Surface Area Heuristic) in BVH construction.
Sourcepub fn contains_aabb(&self, other: &Aabb) -> bool
pub fn contains_aabb(&self, other: &Aabb) -> bool
Checks if this Aabb fully contains another Aabb.
Trait Implementations§
impl Copy for Aabb
impl StructuralPartialEq for Aabb
Auto Trait Implementations§
impl Freeze for Aabb
impl RefUnwindSafe for Aabb
impl Send for Aabb
impl Sync for Aabb
impl Unpin 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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
impl<F, T> IntoSample<T> for Fwhere
T: FromSample<F>,
fn into_sample(self) -> T
§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§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).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.