tile_mipmapper: store tile coordinates in nested map/set

Use the same data structure as the frontend.
This commit is contained in:
Matthias Schiffer 2023-07-02 22:15:25 +02:00
parent 216aa6ceec
commit b63a18ad6f
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
2 changed files with 50 additions and 17 deletions

View file

@ -1,4 +1,5 @@
use std::{
collections::{BTreeMap, BTreeSet},
fmt::Debug,
path::{Path, PathBuf},
};
@ -19,6 +20,19 @@ impl Debug for TileCoords {
}
}
#[derive(Debug, Clone, Default)]
pub struct TileCoordMap(pub BTreeMap<i32, BTreeSet<i32>>);
impl TileCoordMap {
pub fn contains(&self, coords: TileCoords) -> bool {
let Some(xs) = self.0.get(&coords.z) else {
return false;
};
xs.contains(&coords.x)
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ProcessedChunk {
pub blocks: Box<layer::BlockArray>,