mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Minor fixes (e.g. snow not filling in sprites).
This commit is contained in:
parent
2984293937
commit
c4f2cae04a
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -456,9 +456,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.9.1"
|
version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899"
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytecheck"
|
name = "bytecheck"
|
||||||
@ -6502,6 +6502,7 @@ dependencies = [
|
|||||||
"approx 0.4.0",
|
"approx 0.4.0",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"bitvec",
|
"bitvec",
|
||||||
|
"bumpalo",
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"chrono",
|
"chrono",
|
||||||
"chrono-tz",
|
"chrono-tz",
|
||||||
|
@ -40,7 +40,9 @@ strum = { version = "0.24", features = ["derive"] }
|
|||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||||
approx = "0.4.0"
|
approx = "0.4.0"
|
||||||
bitvec = "0.22"
|
bitvec = "0.22"
|
||||||
# bumpalo = { version = "3.9.1", features = ["allocator_api"] }
|
bumpalo = { version = "3.10.0", features = [
|
||||||
|
# "allocator_api"
|
||||||
|
] }
|
||||||
bytemuck = { version="1.4", features=["derive"] }
|
bytemuck = { version="1.4", features=["derive"] }
|
||||||
clap = "2.33"
|
clap = "2.33"
|
||||||
crossbeam-utils = "0.8.1"
|
crossbeam-utils = "0.8.1"
|
||||||
|
@ -6,6 +6,7 @@ use crate::{
|
|||||||
volumes::chunk::{Chunk, ChunkError, ChunkPosIter, ChunkVolIter},
|
volumes::chunk::{Chunk, ChunkError, ChunkPosIter, ChunkVolIter},
|
||||||
};
|
};
|
||||||
use core::{hash::Hash, marker::PhantomData};
|
use core::{hash::Hash, marker::PhantomData};
|
||||||
|
use hashbrown::HashMap;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
|
||||||
@ -102,20 +103,22 @@ impl<V, Storage: core::ops::DerefMut<Target=Vec<V>>, S: RectVolSize, M: Clone> C
|
|||||||
///
|
///
|
||||||
/// It's not acutally flat, it just skips the indirection through the index. The idea is to
|
/// It's not acutally flat, it just skips the indirection through the index. The idea is to
|
||||||
/// use a constant stride for row access so the prefetcher can process it more easily.
|
/// use a constant stride for row access so the prefetcher can process it more easily.
|
||||||
pub fn make_flat<'a>(&'a self, below_slice: &'a [V], above_slice: &'a [V]) -> Vec<&'a [V]>
|
pub fn make_flat<'a>(&'a self, arena: &'a bumpalo::Bump) -> Vec<&'a [V]>
|
||||||
where
|
where
|
||||||
V: Copy + Eq,
|
V: Copy + Hash + Eq,
|
||||||
[(); SubChunk::<V, Storage, S, M>::GROUP_VOLUME as usize]:,
|
[(); SubChunk::<V, Storage, S, M>::GROUP_VOLUME as usize]:,
|
||||||
{
|
{
|
||||||
|
// Cache of slices per block type to maximize cacheline reuse.
|
||||||
|
let mut default_slices = HashMap::new();
|
||||||
let mut flat = Vec::with_capacity(self.sub_chunks.len() * /*SubChunkSize::<V, Storage, S>::SIZE.z as usize **/
|
let mut flat = Vec::with_capacity(self.sub_chunks.len() * /*SubChunkSize::<V, Storage, S>::SIZE.z as usize **/
|
||||||
/* SubChunk::<V, Storage, S, M>::VOLUME as usize */
|
/* SubChunk::<V, Storage, S, M>::VOLUME as usize */
|
||||||
SubChunk::<V, Storage, S, M>::GROUP_COUNT_TOTAL as usize);
|
SubChunk::<V, Storage, S, M>::GROUP_COUNT_TOTAL as usize);
|
||||||
self.sub_chunks.iter().enumerate().for_each(|(idx, sub_chunk)| {
|
self.sub_chunks.iter().enumerate().for_each(|(idx, sub_chunk)| {
|
||||||
let slice = if sub_chunk.default() == &self.below {
|
let default = *sub_chunk.default();
|
||||||
below_slice
|
let slice = *default_slices.entry(default)
|
||||||
} else {
|
.or_insert_with(move || {
|
||||||
above_slice
|
&*arena.alloc_slice_fill_copy(SubChunk::<V, Storage, S, M>::GROUP_VOLUME as usize, default)
|
||||||
};
|
});
|
||||||
sub_chunk.push_flat(&mut flat, slice);
|
sub_chunk.push_flat(&mut flat, slice);
|
||||||
});
|
});
|
||||||
flat
|
flat
|
||||||
|
@ -21,7 +21,7 @@ common-net = { package = "veloren-common-net", path = "../common/net" }
|
|||||||
|
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
bitvec = "0.22"
|
bitvec = "0.22"
|
||||||
bumpalo = "3.9.1"
|
bumpalo = "3.10.0"
|
||||||
enum-iterator = "0.7"
|
enum-iterator = "0.7"
|
||||||
fxhash = "0.2.1"
|
fxhash = "0.2.1"
|
||||||
image = { version = "0.24", default-features = false, features = ["png"] }
|
image = { version = "0.24", default-features = false, features = ["png"] }
|
||||||
|
@ -543,15 +543,17 @@ impl World {
|
|||||||
)
|
)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply snow cover.
|
// Defragment to minimize space consumption.
|
||||||
|
chunk.defragment();
|
||||||
|
|
||||||
|
// Apply snow cover (we do this after defragmentation to benefit from faster iteration over
|
||||||
|
// air underground).
|
||||||
if has_snow {
|
if has_snow {
|
||||||
let snow = Block::new(BlockKind::Snow, Rgb::new(210, 210, 255));
|
let snow = Block::new(BlockKind::Snow, Rgb::new(210, 210, 255));
|
||||||
// NOTE: We assume throughout Veloren that u32 fits in usize (we need to make this a static
|
// NOTE: We assume throughout Veloren that u32 fits in usize (we need to make this a static
|
||||||
// assertion). RECT_SIZE.product() is statically valid.
|
// assertion). RECT_SIZE.product() is statically valid.
|
||||||
let mut snow_blocks = Vec::with_capacity(TerrainChunkSize::RECT_SIZE.product() as usize * 3);
|
let mut snow_blocks = Vec::with_capacity(TerrainChunkSize::RECT_SIZE.product() as usize * 3);
|
||||||
let air_slice = [air; common::terrain::TerrainSubChunk::GROUP_VOLUME as usize];
|
let flat = chunk.make_flat(/*&stone_slice, &air_slice, */&arena);
|
||||||
let stone_slice = [stone; common::terrain::TerrainSubChunk::GROUP_VOLUME as usize];
|
|
||||||
let flat = chunk.make_flat(&stone_slice, &air_slice);
|
|
||||||
zcache_grid.iter()
|
zcache_grid.iter()
|
||||||
.filter(|(_, col_sample)| col_sample.snow_cover)
|
.filter(|(_, col_sample)| col_sample.snow_cover)
|
||||||
.for_each(|(wpos_delta, col_sample)| {
|
.for_each(|(wpos_delta, col_sample)| {
|
||||||
@ -597,15 +599,22 @@ impl World {
|
|||||||
}
|
}
|
||||||
} */
|
} */
|
||||||
});
|
});
|
||||||
|
arena.reset();
|
||||||
|
|
||||||
snow_blocks.into_iter().for_each(|pos| {
|
snow_blocks.into_iter().for_each(|pos| {
|
||||||
let _ = chunk.set(pos, snow);
|
// Make sure not to replace sprites.
|
||||||
|
//
|
||||||
|
// Note that we don't check this in the inner loop above because we want snow to
|
||||||
|
// fall through sprites, and in practice the block.is_air() check is pretty
|
||||||
|
// effective.
|
||||||
|
let _ = chunk.map(pos, |block| if block == Block::empty() {
|
||||||
|
snow
|
||||||
|
} else {
|
||||||
|
block
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, defragment to minimize space consumption.
|
|
||||||
chunk.defragment();
|
|
||||||
|
|
||||||
Ok((chunk, supplement))
|
Ok((chunk, supplement))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user