mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
sync
This commit is contained in:
parent
fdf3ab6a78
commit
1edee02788
@ -46,7 +46,6 @@ pub struct Structure {
|
|||||||
|
|
||||||
struct BaseStructure {
|
struct BaseStructure {
|
||||||
vol: Dyna<StructureBlock, ()>,
|
vol: Dyna<StructureBlock, ()>,
|
||||||
empty: StructureBlock,
|
|
||||||
default_kind: BlockKind,
|
default_kind: BlockKind,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,13 +166,11 @@ impl assets::Compound for BaseStructure {
|
|||||||
|
|
||||||
Ok(BaseStructure {
|
Ok(BaseStructure {
|
||||||
vol,
|
vol,
|
||||||
empty: StructureBlock::None,
|
|
||||||
default_kind: BlockKind::Misc,
|
default_kind: BlockKind::Misc,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Ok(BaseStructure {
|
Ok(BaseStructure {
|
||||||
vol: Dyna::filled(Vec3::zero(), StructureBlock::None, ()),
|
vol: Dyna::filled(Vec3::zero(), StructureBlock::None, ()),
|
||||||
empty: StructureBlock::None,
|
|
||||||
default_kind: BlockKind::Misc,
|
default_kind: BlockKind::Misc,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ pub use self::{scatter::apply_scatter_to, tree::apply_trees_to};
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
column::ColumnSample,
|
column::ColumnSample,
|
||||||
util::{FastNoise, FastNoise2d, RandomField, Sampler},
|
util::{FastNoise, RandomField, Sampler},
|
||||||
Canvas, IndexRef,
|
Canvas, IndexRef,
|
||||||
};
|
};
|
||||||
use common::{
|
use common::{
|
||||||
|
@ -283,7 +283,7 @@ impl ProceduralTree {
|
|||||||
// Our trunk starts at the origin...
|
// Our trunk starts at the origin...
|
||||||
Vec3::zero(),
|
Vec3::zero(),
|
||||||
// ...and has a roughly upward direction
|
// ...and has a roughly upward direction
|
||||||
Vec3::new(rng.gen_range(-1.0, 1.0), rng.gen_range(-1.0, 1.0), 5.0).normalized(),
|
Vec3::new(rng.gen_range(-1.0..1.0), rng.gen_range(-1.0..1.0), 5.0).normalized(),
|
||||||
config.trunk_len,
|
config.trunk_len,
|
||||||
config.trunk_radius,
|
config.trunk_radius,
|
||||||
0,
|
0,
|
||||||
@ -313,7 +313,7 @@ impl ProceduralTree {
|
|||||||
let line = LineSegment3 { start, end };
|
let line = LineSegment3 { start, end };
|
||||||
let wood_radius = branch_radius;
|
let wood_radius = branch_radius;
|
||||||
let leaf_radius = if depth == config.max_depth {
|
let leaf_radius = if depth == config.max_depth {
|
||||||
rng.gen_range(config.leaf_radius.start, config.leaf_radius.end)
|
rng.gen_range(config.leaf_radius.clone())
|
||||||
} else {
|
} else {
|
||||||
0.0
|
0.0
|
||||||
};
|
};
|
||||||
@ -327,12 +327,12 @@ impl ProceduralTree {
|
|||||||
let mut child_idx = None;
|
let mut child_idx = None;
|
||||||
// Don't add child branches if we're already enough layers into the tree
|
// Don't add child branches if we're already enough layers into the tree
|
||||||
if depth < config.max_depth {
|
if depth < config.max_depth {
|
||||||
let x_axis = dir.cross(Vec3::<f32>::zero().map(|_| rng.gen_range(-1.0, 1.0))).normalized();
|
let x_axis = dir.cross(Vec3::<f32>::zero().map(|_| rng.gen_range(-1.0..1.0))).normalized();
|
||||||
let y_axis = dir.cross(x_axis).normalized();
|
let y_axis = dir.cross(x_axis).normalized();
|
||||||
let screw_shift = rng.gen_range(0.0, f32::consts::TAU);
|
let screw_shift = rng.gen_range(0.0..f32::consts::TAU);
|
||||||
|
|
||||||
for i in 0..config.splits {
|
for i in 0..config.splits {
|
||||||
let dist = Lerp::lerp(i as f32 / (config.splits - 1) as f32, rng.gen_range(0.0, 1.0), config.proportionality);
|
let dist = Lerp::lerp(i as f32 / (config.splits - 1) as f32, rng.gen_range(0.0..1.0), config.proportionality);
|
||||||
|
|
||||||
const PHI: f32 = 0.618;
|
const PHI: f32 = 0.618;
|
||||||
const RAD_PER_BRANCH: f32 = f32::consts::TAU * PHI;
|
const RAD_PER_BRANCH: f32 = f32::consts::TAU * PHI;
|
||||||
@ -347,7 +347,7 @@ impl ProceduralTree {
|
|||||||
start,
|
start,
|
||||||
end,
|
end,
|
||||||
split_factor,
|
split_factor,
|
||||||
) + Lerp::lerp(Vec3::<f32>::zero().map(|_| rng.gen_range(-1.0, 1.0)), screw, config.proportionality);
|
) + Lerp::lerp(Vec3::<f32>::zero().map(|_| rng.gen_range(-1.0..1.0)), screw, config.proportionality);
|
||||||
// Start the branch at the closest point to the target
|
// Start the branch at the closest point to the target
|
||||||
let branch_start = line.projected_point(tgt);
|
let branch_start = line.projected_point(tgt);
|
||||||
// Now, interpolate between the target direction and the parent branch's direction to find a direction
|
// Now, interpolate between the target direction and the parent branch's direction to find a direction
|
||||||
|
Loading…
Reference in New Issue
Block a user