pub struct VolGrid2d<V: RectRasterableVol> {
    map_size_lg: MapSizeLg,
    default: Arc<V>,
    chunks: HashMap<Vec2<i32>, Arc<V>, GridHasher>,
}

Fields§

§map_size_lg: MapSizeLg

Size of the entire (not just loaded) map.

§default: Arc<V>

Default voxel for use outside of max map bounds.

§chunks: HashMap<Vec2<i32>, Arc<V>, GridHasher>

Implementations§

source§

impl VolGrid2d<Chonk<Block, TerrainChunkSize, TerrainChunkMeta>>

source

pub fn find_ground(&self, pos: Vec3<i32>) -> Vec3<i32>

Find a location suitable for spawning an entity near the given position (but in the same chunk).

source

pub fn is_space(&self, pos: Vec3<i32>) -> bool

source

pub fn try_find_space(&self, pos: Vec3<i32>) -> Option<Vec3<i32>>

source

pub fn try_find_ground(&self, pos: Vec3<i32>) -> Option<Vec3<i32>>

source

pub fn get_interpolated<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
where T: Copy + Default + Add<Output = T> + Mul<f32, Output = T>, F: FnMut(&TerrainChunk) -> T,

source§

impl<V: RectRasterableVol> VolGrid2d<V>

source

pub fn chunk_key<P: Into<Vec2<i32>>>(pos: P) -> Vec2<i32>

source

pub fn key_chunk<K: Into<Vec2<i32>>>(key: K) -> Vec2<i32>

source

pub fn par_keys(&self) -> ParKeys<'_, Vec2<i32>, Arc<V>>
where V: Send + Sync,

source

pub fn chunk_offs(pos: Vec3<i32>) -> Vec3<i32>

source§

impl<V: RectRasterableVol> VolGrid2d<V>

source

pub fn new( map_size_lg: MapSizeLg, default: Arc<V> ) -> Result<Self, VolGrid2dError<V>>

source

pub fn chunk_size() -> Vec2<u32>

source

pub fn insert(&mut self, key: Vec2<i32>, chunk: Arc<V>) -> Option<Arc<V>>

source

pub fn get_key(&self, key: Vec2<i32>) -> Option<&V>

source

pub fn get_key_real(&self, key: Vec2<i32>) -> Option<&V>

source

pub fn contains_key(&self, key: Vec2<i32>) -> bool

source

pub fn contains_key_real(&self, key: Vec2<i32>) -> bool

source

pub fn get_key_arc(&self, key: Vec2<i32>) -> Option<&Arc<V>>

source

pub fn get_key_arc_real(&self, key: Vec2<i32>) -> Option<&Arc<V>>

source

pub fn clear(&mut self)

source

pub fn drain(&mut self) -> Drain<'_, Vec2<i32>, Arc<V>>

source

pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>>

source

pub fn key_pos(&self, key: Vec2<i32>) -> Vec2<i32>

Converts a chunk key (i.e. coordinates in terms of chunks) into a position in the world (aka “wpos”).

The returned position will be in the corner of the chunk.

source

pub fn pos_key(&self, pos: Vec3<i32>) -> Vec2<i32>

Converts a position in the world into a chunk key (i.e. coordinates in terms of chunks).

source

pub fn pos_chunk(&self, pos: Vec3<i32>) -> Option<&V>

Gets the chunk that contains the provided world position.

source

pub fn iter(&self) -> ChunkIter<'_, V>

source

pub fn cached(&self) -> CachedVolGrid2d<'_, V>

Trait Implementations§

source§

impl<V: RectRasterableVol + Debug> BaseVol for VolGrid2d<V>

§

type Error = VolGrid2dError<V>

§

type Vox = <V as BaseVol>::Vox

source§

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

source§

impl<V: Clone + RectRasterableVol> Clone for VolGrid2d<V>

source§

fn clone(&self) -> VolGrid2d<V>

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: RectRasterableVol + ReadVol + Debug> ReadVol for VolGrid2d<V>

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 Areas outside loaded chunks are ignored

source§

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

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<I: Into<Aabr<i32>>, V: RectRasterableVol + ReadVol + Debug> SampleVol<I> for VolGrid2d<V>

source§

fn sample(&self, range: I) -> Result<Self::Sample, VolGrid2dError<V>>

Take a sample of the terrain by cloning the voxels within the provided range.

Note that the resultant volume does not carry forward metadata from the original chunks.

§

type Sample = VolGrid2d<V>

source§

impl<V: RectRasterableVol + WriteVol + Clone + Debug> WriteVol for VolGrid2d<V>

source§

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

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

Auto Trait Implementations§

§

impl<V> RefUnwindSafe for VolGrid2d<V>
where V: RefUnwindSafe,

§

impl<V> Send for VolGrid2d<V>
where V: Sync + Send,

§

impl<V> Sync for VolGrid2d<V>
where V: Sync + Send,

§

impl<V> Unpin for VolGrid2d<V>

§

impl<V> UnwindSafe for VolGrid2d<V>
where V: RefUnwindSafe,

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

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

§

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