mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
minedmap: split up big types by adding Boxes
Make these values faster to move around, and optimize their size when used in Options.
This commit is contained in:
parent
cd1a5e869d
commit
7b46adf6e7
3 changed files with 12 additions and 9 deletions
|
@ -48,7 +48,7 @@ pub struct ProcessedChunk {
|
|||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
pub struct ProcessedRegion {
|
||||
pub biome_list: IndexSet<Biome>,
|
||||
pub chunks: ChunkArray<Option<ProcessedChunk>>,
|
||||
pub chunks: ChunkArray<Option<Box<ProcessedChunk>>>,
|
||||
}
|
||||
|
||||
pub struct Config {
|
||||
|
|
|
@ -125,11 +125,11 @@ impl<'a> RegionProcessor<'a> {
|
|||
else {
|
||||
return Ok(());
|
||||
};
|
||||
processed_region.chunks[chunk_coords] = Some(ProcessedChunk {
|
||||
processed_region.chunks[chunk_coords] = Some(Box::new(ProcessedChunk {
|
||||
blocks,
|
||||
biomes,
|
||||
depths,
|
||||
});
|
||||
}));
|
||||
|
||||
let chunk_lightmap = Self::render_chunk_lightmap(block_light);
|
||||
overlay_chunk(&mut lightmap, &chunk_lightmap, chunk_coords);
|
||||
|
|
|
@ -39,7 +39,7 @@ fn coord_offset<const AXIS: u8>(
|
|||
}
|
||||
|
||||
fn biome_at(
|
||||
region_group: &RegionGroup<ProcessedRegion>,
|
||||
region_group: &RegionGroup<Box<ProcessedRegion>>,
|
||||
chunk: ChunkCoords,
|
||||
block: LayerBlockCoords,
|
||||
dx: i32,
|
||||
|
@ -72,18 +72,18 @@ impl<'a> TileRenderer<'a> {
|
|||
TileRenderer { config }
|
||||
}
|
||||
|
||||
fn load_region(processed_path: &Path) -> Result<ProcessedRegion> {
|
||||
fn load_region(processed_path: &Path) -> Result<Box<ProcessedRegion>> {
|
||||
storage::read(processed_path).context("Failed to load processed region data")
|
||||
}
|
||||
|
||||
fn load_region_group(
|
||||
processed_paths: RegionGroup<PathBuf>,
|
||||
) -> Result<RegionGroup<ProcessedRegion>> {
|
||||
) -> Result<RegionGroup<Box<ProcessedRegion>>> {
|
||||
processed_paths.try_map(|path| Self::load_region(&path))
|
||||
}
|
||||
|
||||
fn block_color_at(
|
||||
region_group: &RegionGroup<ProcessedRegion>,
|
||||
region_group: &RegionGroup<Box<ProcessedRegion>>,
|
||||
chunk: &ProcessedChunk,
|
||||
chunk_coords: ChunkCoords,
|
||||
block_coords: LayerBlockCoords,
|
||||
|
@ -141,7 +141,7 @@ impl<'a> TileRenderer<'a> {
|
|||
|
||||
fn render_chunk(
|
||||
image: &mut image::RgbaImage,
|
||||
region_group: &RegionGroup<ProcessedRegion>,
|
||||
region_group: &RegionGroup<Box<ProcessedRegion>>,
|
||||
chunk: &ProcessedChunk,
|
||||
chunk_coords: ChunkCoords,
|
||||
) {
|
||||
|
@ -162,7 +162,10 @@ impl<'a> TileRenderer<'a> {
|
|||
overlay_chunk(image, &chunk_image, chunk_coords);
|
||||
}
|
||||
|
||||
fn render_region(image: &mut image::RgbaImage, region_group: &RegionGroup<ProcessedRegion>) {
|
||||
fn render_region(
|
||||
image: &mut image::RgbaImage,
|
||||
region_group: &RegionGroup<Box<ProcessedRegion>>,
|
||||
) {
|
||||
for (coords, chunk) in region_group.center().chunks.iter() {
|
||||
let Some(chunk) = chunk else {
|
||||
continue;
|
||||
|
|
Loading…
Add table
Reference in a new issue