pub struct ChunkCoord {
pub x: i32,
pub z: i32,
}Expand description
Integer index of a chunk column in the infinite X/Z grid.
x and z are chunk indices, not world units; the chunk’s world-space
(0,0,0) corner is (x as f32 * chunk_w, 0, z as f32 * chunk_d).
Fields§
§x: i32Chunk index along X.
z: i32Chunk index along Z.
Implementations§
Source§impl ChunkCoord
impl ChunkCoord
Sourcepub const fn new(x: i32, z: i32) -> ChunkCoord
pub const fn new(x: i32, z: i32) -> ChunkCoord
A chunk coordinate from raw indices.
Sourcepub fn from_world(wx: f32, wz: f32, chunk_w: f32, chunk_d: f32) -> ChunkCoord
pub fn from_world(wx: f32, wz: f32, chunk_w: f32, chunk_d: f32) -> ChunkCoord
The chunk column a world-space (wx, wz) position falls in.
chunk_w / chunk_d are the chunk’s world-space size on X / Z. Floors
rather than truncates, so a negative coordinate maps to the chunk below
it rather than toward zero.
Sourcepub fn origin_world(self, chunk_w: f32, chunk_d: f32) -> (f32, f32)
pub fn origin_world(self, chunk_w: f32, chunk_d: f32) -> (f32, f32)
World-space (x, z) of this chunk’s (0,0,0) corner.
Sourcepub fn offset(self, dx: i32, dz: i32) -> ChunkCoord
pub fn offset(self, dx: i32, dz: i32) -> ChunkCoord
This coordinate shifted by (dx, dz) chunks.
Sourcepub fn chebyshev_distance(self, other: ChunkCoord) -> i32
pub fn chebyshev_distance(self, other: ChunkCoord) -> i32
Chebyshev (square-ring) distance to other, in chunks.
This is the metric the streaming window uses for radius membership: a
chunk is “in view” when its Chebyshev distance to the camera chunk is
<= view_radius, which selects a square block of chunks.
Sourcepub fn sq_distance(self, other: ChunkCoord) -> i64
pub fn sq_distance(self, other: ChunkCoord) -> i64
Squared Euclidean distance to other, in chunk units.
Used to prioritise loads (nearest chunk first). Squared keeps the math
sqrt-free; i64 so a far-apart pair cannot overflow.
Trait Implementations§
Source§impl Clone for ChunkCoord
impl Clone for ChunkCoord
Source§fn clone(&self) -> ChunkCoord
fn clone(&self) -> ChunkCoord
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 ChunkCoord
Source§impl Debug for ChunkCoord
impl Debug for ChunkCoord
impl Eq for ChunkCoord
Source§impl Hash for ChunkCoord
impl Hash for ChunkCoord
Source§impl Ord for ChunkCoord
impl Ord for ChunkCoord
Source§fn cmp(&self, other: &ChunkCoord) -> Ordering
fn cmp(&self, other: &ChunkCoord) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ChunkCoord
impl PartialEq for ChunkCoord
Source§impl PartialOrd for ChunkCoord
impl PartialOrd for ChunkCoord
impl StructuralPartialEq for ChunkCoord
Auto Trait Implementations§
impl Freeze for ChunkCoord
impl RefUnwindSafe for ChunkCoord
impl Send for ChunkCoord
impl Sync for ChunkCoord
impl Unpin for ChunkCoord
impl UnsafeUnpin for ChunkCoord
impl UnwindSafe for ChunkCoord
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,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
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.