mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-05 17:44:52 +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 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 {
|
struct Config {
|
||||||
region_dir: PathBuf,
|
region_dir: PathBuf,
|
||||||
|
@ -195,7 +200,7 @@ impl<'a> RegionProcessor<'a> {
|
||||||
|
|
||||||
minedmap::io::region::from_file(path)?.foreach_chunk(
|
minedmap::io::region::from_file(path)?.foreach_chunk(
|
||||||
|chunk_coords, data: world::de::Chunk| {
|
|chunk_coords, data: world::de::Chunk| {
|
||||||
let Some(((processed_chunk, _), block_light)) = self
|
let Some((processed_chunk, block_light)) = self
|
||||||
.process_chunk(data)
|
.process_chunk(data)
|
||||||
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
.with_context(|| format!("Failed to process chunk {:?}", chunk_coords))?
|
||||||
else {
|
else {
|
||||||
|
@ -299,13 +304,14 @@ impl<'a> TileRenderer<'a> {
|
||||||
fn render_chunk(
|
fn render_chunk(
|
||||||
image: &mut image::RgbaImage,
|
image: &mut image::RgbaImage,
|
||||||
coords: ChunkCoords,
|
coords: ChunkCoords,
|
||||||
chunk: &world::layer::BlockInfoArray,
|
blocks: &world::layer::BlockInfoArray,
|
||||||
|
_biomes: &world::layer::BiomeArray,
|
||||||
) {
|
) {
|
||||||
const N: u32 = BLOCKS_PER_CHUNK as u32;
|
const N: u32 = BLOCKS_PER_CHUNK as u32;
|
||||||
|
|
||||||
let chunk_image = image::RgbaImage::from_fn(N, N, |x, z| {
|
let chunk_image = image::RgbaImage::from_fn(N, N, |x, z| {
|
||||||
image::Rgba(
|
image::Rgba(
|
||||||
match &chunk[LayerBlockCoords {
|
match &blocks[LayerBlockCoords {
|
||||||
x: BlockX(x as u8),
|
x: BlockX(x as u8),
|
||||||
z: BlockZ(z as u8),
|
z: BlockZ(z as u8),
|
||||||
}] {
|
}] {
|
||||||
|
@ -319,11 +325,11 @@ impl<'a> TileRenderer<'a> {
|
||||||
|
|
||||||
fn render_region(image: &mut image::RgbaImage, region: &ProcessedRegion) {
|
fn render_region(image: &mut image::RgbaImage, region: &ProcessedRegion) {
|
||||||
for (coords, chunk) in region.iter() {
|
for (coords, chunk) in region.iter() {
|
||||||
let Some(chunk) = chunk else {
|
let Some((blocks, biomes)) = chunk else {
|
||||||
continue;
|
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;
|
use super::Color;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub enum BiomeGrassColorModifier {
|
pub enum BiomeGrassColorModifier {
|
||||||
DarkForest,
|
DarkForest,
|
||||||
Swamp,
|
Swamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy)]
|
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
|
||||||
pub struct Biome {
|
pub struct Biome {
|
||||||
pub temp: i8,
|
pub temp: i8,
|
||||||
pub downfall: i8,
|
pub downfall: i8,
|
||||||
|
|
Loading…
Add table
Reference in a new issue