Improved giant trees

This commit is contained in:
Joshua Barretto 2021-08-30 00:03:16 +01:00
parent 92c463b315
commit 9ac5e555e6
9 changed files with 26 additions and 23 deletions

View File

@ -3,7 +3,7 @@ EntityConfig (
body: RandomWith("dwarf"),
alignment: Alignment(Enemy),
loot: LootTable("common.loot_tables.creature.biped_large.saurok"),
loot: LootTable("common.loot_tables.humanoids"),
hands: TwoHanded(Item("common.items.weapons.hammer.steel_hammer-3")),

View File

@ -3,7 +3,7 @@ EntityConfig (
body: RandomWith("humanoid"),
alignment: Alignment(Enemy),
loot: LootTable("common.loot_tables.creature.biped_large.saurok"),
loot: LootTable("common.loot_tables.humanoids"),
hands: TwoHanded(Item("common.items.weapons.hammer.steel_hammer-0")),

View File

@ -1,9 +1,9 @@
EntityConfig (
name: Name("Witch"),
body: Exact(Humanoid(Body(
species: Human,
body_type: Female,
hair_style: 2,
species: Human,
body_type: Female,
hair_style: 2,
beard: 0,
eyes: 0,
accessory: 0,
@ -13,7 +13,7 @@ EntityConfig (
))),
alignment: Alignment(Enemy),
loot: LootTable("common.loot_tables.creature.biped_large.saurok"),
loot: LootTable("common.loot_tables.humanoids"),
hands: TwoHanded(Item("common.items.weapons.sceptre.belzeshrub")),

View File

@ -11,12 +11,14 @@ use core::ops::{Div, Mul, Range};
use serde::Deserialize;
use vek::*;
type Gradients = Vec<Range<(u8, u8, u8)>>;
#[derive(Deserialize)]
pub struct Colors {
// TODO(@Sharp): After the merge, construct enough infrastructure to make it convenient to
// define mapping functions over the input; i.e. we should be able to interpret some fields as
// defining App<Abs<Fun, Type>, Arg>, where Fun : (Context, Arg) → (S, Type).
pub structure_blocks: structure::structure_block::PureCases<Option<Vec<Range<(u8, u8, u8)>>>>,
pub structure_blocks: structure::structure_block::PureCases<Option<Gradients>>,
}
pub struct BlockGen<'a> {
@ -297,7 +299,7 @@ pub fn block_from_structure(
.as_ref()
.map(Vec::as_slice)
.unwrap_or(&[]);
let range = if ranges.len() == 0 {
let range = if ranges.is_empty() {
None
} else {
ranges.get(RandomPerm::new(structure_seed).get(13) as usize % ranges.len())

View File

@ -405,7 +405,7 @@ pub fn apply_spots_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
.map(|c| c.alt as i32)
.unwrap_or(0),
);
canvas.blit_structure(origin, &structure, seed, units, true);
canvas.blit_structure(origin, structure, seed, units, true);
}
// Spawn entities

View File

@ -430,7 +430,7 @@ impl TreeConfig {
splits: 1.75..2.0,
split_range: 0.75..1.5,
branch_len_bias: 0.0,
leaf_vertical_scale: 0.2,
leaf_vertical_scale: 0.4,
proportionality: 0.0,
inhabited: false,
hanging_sprites: &[(0.0005, SpriteKind::Beehive)],
@ -478,7 +478,7 @@ impl TreeConfig {
splits: 3.0..3.5,
split_range: 0.5..1.25,
branch_len_bias: 0.0,
leaf_vertical_scale: 0.35,
leaf_vertical_scale: 0.5,
proportionality: 0.5,
inhabited: false,
hanging_sprites: &[(0.0005, SpriteKind::Beehive)],
@ -577,7 +577,7 @@ impl ProceduralTree {
for _ in 0..4 {
let dir =
Vec3::new(rng.gen_range(-1.0..1.0), rng.gen_range(-1.0..1.0), -1.0).normalized();
let len = 8.0;
let len = config.trunk_len * 0.75;
let radius = config.trunk_radius;
let mut aabb = Aabb {
min: trunk_origin,

View File

@ -61,13 +61,11 @@ impl Tree {
let (branch, leaves, _, _) = self.tree.is_branch_or_leaves_at(rposf);
if branch || leaves {
if above && col.snow_cover {
canvas.set(
wpos + Vec3::unit_z(),
Block::new(BlockKind::Snow, Rgb::new(255, 255, 255)),
);
}
if (branch || leaves) && above && col.snow_cover {
canvas.set(
wpos + Vec3::unit_z(),
Block::new(BlockKind::Snow, Rgb::new(255, 255, 255)),
);
}
let block = if leaves {

View File

@ -31,7 +31,7 @@ pub enum Primitive {
/// A sampling function is always a subset of another primitive to avoid
/// needing infinite bounds
Sampling(Id<Primitive>, Box<dyn Fn(Vec3<i32>) -> bool>),
Prefab(PrefabStructure),
Prefab(Box<PrefabStructure>),
// Combinators
And(Id<Primitive>, Id<Primitive>),
@ -52,7 +52,7 @@ pub enum Fill {
// TODO: the offset field for Prefab is a hack that breaks the compositionality of Translate,
// we probably need an evaluator for the primitive tree that gets which point is queried at
// leaf nodes given an input point to make Translate/Rotate work generally
Prefab(PrefabStructure, Vec3<i32>, u32),
Prefab(Box<PrefabStructure>, Vec3<i32>, u32),
Sampling(Arc<dyn Fn(Vec3<i32>) -> Option<Block>>),
}

View File

@ -1383,9 +1383,12 @@ impl SiteStructure for Dungeon {
let entrances = entrances.read();
let entrance = entrances[self.seed as usize % entrances.len()].clone();
let entrance_prim = prim(Primitive::Prefab(entrance.clone()));
let entrance_prim = prim(Primitive::Prefab(Box::new(entrance.clone())));
let entrance_prim = prim(Primitive::Translate(entrance_prim, origin));
fill(entrance_prim, Fill::Prefab(entrance, origin, self.seed));
fill(
entrance_prim,
Fill::Prefab(Box::new(entrance), origin, self.seed),
);
let mut z = self.alt + ALT_OFFSET;
for floor in &self.floors {