diff --git a/common/src/volumes/vol_map.rs b/common/src/volumes/vol_map.rs index aa7c297428..76fa9a6c84 100644 --- a/common/src/volumes/vol_map.rs +++ b/common/src/volumes/vol_map.rs @@ -26,11 +26,11 @@ pub enum VolMapErr { // S = Size (replace with a const when const generics is a thing) // M = Chunk metadata #[derive(Clone)] -pub struct VolMap { +pub struct VolMap { chunks: HashMap, Arc>>, } -impl VolMap { +impl VolMap { #[inline(always)] pub fn chunk_key(pos: Vec3) -> Vec3 { pos.map2(S::SIZE, |e, sz| { @@ -49,12 +49,12 @@ impl VolMap { } } -impl BaseVol for VolMap { +impl BaseVol for VolMap { type Vox = V; type Err = VolMapErr; } -impl ReadVol for VolMap { +impl ReadVol for VolMap { #[inline(always)] fn get(&self, pos: Vec3) -> Result<&V, VolMapErr> { let ck = Self::chunk_key(pos); @@ -68,7 +68,7 @@ impl ReadVol for VolMap { } } -impl SampleVol for VolMap { +impl SampleVol for VolMap { type Sample = VolMap; /// Take a sample of the terrain by cloning the voxels within the provided range. @@ -121,7 +121,7 @@ impl SampleVol for VolMap // Ok(sample) - let mut sample = VolMap::new(); + let mut sample = VolMap::new()?; let chunk_min = Self::chunk_key(range.min); let chunk_max = Self::chunk_key(range.max); for x in chunk_min.x..=chunk_max.x { @@ -158,7 +158,7 @@ impl WriteVol for VolMap } } -impl VolMap { +impl VolMap { pub fn new() -> Result { if Self::chunk_size() .map(|e| e.is_power_of_two() && e > 0) @@ -214,11 +214,11 @@ impl VolMap { } } -pub struct ChunkIter<'a, V: Vox + Clone, S: VolSize + Clone, M: Clone> { +pub struct ChunkIter<'a, V: Vox, S: VolSize, M> { iter: std::collections::hash_map::Iter<'a, Vec3, Arc>>, } -impl<'a, V: Vox + Clone, S: VolSize + Clone, M: Clone> Iterator for ChunkIter<'a, V, S, M> { +impl<'a, V: Vox, S: VolSize, M> Iterator for ChunkIter<'a, V, S, M> { type Item = (Vec3, &'a Arc>); fn next(&mut self) -> Option {