main: pass biome into block_color()

No biome edge smoothing yet.
This commit is contained in:
Matthias Schiffer 2023-04-10 20:58:07 +02:00
parent 0d81dfa35b
commit d79377ad6b
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C

View file

@ -8,7 +8,7 @@ use clap::Parser;
use minedmap::{ use minedmap::{
io::storage, io::storage,
resource, resource::{self, Biome},
types::*, types::*,
world::{ world::{
self, self,
@ -288,7 +288,7 @@ impl<'a> TileRenderer<'a> {
storage::read(&processed_path).context("Failed to load processed region data") storage::read(&processed_path).context("Failed to load processed region data")
} }
fn block_color(block: &BlockInfo) -> [u8; 4] { fn block_color(block: &BlockInfo, _biome: &Biome) -> [u8; 4] {
let h = block let h = block
.depth .depth
.map(|depth| 0.5 + 0.005 * depth.0 as f32) .map(|depth| 0.5 + 0.005 * depth.0 as f32)
@ -305,20 +305,19 @@ impl<'a> TileRenderer<'a> {
image: &mut image::RgbaImage, image: &mut image::RgbaImage,
coords: ChunkCoords, coords: ChunkCoords,
blocks: &world::layer::BlockInfoArray, blocks: &world::layer::BlockInfoArray,
_biomes: &world::layer::BiomeArray, 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( let coords = LayerBlockCoords {
match &blocks[LayerBlockCoords { x: BlockX(x as u8),
x: BlockX(x as u8), z: BlockZ(z as u8),
z: BlockZ(z as u8), };
}] { image::Rgba(match (&blocks[coords], &biomes[coords]) {
Some(block) => Self::block_color(block), (Some(block), Some(biome)) => Self::block_color(block, biome),
None => [0, 0, 0, 0], _ => [0, 0, 0, 0],
}, })
)
}); });
overlay_chunk(image, &chunk_image, coords); overlay_chunk(image, &chunk_image, coords);
} }