pub struct BoundingBox {
pub min_x: i32,
pub min_y: i32,
pub min_z: i32,
pub max_x: i32,
pub max_y: i32,
pub max_z: i32,
}Expand description
An integer axis-aligned bounding box for structure pieces.
Corresponds to vanilla’s BoundingBox (not the float AABB/AABBd
for block shapes or entity collision). Coordinates are absolute world block positions.
Fields§
§min_x: i32Minimum X coordinate (inclusive).
min_y: i32Minimum Y coordinate (inclusive).
min_z: i32Minimum Z coordinate (inclusive).
max_x: i32Maximum X coordinate (inclusive).
max_y: i32Maximum Y coordinate (inclusive).
max_z: i32Maximum Z coordinate (inclusive).
Implementations§
Source§impl BoundingBox
impl BoundingBox
Sourcepub const fn new(x1: i32, y1: i32, z1: i32, x2: i32, y2: i32, z2: i32) -> Self
pub const fn new(x1: i32, y1: i32, z1: i32, x2: i32, y2: i32, z2: i32) -> 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 const fn intersects(&self, other: &Self) -> bool
pub const fn intersects(&self, other: &Self) -> bool
Returns whether this bounding box intersects another.
Sourcepub const fn intersects_xz(
&self,
min_x: i32,
min_z: i32,
max_x: i32,
max_z: i32,
) -> bool
pub const fn intersects_xz( &self, min_x: i32, min_z: i32, max_x: i32, max_z: i32, ) -> bool
Returns whether this bounding box intersects the given XZ range.
Sourcepub const fn is_inside(&self, pos: BlockPos) -> bool
pub const fn is_inside(&self, pos: BlockPos) -> bool
Returns whether the given block position is inside this bounding box.
Sourcepub const fn contains_xyz(&self, x: i32, y: i32, z: i32) -> bool
pub const fn contains_xyz(&self, x: i32, y: i32, z: i32) -> bool
Returns whether the given coordinates are inside this bounding box.
Sourcepub const fn get_center(&self) -> BlockPos
pub const fn get_center(&self) -> BlockPos
Returns the center of this bounding box.
Sourcepub const fn get_x_span(&self) -> i32
pub const fn get_x_span(&self) -> i32
Returns the span (size) along the X axis.
Sourcepub const fn get_y_span(&self) -> i32
pub const fn get_y_span(&self) -> i32
Returns the span (size) along the Y axis.
Sourcepub const fn get_z_span(&self) -> i32
pub const fn get_z_span(&self) -> i32
Returns the span (size) along the Z axis.
Sourcepub const fn encapsulating(a: &Self, b: &Self) -> Self
pub const fn encapsulating(a: &Self, b: &Self) -> Self
Returns the smallest bounding box that contains both a and b.
Sourcepub const fn moved(&self, dx: i32, dy: i32, dz: i32) -> Self
pub const fn moved(&self, dx: i32, dy: i32, dz: i32) -> Self
Returns a new bounding box moved by the given offset.
Sourcepub const fn inflated_by(&self, x: i32, y: i32, z: i32) -> Self
pub const fn inflated_by(&self, x: i32, y: i32, z: i32) -> Self
Returns a new bounding box inflated by the given amounts on each axis.
Trait Implementations§
Source§impl Clone for BoundingBox
impl Clone for BoundingBox
Source§fn clone(&self) -> BoundingBox
fn clone(&self) -> BoundingBox
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BoundingBox
Source§impl Debug for BoundingBox
impl Debug for BoundingBox
impl Eq for BoundingBox
Source§impl Hash for BoundingBox
impl Hash for BoundingBox
Source§impl PartialEq for BoundingBox
impl PartialEq for BoundingBox
Source§fn eq(&self, other: &BoundingBox) -> bool
fn eq(&self, other: &BoundingBox) -> bool
self and other values to be equal, and is used by ==.Source§impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for BoundingBox
impl<'de, WincodeConfig: Config> SchemaRead<'de, WincodeConfig> for BoundingBox
type Dst = BoundingBox
Source§fn read(
reader: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> ReadResult<()>
fn read( reader: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> ReadResult<()>
Source§impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for BoundingBox
impl<WincodeConfig: Config> SchemaWrite<WincodeConfig> for BoundingBox
impl StructuralPartialEq for BoundingBox
Auto Trait Implementations§
impl Freeze for BoundingBox
impl RefUnwindSafe for BoundingBox
impl Send for BoundingBox
impl Sync for BoundingBox
impl Unpin for BoundingBox
impl UnsafeUnpin for BoundingBox
impl UnwindSafe for BoundingBox
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<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
impl<'de, T, C> Deserialize<'de, C> for Twhere
C: Config,
T: SchemaRead<'de, C>,
§fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>
fn deserialize(src: &'de [u8], config: C) -> Result<Self::Dst, ReadError>
Self::Dst.§fn deserialize_into(
src: &'de [u8],
dst: &mut MaybeUninit<Self::Dst>,
config: C,
) -> Result<(), ReadError>
fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, config: C, ) -> Result<(), ReadError>
dst.§impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
impl<'de, T> Deserialize<'de> for Twhere
T: SchemaRead<'de, Configuration>,
§fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>
fn deserialize(src: &'de [u8]) -> Result<Self::Dst, ReadError>
src bytes into a new Self::Dst.§fn deserialize_into(
src: &'de [u8],
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_into( src: &'de [u8], dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
src bytes into dst.§impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
impl<T> DeserializeOwned for Twhere
T: SchemaReadOwned<Configuration>,
§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader] into a new Self::Dst.§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader] into dst.§impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
impl<T, C> DeserializeOwned<C> for Twhere
C: Config,
T: SchemaReadOwned<C>,
§fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
fn deserialize_from<'de>(src: impl Reader<'de>) -> Result<Self::Dst, ReadError>
Reader] into a new Self::Dst.§fn deserialize_from_into<'de>(
src: impl Reader<'de>,
dst: &mut MaybeUninit<Self::Dst>,
) -> Result<(), ReadError>
fn deserialize_from_into<'de>( src: impl Reader<'de>, dst: &mut MaybeUninit<Self::Dst>, ) -> Result<(), ReadError>
Reader] into dst.§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>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T, C> SchemaReadOwned<C> for Twhere
C: ConfigCore,
T: for<'de> SchemaRead<'de, C>,
§impl<T> Serialize for Twhere
T: SchemaWrite<Configuration> + ?Sized,
impl<T> Serialize for Twhere
T: SchemaWrite<Configuration> + ?Sized,
§fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src) -> Result<Vec<u8>, WriteError>
Vec of bytes.§fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
fn serialize_into(dst: impl Writer, src: &Self::Src) -> Result<(), WriteError>
§fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
fn serialized_size(src: &Self::Src) -> Result<u64, WriteError>
§impl<T, C> Serialize<C> for Twhere
C: Config,
T: SchemaWrite<C> + ?Sized,
impl<T, C> Serialize<C> for Twhere
C: Config,
T: SchemaWrite<C> + ?Sized,
§fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
fn serialize(src: &Self::Src, config: C) -> Result<Vec<u8>, WriteError>
Vec of bytes.§fn serialize_into(
dst: impl Writer,
src: &Self::Src,
config: C,
) -> Result<(), WriteError>
fn serialize_into( dst: impl Writer, src: &Self::Src, config: C, ) -> Result<(), WriteError>
Writer].