Added dead trees

This commit is contained in:
Joshua Barretto 2022-03-02 17:29:42 +00:00 committed by IsseW
parent 0b5d043d8e
commit 1392a8662f
2 changed files with 38 additions and 0 deletions

View File

@ -17,6 +17,7 @@ pub enum ForestKind {
Giant,
Swamp,
Frostpine,
Dead,
}
pub struct Environment {
@ -39,6 +40,7 @@ impl ForestKind {
ForestKind::Birch => 0.0..0.6,
ForestKind::Mangrove => 0.5..1.3,
ForestKind::Swamp => 0.5..1.1,
ForestKind::Dead => 0.0..1.5,
_ => 0.0..0.0,
}
}
@ -56,6 +58,7 @@ impl ForestKind {
ForestKind::Birch => -0.7..0.25,
ForestKind::Mangrove => 0.35..1.6,
ForestKind::Swamp => -0.6..0.8,
ForestKind::Dead => -1.5..1.0,
_ => 0.0..0.0,
}
}
@ -82,6 +85,7 @@ impl ForestKind {
ForestKind::Birch => 0.65,
ForestKind::Mangrove => 2.0,
ForestKind::Swamp => 1.0,
ForestKind::Dead => 0.01,
_ => 0.0,
}
}

View File

@ -141,6 +141,15 @@ pub fn apply_trees_to(
StructureBlock::TemperateLeaves,
);
},
ForestKind::Dead => {
break 'model TreeModel::Procedural(
ProceduralTree::generate(
TreeConfig::dead(&mut RandomPerm::new(seed), scale),
&mut RandomPerm::new(seed),
),
StructureBlock::TemperateLeaves,
);
},
ForestKind::Chestnut => {
break 'model TreeModel::Procedural(
ProceduralTree::generate(
@ -395,6 +404,31 @@ impl TreeConfig {
}
}
pub fn dead(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: 9.0 * scale,
trunk_radius: 2.0 * scale,
branch_child_len: 0.9,
branch_child_radius: 0.7,
branch_child_radius_lerp: true,
leaf_radius: 0.0..0.1,
leaf_radius_scaled: 0.0,
straightness: 0.35,
max_depth: 3,
splits: 2.25..3.25,
split_range: 0.75..1.5,
branch_len_bias: 0.0,
leaf_vertical_scale: 1.0,
proportionality: 0.0,
inhabited: false,
hanging_sprites: &[(0.0002, SpriteKind::Apple), (0.00007, SpriteKind::Beehive)],
trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(55, 34, 32)),
}
}
pub fn apple(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);