From 9268a293a88f0b7bd49de6544d3ffbc888c75878 Mon Sep 17 00:00:00 2001 From: griffi-gh Date: Sat, 18 Feb 2023 00:37:17 +0100 Subject: [PATCH] improve worldgen --- assets/blocks/solid_water.png | Bin 0 -> 210 bytes kubi-shared/src/block.rs | 7 ++ kubi-shared/src/worldgen.rs | 126 ++++++++++++++++++++++++++-------- 3 files changed, 106 insertions(+), 27 deletions(-) create mode 100644 assets/blocks/solid_water.png diff --git a/assets/blocks/solid_water.png b/assets/blocks/solid_water.png new file mode 100644 index 0000000000000000000000000000000000000000..7505981b6aed71a697a08740a2c146c12b84a8b4 GIT binary patch literal 210 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!73?$#)eFPF~9{M`SSr1K(i~W;~w1A_XWI BlockDescriptor { + name: "marker", + render: RenderType::None, + collision: CollisionType::None, + raycast_collision: false, + }, Self::Stone => BlockDescriptor { name: "stone", render: RenderType::SolidBlock(CubeTexture::all(BlockTexture::Stone)), diff --git a/kubi-shared/src/worldgen.rs b/kubi-shared/src/worldgen.rs index 0de0826..954293e 100644 --- a/kubi-shared/src/worldgen.rs +++ b/kubi-shared/src/worldgen.rs @@ -63,7 +63,7 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec (BlockData, Vec (BlockData, Vec 0.4 { + let raw_ravine_value = ravine_nose_line.get_noise(noise_x, noise_y); + if (-0.0125..0.0125).contains(&(raw_ravine_value.powi(2))) { + is_surface = false; + height -= (100. * (0.0125 - raw_ravine_value.powi(2)) * (1. / 0.0125)).round() as i32; + } + } + } height }; //add to heightmap - heightmap[x as usize][z as usize] = height; - //place dirt - for y in 0..local_height(height, chunk_position) { - blocks[x][y][z] = Block::Dirt; - within_heightmap = true; - } - //place stone - for y in 0..local_height(height - 5 - (raw_heightmap_value * 5.) as i32, chunk_position) { - blocks[x][y][z] = Block::Stone; - within_heightmap = true; - } - //place grass - if let Some(y) = local_y_position(height, chunk_position) { - blocks[x][y][z] = Block::Grass; + if is_surface { + deco_heightmap[x as usize][z as usize] = Some(height); + //place dirt + for y in 0..local_height(height, chunk_position) { + blocks[x][y][z] = Block::Dirt; + within_heightmap = true; + } + //place stone + for y in 0..local_height(height - 5 - (raw_heightmap_value * 5.) as i32, chunk_position) { + blocks[x][y][z] = Block::Stone; + within_heightmap = true; + } + //place grass + if let Some(y) = local_y_position(height, chunk_position) { + blocks[x][y][z] = Block::Grass; + within_heightmap = true; + } + } else { + for y in 0..local_height(height, chunk_position) { + blocks[x][y][z] = Block::Stone; + within_heightmap = true; + } } } } @@ -128,15 +173,30 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec (BlockData, Vec (BlockData, Vec (BlockData, Vec