diff --git a/common/src/volumes/vol_grid_2d.rs b/common/src/volumes/vol_grid_2d.rs index b77ac13250..70e4c2459a 100644 --- a/common/src/volumes/vol_grid_2d.rs +++ b/common/src/volumes/vol_grid_2d.rs @@ -221,12 +221,19 @@ impl VolGrid2d { pub fn remove(&mut self, key: Vec2) -> Option> { self.chunks.remove(&key) } + /// 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. #[inline(always)] pub fn key_pos(&self, key: Vec2) -> Vec2 { Self::key_chunk(key) } + /// Converts a position in the world into a chunk key (i.e. coordinates in + /// terms of chunks). #[inline(always)] pub fn pos_key(&self, pos: Vec3) -> Vec2 { Self::chunk_key(pos) } + /// Gets the chunk that contains the provided world position. #[inline(always)] pub fn pos_chunk(&self, pos: Vec3) -> Option<&V> { self.get_key(self.pos_key(pos)) }