mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
river generation
This commit is contained in:
parent
b7ec1d1165
commit
fc783d52dc
|
@ -19,6 +19,7 @@ pub enum BlockTexture {
|
||||||
GrassSideSnow,
|
GrassSideSnow,
|
||||||
Cobblestone,
|
Cobblestone,
|
||||||
Planks,
|
Planks,
|
||||||
|
WaterSolid,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Encode, Decode, Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
|
#[derive(Encode, Decode, Clone, Copy, Debug, PartialEq, Eq, EnumIter)]
|
||||||
|
@ -36,6 +37,7 @@ pub enum Block {
|
||||||
Torch,
|
Torch,
|
||||||
Wood,
|
Wood,
|
||||||
Leaf,
|
Leaf,
|
||||||
|
Water,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Block {
|
impl Block {
|
||||||
|
@ -118,6 +120,12 @@ impl Block {
|
||||||
collision: CollisionType::Solid,
|
collision: CollisionType::Solid,
|
||||||
raycast_collision: true,
|
raycast_collision: true,
|
||||||
},
|
},
|
||||||
|
Self::Water => BlockDescriptor {
|
||||||
|
name: "water",
|
||||||
|
render: RenderType::BinaryTransparency(CubeTexture::all(BlockTexture::WaterSolid)),
|
||||||
|
collision: CollisionType::None,
|
||||||
|
raycast_collision: false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,11 +125,13 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
|
||||||
}
|
}
|
||||||
//Generate rivers
|
//Generate rivers
|
||||||
{
|
{
|
||||||
|
let river_width = (height as f32 / -5.).clamp(0.5, 1.);
|
||||||
let river_value = river_noise.get_noise(noise_x, noise_y);
|
let river_value = river_noise.get_noise(noise_x, noise_y);
|
||||||
if (-0.00625..0.00625).contains(&(river_value.powi(2))) {
|
if ((-0.00625 * river_width)..(0.00625 * river_width)).contains(&(river_value.powi(2))) {
|
||||||
is_surface = false;
|
is_surface = false;
|
||||||
river_fill_height = Some(height);
|
river_fill_height = Some(height - 1);
|
||||||
height -= (15. * (0.00625 - river_value.powi(2)) * (1. / 0.00625)).round() as i32;
|
//river_fill_height = Some(-3);
|
||||||
|
height -= (river_width * 15. * ((0.00625 * river_width) - river_value.powi(2)) * (1. / (0.00625 * river_width))).round() as i32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Generate ravines
|
//Generate ravines
|
||||||
|
@ -163,6 +165,24 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
|
||||||
within_heightmap = true;
|
within_heightmap = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
if let Some(river_fill_height) = river_fill_height {
|
||||||
|
//Place water
|
||||||
|
for y in 0..local_height(river_fill_height, chunk_position) {
|
||||||
|
blocks[x][y][z] = Block::Water;
|
||||||
|
within_heightmap = true;
|
||||||
|
}
|
||||||
|
//Place stone
|
||||||
|
for y in 0..local_height(height - 1, chunk_position) {
|
||||||
|
blocks[x][y][z] = Block::Stone;
|
||||||
|
within_heightmap = true;
|
||||||
|
}
|
||||||
|
//Place dirt
|
||||||
|
if let Some(y) = local_y_position(height, chunk_position) {
|
||||||
|
blocks[x][y][z] = Block::Dirt;
|
||||||
|
within_heightmap = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
//Place stone
|
||||||
for y in 0..local_height(height, chunk_position) {
|
for y in 0..local_height(height, chunk_position) {
|
||||||
blocks[x][y][z] = Block::Stone;
|
blocks[x][y][z] = Block::Stone;
|
||||||
within_heightmap = true;
|
within_heightmap = true;
|
||||||
|
@ -170,6 +190,7 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Carve out caves
|
//Carve out caves
|
||||||
if within_heightmap {
|
if within_heightmap {
|
||||||
|
|
|
@ -31,6 +31,7 @@ impl AssetPaths for BlockTexture {
|
||||||
Self::GrassSideSnow => "grass_side_snow.png",
|
Self::GrassSideSnow => "grass_side_snow.png",
|
||||||
Self::Cobblestone => "cobblestone.png",
|
Self::Cobblestone => "cobblestone.png",
|
||||||
Self::Planks => "planks.png",
|
Self::Planks => "planks.png",
|
||||||
|
Self::WaterSolid => "solid_water.png",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue