mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-25 21:28:20 -06:00
Better tree gen
This commit is contained in:
parent
7d46e46e88
commit
32a293922a
|
@ -114,14 +114,16 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
|
||||||
}
|
}
|
||||||
//place trees!
|
//place trees!
|
||||||
if rng_map_a[x][z] < 0.001 {
|
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) {
|
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_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
|
// Part that wraps around the tree
|
||||||
{
|
{
|
||||||
let tree_leaf_height = tree_height - 3;
|
let tree_leaf_height = tree_height - 3;
|
||||||
|
|
|
@ -142,7 +142,7 @@ pub fn draw_current_chunk_border(
|
||||||
Quat::default(),
|
Quat::default(),
|
||||||
world_position
|
world_position
|
||||||
).to_cols_array_2d(),
|
).to_cols_array_2d(),
|
||||||
color: [0.15f32; 4],
|
color: [0.25f32; 4],
|
||||||
view: view,
|
view: view,
|
||||||
perspective: perspective,
|
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?
|
//maybe i need to check for desired/current state here before marking as dirty?
|
||||||
queue.queue.retain(|&event| {
|
queue.queue.retain(|&event| {
|
||||||
if let Some(block) = world.get_block_mut(event.position) {
|
if let Some(block) = world.get_block_mut(event.position) {
|
||||||
|
if event.soft && *block != Block::Air {
|
||||||
|
return false
|
||||||
|
}
|
||||||
*block = event.value;
|
*block = event.value;
|
||||||
//mark chunk as dirty
|
//mark chunk as dirty
|
||||||
let (chunk_pos, block_pos) = ChunkStorage::to_chunk_coords(event.position);
|
let (chunk_pos, block_pos) = ChunkStorage::to_chunk_coords(event.position);
|
||||||
|
|
Loading…
Reference in a new issue