mirror of
https://github.com/neocturne/MinedMap.git
synced 2025-03-04 17:23:33 +01:00
core/tile_mipmapper: fix file meta version for mipmap tiles
The meta version should only change when the outputs must be regenerated even if the inputs stay the same. This should never be the case for mipmap tiles, so we separate the meta version from map/lightmap tiles.
This commit is contained in:
parent
f79edb462c
commit
0988ebe095
2 changed files with 16 additions and 10 deletions
|
@ -31,6 +31,11 @@ pub const MAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
|
||||||
/// (usually because of updated resource data)
|
/// (usually because of updated resource data)
|
||||||
pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
|
pub const LIGHTMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
|
||||||
|
|
||||||
|
/// MinedMap mipmap data version number
|
||||||
|
///
|
||||||
|
/// Increase when the mipmap generation changes (this should not happen)
|
||||||
|
pub const MIPMAP_FILE_META_VERSION: FileMetaVersion = FileMetaVersion(0);
|
||||||
|
|
||||||
/// Coordinate pair of a generated tile
|
/// Coordinate pair of a generated tile
|
||||||
///
|
///
|
||||||
/// Each tile corresponds to one Minecraft region file
|
/// Each tile corresponds to one Minecraft region file
|
||||||
|
|
|
@ -70,12 +70,8 @@ impl<'a> TileMipmapper<'a> {
|
||||||
/// Tile width/height
|
/// Tile width/height
|
||||||
const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32;
|
const N: u32 = (BLOCKS_PER_CHUNK * CHUNKS_PER_REGION) as u32;
|
||||||
|
|
||||||
let version = match kind {
|
|
||||||
TileKind::Map => REGION_FILE_META_VERSION,
|
|
||||||
TileKind::Lightmap => LIGHTMAP_FILE_META_VERSION,
|
|
||||||
};
|
|
||||||
let output_path = self.config.tile_path(kind, level, coords);
|
let output_path = self.config.tile_path(kind, level, coords);
|
||||||
let output_timestamp = fs::read_timestamp(&output_path, version);
|
let output_timestamp = fs::read_timestamp(&output_path, MIPMAP_FILE_META_VERSION);
|
||||||
|
|
||||||
let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)]
|
let sources: Vec<_> = [(0, 0), (0, 1), (1, 0), (1, 1)]
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -149,11 +145,16 @@ impl<'a> TileMipmapper<'a> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::create_with_timestamp(&output_path, version, input_timestamp, |file| {
|
fs::create_with_timestamp(
|
||||||
image
|
&output_path,
|
||||||
.write_to(file, image::ImageFormat::Png)
|
MIPMAP_FILE_META_VERSION,
|
||||||
.context("Failed to save image")
|
input_timestamp,
|
||||||
})?;
|
|file| {
|
||||||
|
image
|
||||||
|
.write_to(file, image::ImageFormat::Png)
|
||||||
|
.context("Failed to save image")
|
||||||
|
},
|
||||||
|
)?;
|
||||||
|
|
||||||
count_processed.send(()).unwrap();
|
count_processed.send(()).unwrap();
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
Loading…
Add table
Reference in a new issue