mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
main: store biome data in processed data files
This commit is contained in:
parent
e912f60ba3
commit
0d81dfa35b
2 changed files with 16 additions and 8 deletions
18
src/main.rs
18
src/main.rs
|
@ -25,7 +25,12 @@ struct Args {
|
|||
}
|
||||
|
||||
type RegionCoords = (i32, i32);
|
||||
type ProcessedRegion = ChunkArray<Option<Box<world::layer::BlockInfoArray>>>;
|
||||
type ProcessedRegion = ChunkArray<
|
||||
Option<(
|
||||
Box<world::layer::BlockInfoArray>,
|
||||
Box<world::layer::BiomeArray>,
|
||||
)>,
|
||||
>;
|
||||
|
||||
struct Config {
|
||||
region_dir: PathBuf,
|
||||
|
@ -195,7 +200,7 @@ impl<'a> RegionProcessor<'a> {
|
|||
|
||||
minedmap::io::region::from_file(path)?.foreach_chunk(
|
||||
|chunk_coords, data: world::de::Chunk| {
|
||||
let Some(((processed_chunk, _), block_light)) = self
|
||||
let Some((processed_chunk, block_light)) = self
|
||||
.process_chunk(data)
|
||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
||||
else {
|
||||
|
@ -299,13 +304,14 @@ impl<'a> TileRenderer<'a> {
|
|||
fn render_chunk(
|
||||
image: &mut image::RgbaImage,
|
||||
coords: ChunkCoords,
|
||||
chunk: &world::layer::BlockInfoArray,
|
||||
blocks: &world::layer::BlockInfoArray,
|
||||
_biomes: &world::layer::BiomeArray,
|
||||
) {
|
||||
const N: u32 = BLOCKS_PER_CHUNK as u32;
|
||||
|
||||
let chunk_image = image::RgbaImage::from_fn(N, N, |x, z| {
|
||||
image::Rgba(
|
||||
match &chunk[LayerBlockCoords {
|
||||
match &blocks[LayerBlockCoords {
|
||||
x: BlockX(x as u8),
|
||||
z: BlockZ(z as u8),
|
||||
}] {
|
||||
|
@ -319,11 +325,11 @@ impl<'a> TileRenderer<'a> {
|
|||
|
||||
fn render_region(image: &mut image::RgbaImage, region: &ProcessedRegion) {
|
||||
for (coords, chunk) in region.iter() {
|
||||
let Some(chunk) = chunk else {
|
||||
let Some((blocks, biomes)) = chunk else {
|
||||
continue;
|
||||
};
|
||||
|
||||
Self::render_chunk(image, coords, chunk);
|
||||
Self::render_chunk(image, coords, blocks, biomes);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::Color;
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub enum BiomeGrassColorModifier {
|
||||
DarkForest,
|
||||
Swamp,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||
pub struct Biome {
|
||||
pub temp: i8,
|
||||
pub downfall: i8,
|
||||
|
|
Loading…
Add table
Reference in a new issue