pub struct ChunkPos<const CHUNK_SIZE: GridCoordinate>(pub Cube);Expand description
Type to distinguish chunk coordinates from cube coordinates.
Chunk math is generally just like cube math (hence the type of the field), but we
don’t want to confuse the two and forget to multiply or divide.
A ChunkPos([x, y, z]) identifies the chunk which contains the cubes with x coordinates
in the half-open range x * CHUNK_SIZE..(x + 1) * CHUNK_SIZE, and similarly for the
y and z axes.
The consequences are unspecified if CHUNK_SIZE is not positive.
Tuple Fields§
§0: CubeImplementations§
Source§impl<const CHUNK_SIZE: GridCoordinate> ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> ChunkPos<CHUNK_SIZE>
Sourcepub const fn new(
x: GridCoordinate,
y: GridCoordinate,
z: GridCoordinate,
) -> Self
pub const fn new( x: GridCoordinate, y: GridCoordinate, z: GridCoordinate, ) -> Self
Construct a ChunkPos from chunk coordinates
(i.e. successive numbers indicate adjacent chunks).
Sourcepub fn bounds(self) -> GridAab
pub fn bounds(self) -> GridAab
Returns the bounds of this chunk as a GridAab.
TODO: specify what happens if the result would overflow.
Sourcepub fn distance(self, other: Self) -> Distance
pub fn distance(self, other: Self) -> Distance
Returns the distance between the two given chunks. See the Distance for an
explanation of what that means.
Sourcepub fn min_distance_squared_from(self, origin_chunk: Self) -> GridCoordinate
pub fn min_distance_squared_from(self, origin_chunk: Self) -> GridCoordinate
Returns the squared distance along the shortest line from origin_chunk’s bounds
to this chunk’s bounds.
This is the same criterion that ChunkChart uses for
deciding whether a chunk is included in the chart or not.
Trait Implementations§
Source§impl<const CHUNK_SIZE: GridCoordinate> Clone for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> Clone for ChunkPos<CHUNK_SIZE>
Source§impl<const CHUNK_SIZE: GridCoordinate> Debug for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> Debug for ChunkPos<CHUNK_SIZE>
Source§impl<const CHUNK_SIZE: GridCoordinate> Hash for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> Hash for ChunkPos<CHUNK_SIZE>
Source§impl<const CHUNK_SIZE: GridCoordinate> PartialEq for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> PartialEq for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> Copy for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> Eq for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: GridCoordinate> StructuralPartialEq for ChunkPos<CHUNK_SIZE>
Auto Trait Implementations§
impl<const CHUNK_SIZE: i32> Freeze for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: i32> RefUnwindSafe for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: i32> Send for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: i32> Sync for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: i32> Unpin for ChunkPos<CHUNK_SIZE>
impl<const CHUNK_SIZE: i32> UnwindSafe for ChunkPos<CHUNK_SIZE>
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> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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