feat: wire vertical exaggeration through the shell #13

Merged
moldybits merged 25 commits from feat/terrain-gen-abstraction into main 2026-05-20 23:00:29 -04:00
Showing only changes of commit 0fef9d23a8 - Show all commits
+16 -6
View File
@@ -434,19 +434,27 @@ mod tests {
} }
#[test] #[test]
fn render_plane_is_uniform_water() { fn render_plane_shows_distinct_hydrology_overlays() {
let grid = HeightGrid::plane(4, 4).unwrap(); let grid = HeightGrid::plane(32, 32).unwrap();
let img = render_top_down(&grid, &fixture_scene()); let img = render_top_down(&grid, &fixture_scene());
let mut saw_base_water = false;
let mut saw_feature = false;
for y in 0..img.height() { for y in 0..img.height() {
for x in 0..img.width() { for x in 0..img.width() {
let p = img.get_pixel(x, y); match img.get_pixel(x, y).0 {
assert_eq!(p.0, WATER_COLOR, "pixel at ({x},{y}) should be water"); c if c == WATER_COLOR => saw_base_water = true,
c if c != WATER_COLOR => saw_feature = true,
_ => unreachable!(),
} }
} }
} }
assert!(saw_base_water, "expected background water pixels");
assert!(saw_feature, "expected lake/river overlay pixels");
}
#[test] #[test]
fn render_hill_has_all_four_bands() { fn render_hill_has_all_four_bands_and_hydrology_overlays() {
let grid = HeightGrid::radial_hill(33, 33, 10.0).unwrap(); let grid = HeightGrid::radial_hill(33, 33, 10.0).unwrap();
let img = render_top_down(&grid, &fixture_scene()); let img = render_top_down(&grid, &fixture_scene());
@@ -454,6 +462,7 @@ mod tests {
let mut saw_lowland = false; let mut saw_lowland = false;
let mut saw_highland = false; let mut saw_highland = false;
let mut saw_snow = false; let mut saw_snow = false;
let mut saw_overlay = false;
for y in 0..img.height() { for y in 0..img.height() {
for x in 0..img.width() { for x in 0..img.width() {
match img.get_pixel(x, y).0 { match img.get_pixel(x, y).0 {
@@ -461,7 +470,7 @@ mod tests {
c if c == LOWLAND_COLOR => saw_lowland = true, c if c == LOWLAND_COLOR => saw_lowland = true,
c if c == HIGHLAND_COLOR => saw_highland = true, c if c == HIGHLAND_COLOR => saw_highland = true,
c if c == SNOW_COLOR => saw_snow = true, c if c == SNOW_COLOR => saw_snow = true,
other => panic!("unexpected color {other:?} at ({x},{y})"), _ => saw_overlay = true,
} }
} }
} }
@@ -469,6 +478,7 @@ mod tests {
assert!(saw_lowland, "expected at least one lowland pixel"); assert!(saw_lowland, "expected at least one lowland pixel");
assert!(saw_highland, "expected at least one highland pixel"); assert!(saw_highland, "expected at least one highland pixel");
assert!(saw_snow, "expected at least one snow pixel"); assert!(saw_snow, "expected at least one snow pixel");
assert!(saw_overlay, "expected lake/river overlay pixels");
} }
#[test] #[test]