diff --git a/common/src/terrain/chonk.rs b/common/src/terrain/chonk.rs index 1ed92e9b9c..9bf300d910 100644 --- a/common/src/terrain/chonk.rs +++ b/common/src/terrain/chonk.rs @@ -60,7 +60,7 @@ impl VolSize for SubChunkSize = Chunk, M>; +pub type SubChunk = Chunk, PhantomData>; #[derive(Debug, Clone, Serialize, Deserialize)] pub struct Chonk { @@ -229,7 +229,7 @@ impl> + return Ok(self.below.clone()); } // Prepend exactly sufficiently many SubChunks via Vec::splice - let c = Chunk::, M>::filled(self.below.clone(), self.meta.clone()); + let c = SubChunk::::filled(self.below.clone(), /*self.meta.clone()*/PhantomData); let n = (-sub_chunk_idx) as usize; self.sub_chunks.splice(0..0, std::iter::repeat(c).take(n)); self.z_offset += sub_chunk_idx * SubChunkSize::::SIZE.z as i32; @@ -240,7 +240,7 @@ impl> + return Ok(self.above.clone()); } // Append exactly sufficiently many SubChunks via Vec::extend - let c = Chunk::, M>::filled(self.above.clone(), self.meta.clone()); + let c = SubChunk::::filled(self.above.clone(), /*self.meta.clone()*/PhantomData); let n = 1 + sub_chunk_idx as usize - self.sub_chunks.len(); self.sub_chunks.extend(std::iter::repeat(c).take(n)); } @@ -282,7 +282,7 @@ impl Iterator for ChonkIterHelper { outer: ChonkIterHelper, - opt_inner: Option<(i32, ChunkPosIter, M>)>, + opt_inner: Option<(i32, ChunkPosIter, PhantomData>)>, } impl Iterator for ChonkPosIter { @@ -308,8 +308,8 @@ impl Iterator for ChonkPosIter { - Vol(ChunkVolIter<'a, V, SubChunkSize, M>), - Pos(ChunkPosIter, M>), + Vol(ChunkVolIter<'a, V, SubChunkSize, PhantomData>), + Pos(ChunkPosIter, PhantomData>), } pub struct ChonkVolIter<'a, V, Storage, S: RectVolSize, M: Clone> { diff --git a/world/examples/chunk_compression_benchmarks.rs b/world/examples/chunk_compression_benchmarks.rs index ceb4c2791e..8a604cc48e 100644 --- a/world/examples/chunk_compression_benchmarks.rs +++ b/world/examples/chunk_compression_benchmarks.rs @@ -13,6 +13,7 @@ use common_net::msg::compression::{ PackingFormula, QuadPngEncoding, TriPngEncoding, VoxelImageDecoding, VoxelImageEncoding, WidePacking, }; +use core::marker::PhantomData; use hashbrown::HashMap; use image::ImageBuffer; use num_traits::cast::FromPrimitive; @@ -363,7 +364,7 @@ impl VoxelImageEncoding for MixedEncodingSparseSprites { type Output = ( Vec, usize, - CompressedData, (SpriteKind, u8)>>, + CompressedData<'static, HashMap, (SpriteKind, u8)>>, ); type Workspace = ( image::ImageBuffer, Vec>, @@ -590,7 +591,7 @@ impl NearestNeighbor for RTree { pub struct PaletteEncoding<'a, NN: NearestNeighbor, const N: u32>(&'a HashMap); impl<'a, NN: NearestNeighbor, const N: u32> VoxelImageEncoding for PaletteEncoding<'a, NN, N> { - type Output = CompressedData<(Vec, [usize; 4])>; + type Output = CompressedData<'a, (Vec, [usize; 4])>; type Workspace = ( ImageBuffer, Vec>, ImageBuffer, Vec>, @@ -1017,7 +1018,7 @@ fn main() { let quadpngfull_pre = Instant::now(); let quadpngfull = image_terrain_chonk( - &QuadPngEncoding::<1>(), + &QuadPngEncoding::<1>(PhantomData), TallPacking { flip_y: true }, &chunk, ) @@ -1026,7 +1027,7 @@ fn main() { let quadpnghalf_pre = Instant::now(); let quadpnghalf = image_terrain_chonk( - &QuadPngEncoding::<2>(), + &QuadPngEncoding::<2>(PhantomData), TallPacking { flip_y: true }, &chunk, ) @@ -1035,7 +1036,7 @@ fn main() { let quadpngquarttall_pre = Instant::now(); let quadpngquarttall = image_terrain_chonk( - &QuadPngEncoding::<4>(), + &QuadPngEncoding::<4>(PhantomData), TallPacking { flip_y: true }, &chunk, ) @@ -1044,19 +1045,19 @@ fn main() { let quadpngquartwide_pre = Instant::now(); let quadpngquartwide = - image_terrain_chonk(&QuadPngEncoding::<4>(), WidePacking::(), &chunk) + image_terrain_chonk(&QuadPngEncoding::<4>(PhantomData), WidePacking::(), &chunk) .unwrap(); let quadpngquartwide_post = Instant::now(); let tripngaverage_pre = Instant::now(); let tripngaverage = - image_terrain_chonk(&TriPngEncoding::(), WidePacking::(), &chunk) + image_terrain_chonk(&TriPngEncoding::(PhantomData), WidePacking::(), &chunk) .unwrap(); let tripngaverage_post = Instant::now(); let tripngconst_pre = Instant::now(); let tripngconst = - image_terrain_chonk(&TriPngEncoding::(), WidePacking::(), &chunk) + image_terrain_chonk(&TriPngEncoding::(PhantomData), WidePacking::(), &chunk) .unwrap(); let tripngconst_post = Instant::now();