Struct veloren_common::volumes::vol_grid_2d::VolGrid2d
source · 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>>
impl VolGrid2d<Chonk<Block, TerrainChunkSize, TerrainChunkMeta>>
sourcepub fn find_ground(&self, pos: Vec3<i32>) -> Vec3<i32>
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).
pub fn is_space(&self, pos: Vec3<i32>) -> bool
pub fn try_find_space(&self, pos: Vec3<i32>) -> Option<Vec3<i32>>
pub fn try_find_ground(&self, pos: Vec3<i32>) -> Option<Vec3<i32>>
pub fn get_interpolated<T, F>(&self, pos: Vec2<i32>, f: F) -> Option<T>
source§impl<V: RectRasterableVol> VolGrid2d<V>
impl<V: RectRasterableVol> VolGrid2d<V>
source§impl<V: RectRasterableVol> VolGrid2d<V>
impl<V: RectRasterableVol> VolGrid2d<V>
pub fn new( map_size_lg: MapSizeLg, default: Arc<V>, ) -> Result<Self, VolGrid2dError<V>>
pub fn chunk_size() -> Vec2<u32>
pub fn insert(&mut self, key: Vec2<i32>, chunk: Arc<V>) -> Option<Arc<V>>
pub fn get_key(&self, key: Vec2<i32>) -> Option<&V>
pub fn get_key_real(&self, key: Vec2<i32>) -> Option<&V>
pub fn contains_key(&self, key: Vec2<i32>) -> bool
pub fn contains_key_real(&self, key: Vec2<i32>) -> bool
pub fn get_key_arc(&self, key: Vec2<i32>) -> Option<&Arc<V>>
pub fn get_key_arc_real(&self, key: Vec2<i32>) -> Option<&Arc<V>>
pub fn clear(&mut self)
pub fn drain(&mut self) -> Drain<'_, Vec2<i32>, Arc<V>>
pub fn remove(&mut self, key: Vec2<i32>) -> Option<Arc<V>>
sourcepub fn key_pos(&self, key: Vec2<i32>) -> Vec2<i32>
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.
sourcepub fn pos_key(&self, pos: Vec3<i32>) -> Vec2<i32>
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).
sourcepub fn pos_chunk(&self, pos: Vec3<i32>) -> Option<&V>
pub fn pos_chunk(&self, pos: Vec3<i32>) -> Option<&V>
Gets the chunk that contains the provided world position.
pub fn iter(&self) -> ChunkIter<'_, V> ⓘ
pub fn cached(&self) -> CachedVolGrid2d<'_, V>
Trait Implementations§
source§impl<V: RectRasterableVol + ReadVol + Debug> ReadVol for VolGrid2d<V>
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))
fn for_each_in(&self, aabb: Aabb<i32>, f: impl FnMut(Vec3<i32>, Self::Vox))
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>>
fn get(&self, pos: Vec3<i32>) -> Result<&V::Vox, VolGrid2dError<V>>
Get a reference to the voxel at the provided position in the volume.
Auto Trait Implementations§
impl<V> Freeze for VolGrid2d<V>
impl<V> RefUnwindSafe for VolGrid2d<V>where
V: RefUnwindSafe,
impl<V> Send for VolGrid2d<V>
impl<V> Sync for VolGrid2d<V>
impl<V> Unpin for VolGrid2d<V>
impl<V> UnwindSafe for VolGrid2d<V>where
V: RefUnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more