From 962f0ec812501c4ad7a04dca660d0d4df19fbd45 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 9 Nov 2020 17:09:33 +0000 Subject: [PATCH] Better snow effects for non-trees --- world/src/layer/tree.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 0a2505db18..2cba78e938 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -97,6 +97,7 @@ pub fn apply_trees_to(canvas: &mut Canvas) { let bounds = tree.model.get_bounds(); let mut is_top = true; + let mut is_leaf_top = true; for z in (bounds.min.z..bounds.max.z).rev() { let wpos = Vec3::new(wpos2d.x, wpos2d.y, tree.pos.z + z); let model_pos = Vec3::from( @@ -123,17 +124,22 @@ pub fn apply_trees_to(canvas: &mut Canvas) { Block::air, ) .map(|block| { - if is_top && col.snow_cover && block.kind() == BlockKind::Leaves { + // Add a snow covering to the block above under certain circumstances + if col.snow_cover + && ((block.kind() == BlockKind::Leaves && is_leaf_top) + || (is_top && block.is_filled())) + { canvas.set( wpos + Vec3::unit_z(), Block::new(BlockKind::Snow, Rgb::new(210, 210, 255)), ); } canvas.set(wpos, block); + is_leaf_top = false; is_top = false; }) .unwrap_or_else(|| { - is_top = true; + is_leaf_top = true; }); } }