Struct veloren_common::terrain::map::MapSizeLg
source · pub struct MapSizeLg(Vec2<u32>);
Expand description
Base two logarithm of a world size, in chunks, per dimension (each dimension must be a power of 2, so the logarithm is exact).
NOTE: As an invariant, each dimension must be between 0 and
[MAX_WORLD_BLOCKS_LG] - [TERRAIN_CHUNK_BLOCKS_LG]
.
NOTE: As an invariant, (1 << ([DEFAULT_WORLD_CHUNKS_LG] + [TERRAIN_CHUNK_BLOCKS_LG]))
fits in an i32 (derived from the invariant
on MAX_WORLD_BLOCKS_LG).
NOTE: As an invariant, each dimension (in chunks) must fit in a i16.
NOTE: As an invariant, the product of dimensions (in chunks) must fit in a usize.
These invariants are all checked on construction of a MapSizeLg
.
Tuple Fields§
§0: Vec2<u32>
Implementations§
source§impl MapSizeLg
impl MapSizeLg
sourcepub const fn new(map_size_lg: Vec2<u32>) -> Result<Self, ()>
pub const fn new(map_size_lg: Vec2<u32>) -> Result<Self, ()>
Construct a new MapSizeLg
, returning an error if the needed invariants
do not hold and the vector otherwise.
TODO: In the future, we may use unsafe code to assert to the compiler that these invariants indeed hold, safely opening up optimizations that might not otherwise be available at runtime.
sourcepub const fn chunks_len(self) -> usize
pub const fn chunks_len(self) -> usize
Get the size of an array of the correct size to hold all chunks.
sourcepub const fn contains_chunk(&self, chunk_key: Vec2<i32>) -> bool
pub const fn contains_chunk(&self, chunk_key: Vec2<i32>) -> bool
Determine whether a chunk position is in bounds.
Trait Implementations§
impl Copy for MapSizeLg
Auto Trait Implementations§
impl Freeze for MapSizeLg
impl RefUnwindSafe for MapSizeLg
impl Send for MapSizeLg
impl Sync for MapSizeLg
impl Unpin for MapSizeLg
impl UnwindSafe for MapSizeLg
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§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>
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