mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-04-21 03:45:07 +02:00
core: deserialize biome list into Vec
Only use IndexSet for deduplication while processing the biome; when deserializing, no deduplication is required, so using a Vec is faster (besides IndexSet missing non-serde support for bincode 2).
This commit is contained in:
parent
deb232ddf3
commit
404ad74235
3 changed files with 12 additions and 5 deletions
|
@ -8,7 +8,6 @@ use std::{
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use clap::ValueEnum;
|
use clap::ValueEnum;
|
||||||
use indexmap::IndexSet;
|
|
||||||
use regex::{Regex, RegexSet};
|
use regex::{Regex, RegexSet};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
@ -102,7 +101,7 @@ pub struct ProcessedRegion {
|
||||||
/// List of biomes used in the region
|
/// List of biomes used in the region
|
||||||
///
|
///
|
||||||
/// Indexed by [ProcessedChunk] biome data
|
/// Indexed by [ProcessedChunk] biome data
|
||||||
pub biome_list: IndexSet<Biome>,
|
pub biome_list: Vec<Biome>,
|
||||||
/// Processed chunk data
|
/// Processed chunk data
|
||||||
pub chunks: ChunkArray<Option<Box<ProcessedChunk>>>,
|
pub chunks: ChunkArray<Option<Box<ProcessedChunk>>>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
//! The [RegionProcessor] and related functions
|
//! The [RegionProcessor] and related functions
|
||||||
|
|
||||||
use std::{ffi::OsStr, path::PathBuf, sync::mpsc, time::SystemTime};
|
use std::{ffi::OsStr, mem, path::PathBuf, sync::mpsc, time::SystemTime};
|
||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use enum_map::{Enum, EnumMap};
|
use enum_map::{Enum, EnumMap};
|
||||||
|
use indexmap::IndexSet;
|
||||||
|
use minedmap_resource::Biome;
|
||||||
use rayon::prelude::*;
|
use rayon::prelude::*;
|
||||||
use tracing::{debug, info, warn};
|
use tracing::{debug, info, warn};
|
||||||
|
|
||||||
|
@ -73,6 +75,8 @@ struct SingleRegionProcessor<'a> {
|
||||||
lightmap_needed: bool,
|
lightmap_needed: bool,
|
||||||
/// True if entity output file needs to be updated
|
/// True if entity output file needs to be updated
|
||||||
entities_needed: bool,
|
entities_needed: bool,
|
||||||
|
/// [IndexSet] of biomes used by the processed region
|
||||||
|
biome_list: IndexSet<Biome>,
|
||||||
/// Processed region intermediate data
|
/// Processed region intermediate data
|
||||||
processed_region: ProcessedRegion,
|
processed_region: ProcessedRegion,
|
||||||
/// Lightmap intermediate data
|
/// Lightmap intermediate data
|
||||||
|
@ -108,6 +112,7 @@ impl<'a> SingleRegionProcessor<'a> {
|
||||||
let entities_needed = Some(input_timestamp) > entities_timestamp;
|
let entities_needed = Some(input_timestamp) > entities_timestamp;
|
||||||
|
|
||||||
let processed_region = ProcessedRegion::default();
|
let processed_region = ProcessedRegion::default();
|
||||||
|
let biome_list = IndexSet::default();
|
||||||
let lightmap = image::GrayAlphaImage::new(N, N);
|
let lightmap = image::GrayAlphaImage::new(N, N);
|
||||||
let entities = ProcessedEntities::default();
|
let entities = ProcessedEntities::default();
|
||||||
|
|
||||||
|
@ -127,6 +132,7 @@ impl<'a> SingleRegionProcessor<'a> {
|
||||||
lightmap_needed,
|
lightmap_needed,
|
||||||
entities_needed,
|
entities_needed,
|
||||||
processed_region,
|
processed_region,
|
||||||
|
biome_list,
|
||||||
lightmap,
|
lightmap,
|
||||||
entities,
|
entities,
|
||||||
image_format: processor.config.tile_image_format(),
|
image_format: processor.config.tile_image_format(),
|
||||||
|
@ -220,7 +226,7 @@ impl<'a> SingleRegionProcessor<'a> {
|
||||||
biomes,
|
biomes,
|
||||||
block_light,
|
block_light,
|
||||||
depths,
|
depths,
|
||||||
}) = world::layer::top_layer(&mut self.processed_region.biome_list, &chunk)
|
}) = world::layer::top_layer(&mut self.biome_list, &chunk)
|
||||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
||||||
{
|
{
|
||||||
if self.output_needed {
|
if self.output_needed {
|
||||||
|
@ -291,6 +297,8 @@ impl<'a> SingleRegionProcessor<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.processed_region.biome_list = mem::take(&mut self.biome_list).into_iter().collect();
|
||||||
|
|
||||||
self.save_region()?;
|
self.save_region()?;
|
||||||
self.save_lightmap()?;
|
self.save_lightmap()?;
|
||||||
self.save_entities()?;
|
self.save_entities()?;
|
||||||
|
|
|
@ -187,7 +187,7 @@ impl<'a> TileRenderer<'a> {
|
||||||
|
|
||||||
for ((region_x, region_z, index), w) in weights.into_values() {
|
for ((region_x, region_z, index), w) in weights.into_values() {
|
||||||
let region = region_group.get(region_x, region_z)?;
|
let region = region_group.get(region_x, region_z)?;
|
||||||
let biome = region.biome_list.get_index(index.into())?;
|
let biome = region.biome_list.get(usize::from(index))?;
|
||||||
|
|
||||||
total += w;
|
total += w;
|
||||||
color += w * block_color(block, Some(biome), depth.0 as f32);
|
color += w * block_color(block, Some(biome), depth.0 as f32);
|
||||||
|
|
Loading…
Add table
Reference in a new issue