Struct veloren_common::terrain::chonk::Chonk
source · pub struct Chonk<V, S: RectVolSize, M: Clone> {
z_offset: i32,
sub_chunks: Vec<Chunk<V, SubChunkSize<S>, M>>,
below: V,
above: V,
meta: M,
phantom: PhantomData<S>,
}
Fields§
§z_offset: i32
§sub_chunks: Vec<Chunk<V, SubChunkSize<S>, M>>
§below: V
§above: V
§meta: M
§phantom: PhantomData<S>
Implementations§
source§impl<V, S: RectVolSize, M: Clone> Chonk<V, S, M>
impl<V, S: RectVolSize, M: Clone> Chonk<V, S, M>
pub fn new(z_offset: i32, below: V, above: V, meta: M) -> Self
pub fn meta(&self) -> &M
pub fn meta_mut(&mut self) -> &mut M
pub fn get_min_z(&self) -> i32
pub fn get_max_z(&self) -> i32
pub fn sub_chunks_len(&self) -> usize
pub fn sub_chunk_groups(&self) -> usize
sourcepub fn iter_changed(&self) -> impl Iterator<Item = (Vec3<i32>, &V)> + '_
pub fn iter_changed(&self) -> impl Iterator<Item = (Vec3<i32>, &V)> + '_
Iterate through the voxels in this chunk, attempting to avoid those that
are unchanged (i.e: match the below
and above
voxels). This is
generally useful for performance reasons.
fn sub_chunk_idx(&self, z: i32) -> i32
fn sub_chunk_z(&self, z: i32) -> i32
fn sub_chunk_min_z(&self, z: i32) -> i32
sourcepub fn defragment(&mut self)
pub fn defragment(&mut self)
Compress chunk by using more intelligent defaults.
Trait Implementations§
source§impl<'de, V, S, M> Deserialize<'de> for Chonk<V, S, M>
impl<'de, V, S, M> Deserialize<'de> for Chonk<V, S, M>
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl<'a, V, S: RectVolSize, M: Clone> IntoPosIterator for &'a Chonk<V, S, M>
impl<'a, V, S: RectVolSize, M: Clone> IntoPosIterator for &'a Chonk<V, S, M>
source§impl<'a, V, S: RectVolSize, M: Clone> IntoVolIterator<'a> for &'a Chonk<V, S, M>
impl<'a, V, S: RectVolSize, M: Clone> IntoVolIterator<'a> for &'a Chonk<V, S, M>
source§impl<V, S: RectVolSize, M: Clone> ReadVol for Chonk<V, S, M>
impl<V, S: RectVolSize, M: Clone> ReadVol for Chonk<V, S, M>
source§fn get(&self, pos: Vec3<i32>) -> Result<&V, Self::Error>
fn get(&self, pos: Vec3<i32>) -> Result<&V, Self::Error>
Get a reference to the voxel at the provided position in the volume.
source§fn get_unchecked(&self, pos: Vec3<i32>) -> &V
fn get_unchecked(&self, pos: Vec3<i32>) -> &V
Get a reference to the voxel at the provided position in the volume.
Many volumes provide a fast path, provided the position is always
in-bounds. Note that this function is still safe.
source§impl<V, S: RectVolSize, M: Clone> RectRasterableVol for Chonk<V, S, M>
impl<V, S: RectVolSize, M: Clone> RectRasterableVol for Chonk<V, S, M>
Auto Trait Implementations§
impl<V, S, M> Freeze for Chonk<V, S, M>
impl<V, S, M> RefUnwindSafe for Chonk<V, S, M>
impl<V, S, M> Send for Chonk<V, S, M>
impl<V, S, M> Sync for Chonk<V, S, M>
impl<V, S, M> Unpin for Chonk<V, S, M>
impl<V, S, M> UnwindSafe for Chonk<V, S, M>
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
Mutably borrows from an owned value. Read more
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)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<C, M> ConvertSaveload<M> for C
impl<C, M> ConvertSaveload<M> for C
§type Error = Infallible
type Error = Infallible
Error may occur during serialization or deserialization of component
§fn convert_into<F>(
&self,
_: F,
) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
fn convert_into<F>( &self, _: F, ) -> Result<<C as ConvertSaveload<M>>::Data, <C as ConvertSaveload<M>>::Error>
Convert this data type into serializable form (
Data
) using
entity to marker mapping function§fn convert_from<F>(
data: <C as ConvertSaveload<M>>::Data,
_: F,
) -> Result<C, <C as ConvertSaveload<M>>::Error>
fn convert_from<F>( data: <C as ConvertSaveload<M>>::Data, _: F, ) -> Result<C, <C as ConvertSaveload<M>>::Error>
Convert this data from a deserializable form (
Data
) using
entity to marker mapping function§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>
Converts
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>
Converts
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