mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Stop duplicating terrian chunk metadata.
This commit is contained in:
parent
ad5bcf3cd8
commit
4819a17ab6
@ -60,7 +60,7 @@ impl<V, Storage, ChonkSize: RectVolSize> VolSize<V> for SubChunkSize<V, Storage,
|
||||
};
|
||||
}
|
||||
|
||||
pub type SubChunk<V, Storage, S, M> = Chunk<V, SubChunkSize<V, Storage, S>, M>;
|
||||
pub type SubChunk<V, Storage, S, M> = Chunk<V, SubChunkSize<V, Storage, S>, PhantomData<M>>;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Chonk<V, Storage, S: RectVolSize, M: Clone> {
|
||||
@ -229,7 +229,7 @@ impl<V: Clone + PartialEq, Storage: Clone + core::ops::DerefMut<Target=Vec<V>> +
|
||||
return Ok(self.below.clone());
|
||||
}
|
||||
// Prepend exactly sufficiently many SubChunks via Vec::splice
|
||||
let c = Chunk::<V, SubChunkSize<V, Storage, S>, M>::filled(self.below.clone(), self.meta.clone());
|
||||
let c = SubChunk::<V, Storage, S, M>::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::<V, Storage, S>::SIZE.z as i32;
|
||||
@ -240,7 +240,7 @@ impl<V: Clone + PartialEq, Storage: Clone + core::ops::DerefMut<Target=Vec<V>> +
|
||||
return Ok(self.above.clone());
|
||||
}
|
||||
// Append exactly sufficiently many SubChunks via Vec::extend
|
||||
let c = Chunk::<V, SubChunkSize<V, Storage, S>, M>::filled(self.above.clone(), self.meta.clone());
|
||||
let c = SubChunk::<V, Storage, S, M>::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<V, Storage, S: RectVolSize, M: Clone> Iterator for ChonkIterHelper<V, Stora
|
||||
|
||||
pub struct ChonkPosIter<V, Storage, S: RectVolSize, M: Clone> {
|
||||
outer: ChonkIterHelper<V, Storage, S, M>,
|
||||
opt_inner: Option<(i32, ChunkPosIter<V, SubChunkSize<V, Storage, S>, M>)>,
|
||||
opt_inner: Option<(i32, ChunkPosIter<V, SubChunkSize<V, Storage, S>, PhantomData<M>>)>,
|
||||
}
|
||||
|
||||
impl<V, Storage, S: RectVolSize, M: Clone> Iterator for ChonkPosIter<V, Storage, S, M> {
|
||||
@ -308,8 +308,8 @@ impl<V, Storage, S: RectVolSize, M: Clone> Iterator for ChonkPosIter<V, Storage,
|
||||
}
|
||||
|
||||
enum InnerChonkVolIter<'a, V, Storage, S: RectVolSize, M: Clone> {
|
||||
Vol(ChunkVolIter<'a, V, SubChunkSize<V, Storage, S>, M>),
|
||||
Pos(ChunkPosIter<V, SubChunkSize<V, Storage, S>, M>),
|
||||
Vol(ChunkVolIter<'a, V, SubChunkSize<V, Storage, S>, PhantomData<M>>),
|
||||
Pos(ChunkPosIter<V, SubChunkSize<V, Storage, S>, PhantomData<M>>),
|
||||
}
|
||||
|
||||
pub struct ChonkVolIter<'a, V, Storage, S: RectVolSize, M: Clone> {
|
||||
|
@ -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<u8>,
|
||||
usize,
|
||||
CompressedData<HashMap<Vec2<u32>, (SpriteKind, u8)>>,
|
||||
CompressedData<'static, HashMap<Vec2<u32>, (SpriteKind, u8)>>,
|
||||
);
|
||||
type Workspace = (
|
||||
image::ImageBuffer<image::Luma<u8>, Vec<u8>>,
|
||||
@ -590,7 +591,7 @@ impl<P: RTreeParams> NearestNeighbor for RTree<ColorPoint, P> {
|
||||
pub struct PaletteEncoding<'a, NN: NearestNeighbor, const N: u32>(&'a HashMap<BlockKind, NN>);
|
||||
|
||||
impl<'a, NN: NearestNeighbor, const N: u32> VoxelImageEncoding for PaletteEncoding<'a, NN, N> {
|
||||
type Output = CompressedData<(Vec<u8>, [usize; 4])>;
|
||||
type Output = CompressedData<'a, (Vec<u8>, [usize; 4])>;
|
||||
type Workspace = (
|
||||
ImageBuffer<image::Luma<u8>, Vec<u8>>,
|
||||
ImageBuffer<image::Luma<u8>, Vec<u8>>,
|
||||
@ -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::<true>(), &chunk)
|
||||
image_terrain_chonk(&QuadPngEncoding::<4>(PhantomData), WidePacking::<true>(), &chunk)
|
||||
.unwrap();
|
||||
let quadpngquartwide_post = Instant::now();
|
||||
|
||||
let tripngaverage_pre = Instant::now();
|
||||
let tripngaverage =
|
||||
image_terrain_chonk(&TriPngEncoding::<true>(), WidePacking::<true>(), &chunk)
|
||||
image_terrain_chonk(&TriPngEncoding::<true>(PhantomData), WidePacking::<true>(), &chunk)
|
||||
.unwrap();
|
||||
let tripngaverage_post = Instant::now();
|
||||
|
||||
let tripngconst_pre = Instant::now();
|
||||
let tripngconst =
|
||||
image_terrain_chonk(&TriPngEncoding::<false>(), WidePacking::<true>(), &chunk)
|
||||
image_terrain_chonk(&TriPngEncoding::<false>(PhantomData), WidePacking::<true>(), &chunk)
|
||||
.unwrap();
|
||||
let tripngconst_post = Instant::now();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user