Added Cherry Tree ForestKind

This commit is contained in:
BigKhan 2024-01-28 16:16:01 +00:00
parent be056ef595
commit f600d48e15
5 changed files with 44 additions and 2 deletions

View File

@ -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

View File

@ -49,6 +49,7 @@ make_case_elim!(
KeyholeBars(consumes: String) = 29,
HaniwaKeyhole(consumes: String) = 30,
MapleLeaves = 31,
CherryLeaves = 32,
}
);

View File

@ -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,
}
}

View File

@ -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()

View File

@ -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::<f32>().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