From 31b2693b78983575cb20b9468d1d1f184cd938ee Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sat, 11 Apr 2020 21:03:32 +0100 Subject: [PATCH] Fixed river width determination --- world/src/civ/mod.rs | 2 +- world/src/column/mod.rs | 6 +++--- world/src/site/settlement/mod.rs | 34 +++++++++++++++++--------------- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/world/src/civ/mod.rs b/world/src/civ/mod.rs index 548d66a185..b1f9005b29 100644 --- a/world/src/civ/mod.rs +++ b/world/src/civ/mod.rs @@ -100,7 +100,7 @@ impl Civs { let flatten_radius = 12.0; if let Some(center_alt) = ctx.sim.get_alt_approx(wpos) { for pos in nearby_chunks.clone() { - let factor = (1.0 - (site.center - pos).map(|e| e as f32).magnitude() / flatten_radius) * 1.3; + let factor = (1.0 - (site.center - pos).map(|e| e as f32).magnitude() / flatten_radius) * 1.15; ctx.sim .get_mut(pos) // Don't disrupt chunks that are near water diff --git a/world/src/column/mod.rs b/world/src/column/mod.rs index 201d23df51..d7aab1809b 100644 --- a/world/src/column/mod.rs +++ b/world/src/column/mod.rs @@ -629,7 +629,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { Some(( true, - Some(river_dist as f32), + Some((river_dist - river_width * 0.5) as f32), valley_alt, new_alt, valley_alt + river_gouge, @@ -676,7 +676,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { let _river_height_factor = river_dist / (river_width * 0.5); return Some(( true, - Some(river_dist as f32), + Some((river_dist - river_width * 0.5) as f32), alt_for_river.min(lake_water_alt - 1.0 - river_gouge), lake_water_alt - river_gouge, alt_for_river.min(lake_water_alt - 1.0), @@ -686,7 +686,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> { Some(( river_scale_factor <= 1.0, - Some(wposf.distance(river_pos) as f32), + Some((wposf.distance(river_pos) - river_width * 0.5) as f32), alt_for_river, downhill_water_alt, alt_for_river, diff --git a/world/src/site/settlement/mod.rs b/world/src/site/settlement/mod.rs index e5f9ee4582..223b179252 100644 --- a/world/src/site/settlement/mod.rs +++ b/world/src/site/settlement/mod.rs @@ -291,7 +291,7 @@ impl Settlement { { Some(Plot::Hazard) => 200.0, Some(Plot::Water) => 40.0, - Some(Plot::Town) => 1000.0, + Some(Plot::Town) => 10000.0, _ => 10.0, }) .map(|path| wall_path.extend(path.iter().copied())); @@ -482,7 +482,7 @@ impl Settlement { // Try to use the column at the centre of the path for sampling to make them flatter let col = get_column(offs + (nearest.floor().map(|e| e as i32) - rpos)).unwrap_or(col_sample); let bridge_offset = if let Some(water_dist) = col.water_dist { - ((water_dist.abs() * 0.2).min(f32::consts::PI).cos() + 1.0) * 5.0 + ((water_dist.max(0.0) * 0.2).min(f32::consts::PI).cos() + 1.0) * 5.0 } else { 0.0 }; @@ -500,22 +500,24 @@ impl Settlement { } let head_space = (8 - (dist * 0.25).powf(6.0).round() as i32).max(1); for z in inset..inset + head_space { - vol.set( - Vec3::new(offs.x, offs.y, surface_z + z), - Block::empty(), - ); + let pos = Vec3::new(offs.x, offs.y, surface_z + z); + if vol.get(pos).unwrap().kind() != BlockKind::Water { + vol.set(pos, Block::empty()); + } } // Ground colour } else if let Some(color) = self.get_color(rpos) { - for z in -8..6 { - let pos = Vec3::new(offs.x, offs.y, surface_z + z); + if col_sample.water_dist.map(|dist| dist > 2.0).unwrap_or(true) { + for z in -8..6 { + let pos = Vec3::new(offs.x, offs.y, surface_z + z); - if z >= 0 { - if vol.get(pos).unwrap().kind() != BlockKind::Water { - vol.set(pos, Block::empty()); + if z >= 0 { + if vol.get(pos).unwrap().kind() != BlockKind::Water { + vol.set(pos, Block::empty()); + } + } else { + vol.set(pos, Block::new(BlockKind::Normal, noisy_color(color, 4))); } - } else { - vol.set(pos, Block::new(BlockKind::Normal, noisy_color(color, 4))); } } } @@ -531,7 +533,7 @@ impl Settlement { let z_offset = if let Some(water_dist) = col_sample.water_dist { // Water gate - ((water_dist.abs() * 0.45).min(f32::consts::PI).cos() + 1.0) * 4.0 + ((water_dist.max(0.0) * 0.45).min(f32::consts::PI).cos() + 1.0) * 4.0 } else { 0.0 } as i32; @@ -550,7 +552,7 @@ impl Settlement { // Towers if let Some((Tower::Wall, _pos)) = sample.tower { - for z in 0..16 { + for z in -2..16 { vol.set( Vec3::new(offs.x, offs.y, surface_z + z), Block::new(BlockKind::Normal, Rgb::new(50, 50, 50)), @@ -579,7 +581,7 @@ impl Settlement { for x in bounds.min.x..bounds.max.x + 1 { for y in bounds.min.y..bounds.max.y + 1 { - let col = if let Some(col) = get_column(offs) { + let col = if let Some(col) = get_column(self.origin + Vec2::new(x, y) - wpos2d) { col } else { continue;