Skip to content

Commit

Permalink
make eroding amount more proportional to other terrain tools
Browse files Browse the repository at this point in the history
fixes #115
  • Loading branch information
Uriopass committed Jul 11, 2024
1 parent 6c866ae commit 4203550
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion simulation/src/map/terrain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 4203550

Please sign in to comment.