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>

source

pub fn new(z_offset: i32, below: V, above: V, meta: M) -> Self

source

pub fn meta(&self) -> &M

source

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

source

pub fn get_min_z(&self) -> i32

source

pub fn get_max_z(&self) -> i32

source

pub fn sub_chunks_len(&self) -> usize

source

pub fn sub_chunk_groups(&self) -> usize

source

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.

source

fn sub_chunk_idx(&self, z: i32) -> i32

source

fn sub_chunk_z(&self, z: i32) -> i32

source

fn sub_chunk_min_z(&self, z: i32) -> i32

source

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

Compress chunk by using more intelligent defaults.

source§

impl Chonk<Block, TerrainChunkSize, TerrainChunkMeta>

source

pub fn water(sea_level: i32) -> TerrainChunk

Generate an all-water chunk at a specific sea level.

source

pub fn find_accessible_pos( &self, spawn_wpos: Vec2<i32>, ascending: bool ) -> Vec3<f32>

Find the highest or lowest accessible position within the chunk

Trait Implementations§

source§

impl<V, S: RectVolSize, M: Clone> BaseVol for Chonk<V, S, M>

§

type Error = ChonkError

§

type Vox = V

source§

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

source§

impl<V: Clone, S: Clone + RectVolSize, M: Clone + Clone> Clone for Chonk<V, S, M>

source§

fn clone(&self) -> Chonk<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 + RectVolSize, M: Debug + Clone> Debug for Chonk<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, M> Deserialize<'de> for Chonk<V, S, M>
where V: Deserialize<'de>, S: Deserialize<'de> + RectVolSize, M: Deserialize<'de> + Clone,

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<'a, V, S: RectVolSize, M: Clone> IntoPosIterator for &'a Chonk<V, S, M>

§

type IntoIter = ChonkPosIter<V, S, M>

source§

fn pos_iter( self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32> ) -> Self::IntoIter

source§

impl<'a, V, S: RectVolSize, M: Clone> IntoVolIterator<'a> for &'a Chonk<V, S, M>

§

type IntoIter = ChonkVolIter<'a, V, S, M>

source§

fn vol_iter( self, lower_bound: Vec3<i32>, upper_bound: Vec3<i32> ) -> Self::IntoIter

source§

impl<V, S: RectVolSize, M: Clone> ReadVol for Chonk<V, S, M>

source§

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

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: RectVolSize, M: Clone> RectRasterableVol for Chonk<V, S, M>

source§

const RECT_SIZE: Vec2<u32> = S::RECT_SIZE

source§

impl<V, S, M> Serialize for Chonk<V, S, M>

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: RectVolSize, M: Clone> WriteVol for Chonk<V, S, M>

source§

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

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

Auto Trait Implementations§

§

impl<V, S, M> RefUnwindSafe for Chonk<V, S, M>

§

impl<V, S, M> Send for Chonk<V, S, M>
where M: Send, S: Send, V: Send,

§

impl<V, S, M> Sync for Chonk<V, S, M>
where M: Sync, S: Sync, V: Sync,

§

impl<V, S, M> Unpin for Chonk<V, S, M>
where M: Unpin, S: Unpin, V: Unpin,

§

impl<V, S, M> UnwindSafe for Chonk<V, S, M>
where M: UnwindSafe, S: UnwindSafe, V: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<C, M> ConvertSaveload<M> for C

§

type Data = C

(De)Serializable data representation for data type
§

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>
where F: FnMut(Entity) -> Option<M>,

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>
where F: FnMut(M) -> Option<Entity>,

Convert this data from a deserializable form (Data) using entity to marker mapping function
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<V> RectSizedVol for V

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<Context> SubContext<Context> for Context

source§

fn sub_context(self) -> Context

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

§

impl<T> Event for T
where T: Send + Sync + 'static,

§

impl<T> Resource for T
where T: Any + Send + Sync,