From 37ab56115fd07c3fc7350179123ac1afc7a37a74 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Wed, 18 Jan 2023 03:51:11 +0100 Subject: [PATCH] experimenting a bit more --- src/game/world/thread/world_gen.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/game/world/thread/world_gen.rs b/src/game/world/thread/world_gen.rs index 34a403f..e32d129 100644 --- a/src/game/world/thread/world_gen.rs +++ b/src/game/world/thread/world_gen.rs @@ -6,6 +6,9 @@ use crate::game::{ }; const HEIGHTMAP_SCALE: f64 = 0.004; +const MOUNTAINESS_SCALE: f64 = 0.0001; +const MNT_RAMP_1: f64 = 0.5; +const MNT_RAMP_2: f64 = 0.6; const TERRAIN_HEIGHT_MIN: f64 = 64.; const TERRAIN_HEIGHT_MAX: f64 = 80.; @@ -17,14 +20,31 @@ pub fn generate_chunk(position: IVec2, seed: u32) -> ChunkData { let mut terrain_base_fbm: Fbm = Fbm::new(seed); terrain_base_fbm.octaves = 6; + let mut mountainess_base_fbm: Fbm = Fbm::new(seed); + mountainess_base_fbm.octaves = 4; + //put everything together for x in 0..CHUNK_SIZE { for z in 0..CHUNK_SIZE { let point = world_xz.as_dvec2() + DVec2::from_array([x as f64, z as f64]); let heightmap = (terrain_base_fbm.get((point * HEIGHTMAP_SCALE).to_array()) + 1.) / 2.; + let mountainess = (mountainess_base_fbm.get((point * MOUNTAINESS_SCALE).to_array()) + 1.) / 2.; + //generate basic terrain - let terain_height = (TERRAIN_HEIGHT_MIN + (heightmap * TERRAIN_HEIGHT_MAX)).floor() as usize; + let terain_height = + ( + TERRAIN_HEIGHT_MIN + + (heightmap * TERRAIN_HEIGHT_MAX * (1. + if mountainess < MNT_RAMP_1 { + 0. + } else { + if mountainess > MNT_RAMP_2 { + 1. + } else { + mountainess - MNT_RAMP_1 + } + })) + ).floor() as usize; for y in 0..terain_height { chunk[x][y][z] = Block::Dirt; }