soft updates

This commit is contained in:
griffi-gh 2023-02-17 22:03:45 +01:00
parent 4a84fec041
commit de4938ee6a
5 changed files with 9 additions and 3 deletions

View file

@ -118,7 +118,9 @@ pub fn generate_world(chunk_position: IVec3, seed: u64) -> (BlockData, Vec<Queue
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 {
smart_place(&mut blocks, tree_pos + IVec3::Y * tree_y, Block::Wood);
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
{

View file

@ -69,6 +69,7 @@ fn block_placement_system(
block_event_queue.push(BlockUpdateEvent {
position: place_position,
value: place_block,
soft: place_block != Block::Air,
});
//send event
entities.add_entity(

View file

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

View file

@ -203,6 +203,7 @@ fn process_completed_tasks(
queue.push(BlockUpdateEvent {
position: event.position,
value: event.block_type,
soft: true,
});
}

View file

@ -7,7 +7,9 @@ use super::ChunkStorage;
#[derive(Clone, Copy, Debug)]
pub struct BlockUpdateEvent {
pub position: IVec3,
pub value: Block
pub value: Block,
//Only replace air blocks
pub soft: bool,
}
#[derive(Unique, Default, Clone)]