pub struct Dyna<V, M, A: Access = ColumnAccess> {
    vox: Vec<V>,
    meta: M,
    pub sz: Vec3<u32>,
    _phantom: PhantomData<A>,
}
Expand description

A volume with dimensions known only at the creation of the object.

Fields§

§vox: Vec<V>§meta: M§sz: Vec3<u32>§_phantom: PhantomData<A>

Implementations§

source§

impl Dyna<Cell, ()>

source

pub fn from_voxes(data: &[(&DotVoxData, Vec3<i32>, bool)]) -> (Self, Vec3<i32>)

Take a list of voxel data, offsets, and x-mirror flags, and assembled them into a combined segment

source

pub fn from_vox_model_index( dot_vox_data: &DotVoxData, model_index: usize ) -> Self

source

pub fn from_vox( dot_vox_data: &DotVoxData, flipped: bool, model_index: usize ) -> Self

source

pub fn map(self, transform: impl Fn(Cell) -> Option<Cell>) -> Self

Transform cells

source

pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self

Transform cell colors

source§

impl Dyna<MatCell, ()>

source

pub fn to_segment(&self, map: impl Fn(Material) -> Rgb<u8>) -> Segment

source

pub fn map(self, transform: impl Fn(MatCell) -> Option<MatCell>) -> Self

Transform cells

source

pub fn map_rgb(self, transform: impl Fn(Rgb<u8>) -> Rgb<u8>) -> Self

Transform cell colors

source

pub fn from_vox_model_index( dot_vox_data: &DotVoxData, model_index: usize ) -> Self

source

pub fn from_vox( dot_vox_data: &DotVoxData, flipped: bool, model_index: usize ) -> Self

source§

impl<V, M, A: Access> Dyna<V, M, A>

source

fn idx_for(sz: Vec3<u32>, pos: Vec3<i32>) -> Option<usize>

Used to transform a voxel position in the volume into its corresponding index in the voxel array.

source

pub fn map_into<W, F: FnMut(V) -> W>(self, f: F) -> Dyna<W, M, A>

source§

impl<V: Clone, M, A: Access> Dyna<V, M, A>

source

pub fn filled(sz: Vec3<u32>, vox: V, meta: M) -> Self

Create a new Dyna with the provided dimensions and all voxels filled with duplicates of the provided voxel.

source

pub fn from_fn<F: FnMut(Vec3<i32>) -> V>(sz: Vec3<u32>, meta: M, f: F) -> Self

Same as Dyna::filled, but with the voxel determined by the function f.

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.

Trait Implementations§

source§

impl<V, M, A: Access> BaseVol for Dyna<V, M, A>

§

type Error = DynaError

§

type Vox = V

source§

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

source§

impl<V: Clone, M: Clone, A: Access> Clone for Dyna<V, M, A>

source§

fn clone(&self) -> Self

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, M: Debug, A: Debug + Access> Debug for Dyna<V, M, A>

source§

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

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

impl<'de, V, M, A: Access> Deserialize<'de> for Dyna<V, M, A>
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 From<Dyna<Cell, ()>> for TerrainSegment

source§

fn from(value: Segment) -> Self

Converts to this type from the input type.
source§

impl<'a, V, M, A: Access> IntoPosIterator for &'a Dyna<V, M, A>

§

type IntoIter = DefaultPosIterator

source§

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

source§

impl<'a, V, M, A: Access> IntoVolIterator<'a> for &'a Dyna<V, M, A>

§

type IntoIter = DefaultVolIterator<'a, Dyna<V, M, A>>

source§

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

source§

impl<V, M, A: Access> ReadVol for Dyna<V, M, A>

source§

fn get(&self, pos: Vec3<i32>) -> Result<&V, DynaError>

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 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, M, A: Access> Serialize for Dyna<V, M, A>
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<'a, V, M, A: Access> SizedVol for &'a Dyna<V, M, A>

source§

fn lower_bound(&self) -> Vec3<i32>

Returns the (inclusive) lower bound of the volume.
source§

fn upper_bound(&self) -> Vec3<i32>

Returns the (exclusive) upper bound of the volume.
source§

fn size(&self) -> Vec3<u32>

Returns the size of the volume.
source§

impl<V, M, A: Access> SizedVol for Dyna<V, M, A>

source§

fn lower_bound(&self) -> Vec3<i32>

Returns the (inclusive) lower bound of the volume.
source§

fn upper_bound(&self) -> Vec3<i32>

Returns the (exclusive) upper bound of the volume.
source§

fn size(&self) -> Vec3<u32>

Returns the size of the volume.
source§

impl<V, M, A: Access> WriteVol for Dyna<V, M, A>

source§

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

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

Auto Trait Implementations§

§

impl<V, M, A> RefUnwindSafe for Dyna<V, M, A>

§

impl<V, M, A> Send for Dyna<V, M, A>
where A: Send, M: Send, V: Send,

§

impl<V, M, A> Sync for Dyna<V, M, A>
where A: Sync, M: Sync, V: Sync,

§

impl<V, M, A> Unpin for Dyna<V, M, A>
where A: Unpin, M: Unpin, V: Unpin,

§

impl<V, M, A> UnwindSafe for Dyna<V, M, A>
where A: UnwindSafe, M: 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<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,