mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-21 22:38:41 -06:00
Better tree gen
This commit is contained in:
parent
de4938ee6a
commit
e2b8cbfdd5
|
@ -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 {
|
||||
//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(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);
|
||||
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) {
|
||||
blocks[x][y][z] = Block::Wood;
|
||||
}
|
||||
}
|
||||
// Part that wraps around the tree
|
||||
{
|
||||
let tree_leaf_height = tree_height - 3;
|
||||
|
|
|
@ -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,
|
||||
},
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue