mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
main: pass biome into block_color()
No biome edge smoothing yet.
This commit is contained in:
parent
0d81dfa35b
commit
d79377ad6b
1 changed files with 11 additions and 12 deletions
23
src/main.rs
23
src/main.rs
|
@ -8,7 +8,7 @@ use clap::Parser;
|
|||
|
||||
use minedmap::{
|
||||
io::storage,
|
||||
resource,
|
||||
resource::{self, Biome},
|
||||
types::*,
|
||||
world::{
|
||||
self,
|
||||
|
@ -288,7 +288,7 @@ impl<'a> TileRenderer<'a> {
|
|||
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
|
||||
.depth
|
||||
.map(|depth| 0.5 + 0.005 * depth.0 as f32)
|
||||
|
@ -305,20 +305,19 @@ impl<'a> TileRenderer<'a> {
|
|||
image: &mut image::RgbaImage,
|
||||
coords: ChunkCoords,
|
||||
blocks: &world::layer::BlockInfoArray,
|
||||
_biomes: &world::layer::BiomeArray,
|
||||
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 &blocks[LayerBlockCoords {
|
||||
x: BlockX(x as u8),
|
||||
z: BlockZ(z as u8),
|
||||
}] {
|
||||
Some(block) => Self::block_color(block),
|
||||
None => [0, 0, 0, 0],
|
||||
},
|
||||
)
|
||||
let coords = LayerBlockCoords {
|
||||
x: BlockX(x as u8),
|
||||
z: BlockZ(z as u8),
|
||||
};
|
||||
image::Rgba(match (&blocks[coords], &biomes[coords]) {
|
||||
(Some(block), Some(biome)) => Self::block_color(block, biome),
|
||||
_ => [0, 0, 0, 0],
|
||||
})
|
||||
});
|
||||
overlay_chunk(image, &chunk_image, coords);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue