From f600d48e159f275ec7d567d27f26796e9b253c37 Mon Sep 17 00:00:00 2001 From: BigKhan Date: Sun, 28 Jan 2024 16:16:01 +0000 Subject: [PATCH 1/4] Added Cherry Tree ForestKind --- assets/world/style/colors.ron | 1 + common/src/terrain/structure.rs | 1 + world/src/all.rs | 7 ++++++- world/src/block/mod.rs | 3 ++- world/src/layer/tree.rs | 34 +++++++++++++++++++++++++++++++++ 5 files changed, 44 insertions(+), 2 deletions(-) diff --git a/assets/world/style/colors.ron b/assets/world/style/colors.ron index cbcfa31e5d..85fb595d80 100644 --- a/assets/world/style/colors.ron +++ b/assets/world/style/colors.ron @@ -34,6 +34,7 @@ Chestnut: [(start: (30, 80, 0), end: (50, 120, 0))], Baobab: [(start: (50, 100, 40), end: (50, 90, 0))], MapleLeaves: [(start: (103, 32, 21), end: (131, 24, 26)), (start: (96, 30, 44), end: (92, 9, 46))], + CherryLeaves: [(start: (210, 109, 116), end: (217, 102, 102))], ) // Water blocks ignore color now so this isn't used, but just in case this color was worth diff --git a/common/src/terrain/structure.rs b/common/src/terrain/structure.rs index e8c41bb1b9..619fe4c33f 100644 --- a/common/src/terrain/structure.rs +++ b/common/src/terrain/structure.rs @@ -49,6 +49,7 @@ make_case_elim!( KeyholeBars(consumes: String) = 29, HaniwaKeyhole(consumes: String) = 30, MapleLeaves = 31, + CherryLeaves = 32, } ); diff --git a/world/src/all.rs b/world/src/all.rs index 14cedea1e4..9a59503deb 100644 --- a/world/src/all.rs +++ b/world/src/all.rs @@ -20,6 +20,7 @@ pub enum ForestKind { Frostpine, Dead, Mapletree, + Cherry, } pub struct Environment { @@ -44,7 +45,8 @@ impl ForestKind { ForestKind::Mangrove => 0.5..1.3, ForestKind::Swamp => 0.5..1.1, ForestKind::Dead => 0.0..1.5, - ForestKind::Mapletree => 0.55..1.25, + ForestKind::Mapletree => 0.65..1.25, + ForestKind::Cherry => 0.45..0.75, _ => 0.0..0.0, } } @@ -65,6 +67,7 @@ impl ForestKind { ForestKind::Swamp => -0.6..0.8, ForestKind::Dead => -1.5..1.0, ForestKind::Mapletree => -0.15..0.25, + ForestKind::Cherry => -0.10..0.15, _ => 0.0..0.0, } } @@ -94,6 +97,7 @@ impl ForestKind { ForestKind::Swamp => 1.0, ForestKind::Dead => 0.01, ForestKind::Mapletree => 0.65, + ForestKind::Cherry => 12.0, _ => 0.0, } } @@ -112,6 +116,7 @@ impl ForestKind { ForestKind::Mangrove => 1.0, ForestKind::Swamp => 0.4, ForestKind::Mapletree => 0.4, + ForestKind::Cherry => 0.3, _ => 1.0, } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 8c9d954590..5aae6790cd 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -281,7 +281,8 @@ pub fn block_from_structure( | StructureBlock::Mangrove | StructureBlock::Chestnut | StructureBlock::Baobab - | StructureBlock::MapleLeaves => { + | StructureBlock::MapleLeaves + | StructureBlock::CherryLeaves => { let ranges = sblock .elim_case_pure(&index.colors.block.structure_blocks) .as_ref() diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index af1986a2a1..7a5cc755bb 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -233,6 +233,15 @@ pub fn apply_trees_to( StructureBlock::MapleLeaves, ); }, + ForestKind::Cherry => { + break 'model TreeModel::Procedural( + ProceduralTree::generate( + TreeConfig::cherry(&mut RandomPerm::new(seed), scale), + &mut RandomPerm::new(seed), + ), + StructureBlock::CherryLeaves, + ); + }, }; let models = models.read(); @@ -732,6 +741,31 @@ impl TreeConfig { trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(110, 68, 22)), } } + + pub fn cherry(rng: &mut impl Rng, scale: f32) -> Self { + let scale = scale * (0.8 + rng.gen::().powi(2) * 0.5); + let log_scale = 1.0 + scale.log2().max(0.0); + + Self { + trunk_len: 7.0 * scale, + trunk_radius: 1.27 * scale, + branch_child_len: 0.9, + branch_child_radius: 0.65, + branch_child_radius_lerp: true, + leaf_radius: 2.5 * log_scale..3.0 * log_scale, + leaf_radius_scaled: 0.0, + straightness: 0.55, + max_depth: 4, + splits: 2.0..3.0, + split_range: 0.75..1.3, + branch_len_bias: 0.0, + leaf_vertical_scale: 1.0, + proportionality: 0.0, + inhabited: false, + hanging_sprites: &[], + trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(90, 45, 15)), + } + } } // TODO: Rename this to `Tree` when the name conflict is gone From a07a4ca926b98d48d58c99cb6dc5bafc2a420a62 Mon Sep 17 00:00:00 2001 From: BigKhan Date: Sun, 28 Jan 2024 16:41:27 +0000 Subject: [PATCH 2/4] fixed flying branches --- world/src/layer/tree.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 7a5cc755bb..9e01d0dc0d 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -750,7 +750,7 @@ impl TreeConfig { trunk_len: 7.0 * scale, trunk_radius: 1.27 * scale, branch_child_len: 0.9, - branch_child_radius: 0.65, + branch_child_radius: 0.70, branch_child_radius_lerp: true, leaf_radius: 2.5 * log_scale..3.0 * log_scale, leaf_radius_scaled: 0.0, From ee10e0373606ec5567b4efe441dabeeb66e9c784 Mon Sep 17 00:00:00 2001 From: BigKhan Date: Sun, 28 Jan 2024 17:16:47 +0000 Subject: [PATCH 3/4] wood darker --- assets/world/style/colors.ron | 2 +- world/src/layer/tree.rs | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/assets/world/style/colors.ron b/assets/world/style/colors.ron index 85fb595d80..e974827c67 100644 --- a/assets/world/style/colors.ron +++ b/assets/world/style/colors.ron @@ -34,7 +34,7 @@ Chestnut: [(start: (30, 80, 0), end: (50, 120, 0))], Baobab: [(start: (50, 100, 40), end: (50, 90, 0))], MapleLeaves: [(start: (103, 32, 21), end: (131, 24, 26)), (start: (96, 30, 44), end: (92, 9, 46))], - CherryLeaves: [(start: (210, 109, 116), end: (217, 102, 102))], + CherryLeaves: [(start: (210, 109, 116), end: (217, 102, 102)), (start: (191, 128, 151), end: (206, 113, 123))] ) // Water blocks ignore color now so this isn't used, but just in case this color was worth diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 9e01d0dc0d..514122656a 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -763,10 +763,9 @@ impl TreeConfig { proportionality: 0.0, inhabited: false, hanging_sprites: &[], - trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(90, 45, 15)), + trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(69, 37, 17)), } } -} // TODO: Rename this to `Tree` when the name conflict is gone pub struct ProceduralTree { From 87c00b5645a2d6ee8a55ed92bd1e77e4ccf217b0 Mon Sep 17 00:00:00 2001 From: BigKhan Date: Wed, 31 Jan 2024 10:53:02 +0000 Subject: [PATCH 4/4] did the fmt thing --- world/src/layer/tree.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index 514122656a..ba012f6094 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -766,6 +766,7 @@ impl TreeConfig { trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(69, 37, 17)), } } +} // TODO: Rename this to `Tree` when the name conflict is gone pub struct ProceduralTree {