type SubChunk<V, S, M> = Chunk<V, SubChunkSize<S>, M>;
Aliased Type§
struct SubChunk<V, S, M> {
indices: Vec<u8>,
vox: Vec<V>,
default: V,
meta: M,
phantom: PhantomData<SubChunkSize<S>>,
}
Fields§
§indices: Vec<u8>
§vox: Vec<V>
§default: V
§meta: M
§phantom: PhantomData<SubChunkSize<S>>
Implementations
Source§impl<V, S: VolSize, M> Chunk<V, S, M>
impl<V, S: VolSize, M> Chunk<V, S, M>
pub const GROUP_COUNT: Vec3<u32>
Sourceconst GROUP_COUNT_TOTAL: u32
const GROUP_COUNT_TOTAL: u32
GROUP_COUNT_TOTAL
is always 256
, except if VOLUME < 256
const GROUP_LONG_SIDE_LEN: u32
const GROUP_SIZE: Vec3<u32>
const GROUP_VOLUME: u32
const VOLUME: u32
Sourcepub fn filled(default: V, meta: M) -> Self
pub fn filled(default: V, meta: M) -> Self
Creates a new Chunk
with the provided dimensions and all voxels filled
with duplicates of the provided voxel.
Sourcepub fn defragment(&mut self)
pub fn defragment(&mut self)
Compress this subchunk by frequency.
Sourcepub fn metadata_mut(&mut self) -> &mut M
pub fn metadata_mut(&mut self) -> &mut M
Get a mutable reference to the internal metadata.
pub fn num_groups(&self) -> usize
Sourcepub fn homogeneous(&self) -> Option<&V>
pub fn homogeneous(&self) -> Option<&V>
Returns Some(v)
if the block is homogeneous and contains nothing but
voxels of value v
, and None
otherwise. This method is
conservative (it may return None when the chunk is
actually homogeneous) unless called immediately after defragment
.
fn grp_idx(pos: Vec3<i32>) -> u32
fn rel_idx(pos: Vec3<i32>) -> u32
fn idx_unchecked(&self, pos: Vec3<i32>) -> Option<usize>
fn force_idx_unchecked(&mut self, pos: Vec3<i32>) -> usizewhere
V: Clone,
fn get_unchecked(&self, pos: Vec3<i32>) -> &V
fn set_unchecked(&mut self, pos: Vec3<i32>, vox: V) -> V
Trait Implementations
Source§impl<'de, V, S: VolSize, M> Deserialize<'de> for Chunk<V, S, M>where
V: Deserialize<'de>,
M: Deserialize<'de>,
impl<'de, V, S: VolSize, M> Deserialize<'de> for Chunk<V, S, M>where
V: Deserialize<'de>,
M: Deserialize<'de>,
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<V, S: VolSize, M> RasterableVol for Chunk<V, S, M>
impl<V, S: VolSize, M> RasterableVol for Chunk<V, S, M>
Source§impl<V, S: VolSize, M> ReadVol for Chunk<V, S, M>
impl<V, S: VolSize, M> ReadVol for Chunk<V, S, M>
Source§fn get(&self, pos: Vec3<i32>) -> Result<&Self::Vox, Self::Error>
fn get(&self, pos: Vec3<i32>) -> Result<&Self::Vox, Self::Error>
Get a reference to the voxel at the provided position in the volume.
Source§fn get_unchecked(&self, pos: Vec3<i32>) -> &Self::Vox
fn get_unchecked(&self, pos: Vec3<i32>) -> &Self::Vox
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.