From 667dc2c80986434ae20cef25d18a0a2b66ceaf9c Mon Sep 17 00:00:00 2001 From: Jay Kickliter Date: Sun, 7 Jan 2024 01:12:27 +0000 Subject: [PATCH] Handle voids --- hexit/src/elevation.rs | 4 ++++ hexit/src/tesselate.rs | 1 + 2 files changed, 5 insertions(+) diff --git a/hexit/src/elevation.rs b/hexit/src/elevation.rs index 71756f3..d38b3d4 100644 --- a/hexit/src/elevation.rs +++ b/hexit/src/elevation.rs @@ -101,6 +101,10 @@ impl Compactor for CloseEnoughCompactor { let mut n_max = i16::MIN; let mut n_n = 0; for Elevation { min, sum, max, n } in [v0, v1, v2, v3, v4, v5, v6] { + // HACK: Ignore voids that snuck through. + if [min, max].contains(&&i16::MIN) { + continue; + } n_min = i16::min(n_min, *min); n_sum += sum; n_max = i16::max(n_max, *max); diff --git a/hexit/src/tesselate.rs b/hexit/src/tesselate.rs index 71bbe7b..22a71f3 100644 --- a/hexit/src/tesselate.rs +++ b/hexit/src/tesselate.rs @@ -84,6 +84,7 @@ impl Tesselate { fn tesselate_tile(&self, tile: &Tile, progress_bar: &ProgressBar) -> Result> { let mut hextree: HexTreeMap = HexTreeMap::new(); for sample in tile.iter() { + assert_ne!(sample.elevation(), i16::MIN); let (elev, hexes) = Self::tesselate_sample(&sample, self.resolution)?; for hex in hexes { hextree.insert(Cell::try_from(hex)?, elev);