mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
minedmap/tile_renderer: load 3x3 neighbourhoods of regions
Prepare for biome smoothing by always loading neighbouring regions.
This commit is contained in:
parent
a30266f67f
commit
35bbd167ba
1 changed files with 11 additions and 4 deletions
|
@ -26,6 +26,12 @@ 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 load_region_group(
|
||||||
|
processed_paths: RegionGroup<PathBuf>,
|
||||||
|
) -> Result<RegionGroup<ProcessedRegion>> {
|
||||||
|
processed_paths.try_map(|path| Self::load_region(&path))
|
||||||
|
}
|
||||||
|
|
||||||
fn render_chunk(image: &mut image::RgbaImage, coords: ChunkCoords, chunk: &ProcessedChunk) {
|
fn render_chunk(image: &mut image::RgbaImage, coords: ChunkCoords, chunk: &ProcessedChunk) {
|
||||||
const N: u32 = BLOCKS_PER_CHUNK as u32;
|
const N: u32 = BLOCKS_PER_CHUNK as u32;
|
||||||
|
|
||||||
|
@ -50,8 +56,8 @@ impl<'a> TileRenderer<'a> {
|
||||||
overlay_chunk(image, &chunk_image, coords);
|
overlay_chunk(image, &chunk_image, coords);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_region(image: &mut image::RgbaImage, region: &ProcessedRegion) {
|
fn render_region(image: &mut image::RgbaImage, region_group: &RegionGroup<ProcessedRegion>) {
|
||||||
for (coords, chunk) in region.iter() {
|
for (coords, chunk) in region_group.center().iter() {
|
||||||
let Some(chunk) = chunk else {
|
let Some(chunk) = chunk else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
@ -112,9 +118,10 @@ impl<'a> TileRenderer<'a> {
|
||||||
.display(),
|
.display(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let region = Self::load_region(processed_paths.center())?;
|
let region_group = Self::load_region_group(processed_paths)
|
||||||
|
.with_context(|| format!("Region {:?} from previous step must be loadable", coords))?;
|
||||||
let mut image = image::RgbaImage::new(N, N);
|
let mut image = image::RgbaImage::new(N, N);
|
||||||
Self::render_region(&mut image, ®ion);
|
Self::render_region(&mut image, ®ion_group);
|
||||||
|
|
||||||
fs::create_with_timestamp(
|
fs::create_with_timestamp(
|
||||||
&output_path,
|
&output_path,
|
||||||
|
|
Loading…
Add table
Reference in a new issue