Skip to main content

WorldAabb

Struct WorldAabb 

Source
pub struct WorldAabb {
    min_x: f64,
    min_y: f64,
    min_z: f64,
    max_x: f64,
    max_y: f64,
    max_z: f64,
}
Expand description

World-space axis-aligned box used by entity and collision physics.

Fields§

§min_x: f64§min_y: f64§min_z: f64§max_x: f64§max_y: f64§max_z: f64

Implementations§

Source§

impl WorldAabb

Source

pub const fn new( min_x: f64, min_y: f64, min_z: f64, max_x: f64, max_y: f64, max_z: f64, ) -> Self

Creates a world-space AABB and normalizes endpoint order like vanilla AABB.

Source

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.

Source

pub const fn min_x(self) -> f64

Returns the minimum X coordinate.

Source

pub const fn min_y(self) -> f64

Returns the minimum Y coordinate.

Source

pub const fn min_z(self) -> f64

Returns the minimum Z coordinate.

Source

pub const fn max_x(self) -> f64

Returns the maximum X coordinate.

Source

pub const fn max_y(self) -> f64

Returns the maximum Y coordinate.

Source

pub const fn max_z(self) -> f64

Returns the maximum Z coordinate.

Source

pub const fn min(self, axis: Axis) -> f64

Returns the minimum coordinate on axis.

Source

pub const fn max(self, axis: Axis) -> f64

Returns the maximum coordinate on axis.

Source

pub const fn is_empty(self) -> bool

Returns true when this box has no positive volume on at least one axis.

Source

pub fn width(self) -> f64

Returns the X size.

Source

pub fn height(self) -> f64

Returns the Y size.

Source

pub fn depth(self) -> f64

Returns the Z size.

Source

pub fn size(self) -> f64

Vanilla equivalent: AABB.getSize().

Source

pub fn move_by(self, dx: f64, dy: f64, dz: f64) -> Self

Returns this box translated by the given delta.

Source

pub fn move_vec(self, delta: DVec3) -> Self

Returns this box translated by delta.

Source

pub fn inflate(self, amount: f64) -> Self

Returns this box expanded by amount in every direction.

Source

pub fn inflate_xyz(self, x: f64, y: f64, z: f64) -> Self

Returns this box expanded independently on each axis.

Source

pub fn deflate(self, amount: f64) -> Self

Returns this box shrunk by amount in every direction.

Source

pub fn expand_towards(self, delta: DVec3) -> Self

Returns this box expanded only in the direction of delta.

Source

pub fn intersects(self, other: Self) -> bool

Returns true if this box intersects other.

Source

pub fn intersects_coords( self, min_x: f64, min_y: f64, min_z: f64, max_x: f64, max_y: f64, max_z: f64, ) -> bool

Returns true if this box intersects the given raw coordinate bounds.

Source

pub fn intersects_block(self, pos: BlockPos) -> bool

Returns true if this box intersects the full block at pos.

Source

pub fn contains(self, x: f64, y: f64, z: f64) -> bool

Returns true if the point lies inside this box.

Trait Implementations§

Source§

impl Clone for WorldAabb

Source§

fn clone(&self) -> WorldAabb

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for WorldAabb

Source§

impl Debug for WorldAabb

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for WorldAabb

Source§

fn eq(&self, other: &WorldAabb) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for WorldAabb

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more