Skip to content

Commit

Permalink
Handle voids
Browse files Browse the repository at this point in the history
  • Loading branch information
JayKickliter committed Jan 7, 2024
1 parent c27c7cb commit 667dc2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions hexit/src/elevation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ impl Compactor<Elevation> 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);
Expand Down
1 change: 1 addition & 0 deletions hexit/src/tesselate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ impl Tesselate {
fn tesselate_tile(&self, tile: &Tile, progress_bar: &ProgressBar) -> Result<HexTreeMap<i16>> {
let mut hextree: HexTreeMap<i16> = 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);
Expand Down

0 comments on commit 667dc2c

Please sign in to comment.