Better tree gen

This commit is contained in:
griffi-gh 2023-02-17 22:25:53 +01:00
parent de4938ee6a
commit e2b8cbfdd5
3 changed files with 12 additions and 7 deletions

View file

@ -114,14 +114,16 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
}
//place trees!
if rng_map_a[x][z] < 0.001 {
if let Some(y) = local_y_position(height + 1, chunk_position) {
let tree_pos = ivec3(x as i32, y as i32, z as i32);
//Place wood (no smart_place needed here!)
let tree_height = 4 + (rng_map_b[x][z] * 3.).round() as i32;
for tree_y in 0..tree_height {
if let Some(y) = local_y_position(offset.y + tree_y, chunk_position) {
if let Some(y) = local_y_position(height + 1 + tree_y, chunk_position) {
blocks[x][y][z] = Block::Wood;
}
}
//Place leaf blocks
if let Some(y) = local_y_position(height + 1, chunk_position) {
let tree_pos = ivec3(x as i32, y as i32, z as i32);
// Part that wraps around the tree
{
let tree_leaf_height = tree_height - 3;

View file

@ -142,7 +142,7 @@ pub fn draw_current_chunk_border(
Quat::default(),
world_position
).to_cols_array_2d(),
color: [0.15f32; 4],
color: [0.25f32; 4],
view: view,
perspective: perspective,
},

View file

@ -32,6 +32,9 @@ pub fn apply_queued_blocks(
//maybe i need to check for desired/current state here before marking as dirty?
queue.queue.retain(|&event| {
if let Some(block) = world.get_block_mut(event.position) {
if event.soft && *block != Block::Air {
return false
}
*block = event.value;
//mark chunk as dirty
let (chunk_pos, block_pos) = ChunkStorage::to_chunk_coords(event.position);