mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
This seems to save at least 30 seconds (out of 90 to 120 secs) when tweaking TILE_SIZE in voxygen/src/mesh/greedy.rs (NOTE: I did some more timing, see associated MR description)
This commit is contained in:
parent
479affe127
commit
291a424b4e
@ -1,5 +1,7 @@
|
|||||||
#![enable(unwrap_newtypes)]
|
#![enable(unwrap_newtypes)]
|
||||||
(
|
{
|
||||||
|
// Represents the lack of a sprite.
|
||||||
|
Empty: None,
|
||||||
// Windows
|
// Windows
|
||||||
Window1: Some((
|
Window1: Some((
|
||||||
variations: [
|
variations: [
|
||||||
@ -1348,7 +1350,7 @@ Ember: Some((
|
|||||||
wind_sway: 0.0,
|
wind_sway: 0.0,
|
||||||
)),
|
)),
|
||||||
// Smoke dummy
|
// Smoke dummy
|
||||||
Smoke: Some((
|
SmokeDummy: Some((
|
||||||
variations: [
|
variations: [
|
||||||
(
|
(
|
||||||
model: "voxygen.voxel.sprite.ember.dummy",
|
model: "voxygen.voxel.sprite.ember.dummy",
|
||||||
@ -2902,7 +2904,11 @@ GiantKelp: Some((
|
|||||||
],
|
],
|
||||||
wind_sway: 0.2,
|
wind_sway: 0.2,
|
||||||
)),
|
)),
|
||||||
//Seagrass
|
// Red Algae
|
||||||
|
RedAlgae: None,
|
||||||
|
// Underwater Vent
|
||||||
|
UnderwaterVent: None,
|
||||||
|
// Seagrass
|
||||||
Seagrass: Some((
|
Seagrass: Some((
|
||||||
variations: [
|
variations: [
|
||||||
(
|
(
|
||||||
@ -3945,4 +3951,4 @@ Eldwood: Some((
|
|||||||
],
|
],
|
||||||
wind_sway: 0.0,
|
wind_sway: 0.0,
|
||||||
)),
|
)),
|
||||||
)
|
}
|
||||||
|
@ -24,7 +24,7 @@ use common::{
|
|||||||
assets::{self, AssetExt, DotVoxAsset},
|
assets::{self, AssetExt, DotVoxAsset},
|
||||||
figure::Segment,
|
figure::Segment,
|
||||||
spiral::Spiral2d,
|
spiral::Spiral2d,
|
||||||
terrain::{sprite, Block, SpriteKind, TerrainChunk},
|
terrain::{Block, SpriteKind, TerrainChunk},
|
||||||
vol::{BaseVol, ReadVol, RectRasterableVol, SampleVol},
|
vol::{BaseVol, ReadVol, RectRasterableVol, SampleVol},
|
||||||
volumes::vol_grid_2d::{VolGrid2d, VolGrid2dError},
|
volumes::vol_grid_2d::{VolGrid2d, VolGrid2dError},
|
||||||
};
|
};
|
||||||
@ -157,7 +157,7 @@ struct SpriteConfig<Model> {
|
|||||||
/// NOTE: Model is an asset path to the appropriate sprite .vox model.
|
/// NOTE: Model is an asset path to the appropriate sprite .vox model.
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
#[serde(transparent)]
|
#[serde(transparent)]
|
||||||
struct SpriteSpec(sprite::sprite_kind::PureCases<Option<SpriteConfig<String>>>);
|
struct SpriteSpec(HashMap<SpriteKind, Option<SpriteConfig<String>>>);
|
||||||
|
|
||||||
impl assets::Asset for SpriteSpec {
|
impl assets::Asset for SpriteSpec {
|
||||||
type Loader = assets::RonLoader;
|
type Loader = assets::RonLoader;
|
||||||
@ -236,7 +236,7 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug + '
|
|||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
|
||||||
if let Some(cfg) = sprite.elim_case_pure(&sprite_config.0) {
|
if let Some(cfg) = sprite_config.0.get(&sprite).and_then(Option::as_ref) {
|
||||||
let seed = wpos.x as u64 * 3
|
let seed = wpos.x as u64 * 3
|
||||||
+ wpos.y as u64 * 7
|
+ wpos.y as u64 * 7
|
||||||
+ wpos.x as u64 * wpos.y as u64; // Awful PRNG
|
+ wpos.x as u64 * wpos.y as u64; // Awful PRNG
|
||||||
@ -394,10 +394,16 @@ impl SpriteRenderContext {
|
|||||||
let max_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32);
|
let max_size = guillotiere::Size::new(max_texture_size as i32, max_texture_size as i32);
|
||||||
let mut greedy = GreedyMesh::new(max_size);
|
let mut greedy = GreedyMesh::new(max_size);
|
||||||
let mut sprite_mesh = Mesh::new();
|
let mut sprite_mesh = Mesh::new();
|
||||||
let sprite_config_ = &sprite_config;
|
|
||||||
// NOTE: Tracks the start vertex of the next model to be meshed.
|
// NOTE: Tracks the start vertex of the next model to be meshed.
|
||||||
let sprite_data: HashMap<(SpriteKind, usize), _> = SpriteKind::into_enum_iter()
|
let sprite_data: HashMap<(SpriteKind, usize), _> = SpriteKind::into_enum_iter()
|
||||||
.filter_map(|kind| Some((kind, kind.elim_case_pure(&sprite_config_.0).as_ref()?)))
|
.filter_map(|kind| {
|
||||||
|
let config = sprite_config
|
||||||
|
.0
|
||||||
|
.get(&kind)
|
||||||
|
.unwrap_or_else(|| panic!("{kind:?}"))
|
||||||
|
.as_ref()?;
|
||||||
|
Some((kind, config))
|
||||||
|
})
|
||||||
.flat_map(|(kind, sprite_config)| {
|
.flat_map(|(kind, sprite_config)| {
|
||||||
sprite_config.variations.iter().enumerate().map(
|
sprite_config.variations.iter().enumerate().map(
|
||||||
move |(
|
move |(
|
||||||
|
Loading…
Reference in New Issue
Block a user