Type Alias SubChunk

Source
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>

Source

pub fn pos_iter( lower_bound: Vec3<i32>, upper_bound: Vec3<i32>, ) -> ChunkPosIter<V, S, M>

It’s possible to obtain a positional iterator without having a Chunk instance.

Source§

impl<V, S: VolSize, M> Chunk<V, S, M>

Source

pub const GROUP_COUNT: Vec3<u32>

Source

const GROUP_COUNT_TOTAL: u32

GROUP_COUNT_TOTAL is always 256, except if VOLUME < 256

Source

const GROUP_LONG_SIDE_LEN: u32

Source

const GROUP_SIZE: Vec3<u32>

Source

const GROUP_VOLUME: u32

Source

const VOLUME: u32

Source

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.

Source

pub fn defragment(&mut self)
where V: Clone + Eq + Hash,

Compress this subchunk by frequency.

Source

pub fn metadata(&self) -> &M

Get a reference to the internal metadata.

Source

pub fn metadata_mut(&mut self) -> &mut M

Get a mutable reference to the internal metadata.

Source

pub fn num_groups(&self) -> usize

Source

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.

Source

fn grp_idx(pos: Vec3<i32>) -> u32

Source

fn rel_idx(pos: Vec3<i32>) -> u32

Source

fn idx_unchecked(&self, pos: Vec3<i32>) -> Option<usize>

Source

fn force_idx_unchecked(&mut self, pos: Vec3<i32>) -> usize
where V: Clone,

Source

fn get_unchecked(&self, pos: Vec3<i32>) -> &V

Source

fn set_unchecked(&mut self, pos: Vec3<i32>, vox: V) -> V
where V: Clone + PartialEq,

Trait Implementations

Source§

impl<V, S: VolSize, M> BaseVol for Chunk<V, S, M>

Source§

type Error = ChunkError

Source§

type Vox = V

Source§

fn scaled_by(self, scale: Vec3<f32>) -> Scaled<Self>
where Self: Sized,

Source§

impl<V: Clone, S: Clone + VolSize, M: Clone> Clone for Chunk<V, S, M>

Source§

fn clone(&self) -> Chunk<V, S, M>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<V: Debug, S: Debug + VolSize, M: Debug> Debug for Chunk<V, S, M>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<V, S: VolSize, M> RasterableVol for Chunk<V, S, M>

Source§

const SIZE: Vec3<u32> = S::SIZE

Source§

impl<V, S: VolSize, M> ReadVol for Chunk<V, S, M>

Source§

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

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§

fn for_each_in(&self, aabb: Aabb<i32>, f: impl FnMut(Vec3<i32>, Self::Vox))
where Self::Vox: Copy,

Call provided closure with each block in the supplied Aabb Portions of the Aabb outside the volume are ignored
Source§

fn ray( &self, from: Vec3<f32>, to: Vec3<f32>, ) -> Ray<'_, Self, fn(&Self::Vox) -> bool, fn(&Self::Vox, Vec3<i32>)>
where Self: Sized,

NOTE: By default, this ray will simply run from from to to without stopping. To make something interesting happen, call until or for_each.
Source§

impl<V, S: VolSize, M> Serialize for Chunk<V, S, M>
where V: Serialize, M: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<V: Clone + PartialEq, S: VolSize, M> WriteVol for Chunk<V, S, M>

Source§

fn set( &mut self, pos: Vec3<i32>, vox: Self::Vox, ) -> Result<Self::Vox, Self::Error>

Set the voxel at the provided position in the volume to the provided value.
Source§

fn map<F: FnOnce(Self::Vox) -> Self::Vox>( &mut self, pos: Vec3<i32>, f: F, ) -> Result<Self::Vox, Self::Error>
where Self: ReadVol, Self::Vox: Clone,

Map a voxel to another using the provided function.