From 420355036d9bdc830900b04c03fb800b3874196c Mon Sep 17 00:00:00 2001 From: Paris DOUADY Date: Thu, 11 Jul 2024 11:17:11 +0200 Subject: [PATCH] make eroding amount more proportional to other terrain tools fixes #115 --- simulation/src/map/terrain.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/simulation/src/map/terrain.rs b/simulation/src/map/terrain.rs index 35bc4a34..59783d54 100644 --- a/simulation/src/map/terrain.rs +++ b/simulation/src/map/terrain.rs @@ -237,8 +237,14 @@ impl Environment { }), TerraformKind::Erode => { let mut rng = common::rand::gen(tick.0); + let n_particles_continuous = amount * DELTA * radius * radius * 0.00002; + let mut n_particles = n_particles_continuous as usize; + if n_particles_continuous.fract() > rng.next_f32() { + n_particles += 1; + } + self.heightmap - .erode(bbox, amount.clamp(0.0, 1000.0) as usize, || rng.next_f32()) + .erode(bbox, n_particles, || rng.next_f32()) .into_iter() .map(|(x, y)| TerrainChunkID::new_i16(x as i16, y as i16)) .collect()