pub struct Aabb<T, I> {
min: T,
max: T,
p: PhantomData<I>,
}Expand description
Fields§
§min: TMinimum corner of the box.
max: TMaximum corner of the box.
p: PhantomData<I>Implementations§
Source§impl<T: AabbVector, I> Aabb<T, I>
impl<T: AabbVector, I> Aabb<T, I>
Sourcepub fn from_min_max(min: T, max: T) -> Self
pub fn from_min_max(min: T, max: T) -> Self
Creates an AABB ensuring min <= max on every axis.
Sourcepub fn inflate_xyz(self, x: T::Scalar, y: T::Scalar, z: T::Scalar) -> Self
pub fn inflate_xyz(self, x: T::Scalar, y: T::Scalar, z: T::Scalar) -> Self
Expands the box independently on each axis.
Sourcepub fn encapsulating(a: &Self, b: &Self) -> Self
pub fn encapsulating(a: &Self, b: &Self) -> Self
Returns the smallest AABB that contains both a and b.
Source§impl<I> Aabb<DVec3, I>
impl<I> Aabb<DVec3, I>
Sourcepub const fn min_corner(&self) -> DVec3
pub const fn min_corner(&self) -> DVec3
Returns the minimum corner.
Sourcepub const fn max_corner(&self) -> DVec3
pub const fn max_corner(&self) -> DVec3
Returns the maximum corner.
Sourcepub fn distance_to_sqr(self, point: DVec3) -> f64
pub fn distance_to_sqr(self, point: DVec3) -> f64
Returns the squared distance from point to this box.
Mirrors vanilla AABB.distanceToSqr.
Sourcepub const fn closest_point_to(self, point: DVec3) -> DVec3
pub const fn closest_point_to(self, point: DVec3) -> DVec3
Returns the closest point inside this box to point.
Mirrors the per-box clamp used by vanilla VoxelShape.closestPointTo.
Source§impl<I> Aabb<IVec3, I>
impl<I> Aabb<IVec3, I>
Sourcepub const fn min_corner(&self) -> IVec3
pub const fn min_corner(&self) -> IVec3
Returns the minimum corner.
Sourcepub const fn max_corner(&self) -> IVec3
pub const fn max_corner(&self) -> IVec3
Returns the maximum corner.
Source§impl<T: AabbVector, I> Aabb<T, I>
impl<T: AabbVector, I> Aabb<T, I>
Source§impl<T: AabbVector, I: Space> Aabb<T, I>
impl<T: AabbVector, I: Space> Aabb<T, I>
fn axis_overlaps( min1: T::Scalar, max1: T::Scalar, min2: T::Scalar, max2: T::Scalar, ) -> bool
fn axis_contains(min: T::Scalar, max: T::Scalar, v: T::Scalar) -> bool
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Returns true when this box has no positive volume on at least one axis.
Sourcepub fn intersects(self, other: Self) -> bool
pub fn intersects(self, other: Self) -> bool
Returns whether this bounding box intersects another.
Sourcepub fn intersects_bounds(self, min: T, max: T) -> bool
pub fn intersects_bounds(self, min: T, max: T) -> bool
Returns true if this box intersects the given bounds.
Sourcepub fn intersects_xz(
self,
min_x: T::Scalar,
min_z: T::Scalar,
max_x: T::Scalar,
max_z: T::Scalar,
) -> bool
pub fn intersects_xz( self, min_x: T::Scalar, min_z: T::Scalar, max_x: T::Scalar, max_z: T::Scalar, ) -> bool
Returns whether this bounding box intersects the given XZ range.
Source§impl<I: Space> Aabb<IVec3, I>
impl<I: Space> Aabb<IVec3, I>
Sourcepub fn contains_blockpos(self, pos: BlockPos) -> bool
pub fn contains_blockpos(self, pos: BlockPos) -> bool
Returns whether the given coordinates are inside this bounding box.
Source§impl<I: Space> Aabb<DVec3, I>
impl<I: Space> Aabb<DVec3, I>
Sourcepub const FULL_BLOCK: Self
pub const FULL_BLOCK: Self
A full block from (0, 0, 0) to (1, 1, 1).
Sourcepub const fn new(
min_x: f64,
min_y: f64,
min_z: f64,
max_x: f64,
max_y: f64,
max_z: f64,
) -> Self
pub const fn new( min_x: f64, min_y: f64, min_z: f64, max_x: f64, max_y: f64, max_z: f64, ) -> Self
Creates an AABB and normalizes endpoint order like vanilla AABB.
Source§impl Aabb<DVec3, BlockLocal>
impl Aabb<DVec3, BlockLocal>
Source§impl Aabb<DVec3, World>
impl Aabb<DVec3, World>
Sourcepub fn entity_box(x: f64, y: f64, z: f64, half_width: f64, height: f64) -> Self
pub fn entity_box(x: f64, y: f64, z: f64, half_width: f64, height: f64) -> Self
Creates an entity bounding box centered on X/Z and using y as feet.
Sourcepub fn expand_towards(self, delta: DVec3) -> Self
pub fn expand_towards(self, delta: DVec3) -> Self
Expands the box only in the direction of delta.
Sourcepub fn intersects_block(self, pos: BlockPos) -> bool
pub fn intersects_block(self, pos: BlockPos) -> bool
Returns true if this box intersects the full block at pos.
Source§impl Aabb<IVec3, Structure>
impl Aabb<IVec3, Structure>
Sourcepub const fn new(pos1: IVec3, pos2: IVec3) -> Self
pub const fn new(pos1: IVec3, pos2: IVec3) -> Self
Creates a new bounding box, normalizing so min <= max on each axis.
Sourcepub const fn from_corners(a: BlockPos, b: BlockPos) -> Self
pub const fn from_corners(a: BlockPos, b: BlockPos) -> Self
Creates a bounding box from two corner block positions.
Sourcepub fn distance_to_sqr(self, point: DVec3) -> f64
pub fn distance_to_sqr(self, point: DVec3) -> f64
Returns the squared distance from point to this box.
Mirrors vanilla AABB.distanceToSqr.
Trait Implementations§
impl<T: Copy, I: Copy> Copy for Aabb<T, I>
impl<T: Eq, I: Eq> Eq for Aabb<T, I>
impl<T: PartialEq, I: PartialEq> StructuralPartialEq for Aabb<T, I>
Auto Trait Implementations§
impl<T, I> Freeze for Aabb<T, I>where
T: Freeze,
impl<T, I> RefUnwindSafe for Aabb<T, I>where
T: RefUnwindSafe,
I: RefUnwindSafe,
impl<T, I> Send for Aabb<T, I>
impl<T, I> Sync for Aabb<T, I>
impl<T, I> Unpin for Aabb<T, I>
impl<T, I> UnsafeUnpin for Aabb<T, I>where
T: UnsafeUnpin,
impl<T, I> UnwindSafe for Aabb<T, I>where
T: UnwindSafe,
I: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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 moreArc<SyncMutex<>>