mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Shrubs back!
This commit is contained in:
parent
8db5acd987
commit
ebe76abc54
@ -5,7 +5,7 @@
|
||||
caverns: false, // TODO: Disabled by default until cave overhaul
|
||||
caves: true,
|
||||
rocks: true,
|
||||
shrubs: false,
|
||||
shrubs: true,
|
||||
trees: true,
|
||||
scatter: false,
|
||||
paths: true,
|
||||
|
@ -234,7 +234,7 @@ impl<'a> Canvas<'a> {
|
||||
let rpos2d = wpos2d - origin.xy();
|
||||
let rpos2d = units.x * rpos2d.x + units.y * rpos2d.y;
|
||||
|
||||
let mut above = true;
|
||||
// let mut above = true;
|
||||
for z in (structure.get_bounds().min.z..structure.get_bounds().max.z).rev() {
|
||||
if let Ok(sblock) = structure.get(rpos2d.with_z(z)) {
|
||||
/* let mut add_snow = false; */
|
||||
@ -249,12 +249,12 @@ impl<'a> Canvas<'a> {
|
||||
|sprite| block.with_sprite(sprite),
|
||||
info.calendar(),
|
||||
) {
|
||||
if !new_block.is_air() {
|
||||
/* if !new_block.is_air() {
|
||||
/* if with_snow && col.snow_cover && above {
|
||||
add_snow = true;
|
||||
} */
|
||||
above = false;
|
||||
}
|
||||
} */
|
||||
new_block
|
||||
} else {
|
||||
block
|
||||
|
@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
all::ForestKind,
|
||||
site2::{self, PrimitiveTransform},
|
||||
util::{gen_cache::StructureGenCache, seed_expan, Sampler, StructureGen2d, UnitChooser},
|
||||
Canvas,
|
||||
};
|
||||
@ -25,14 +26,57 @@ struct Shrub {
|
||||
wpos: Vec3<i32>,
|
||||
seed: u32,
|
||||
kind: ForestKind,
|
||||
rng: ChaChaRng,
|
||||
}
|
||||
|
||||
pub fn apply_shrubs_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
|
||||
let mut shrub_gen = StructureGenCache::new(StructureGen2d::new(canvas.index().seed, 8, 4));
|
||||
// let mut shrub_gen = StructureGenCache::new(StructureGen2d::new(canvas.index().seed, 8, 4));
|
||||
|
||||
let info = canvas.info();
|
||||
|
||||
canvas.foreach_col(|_, wpos2d, _| {
|
||||
let area_size = Vec2::from(info.area().size().map(|e| e as i32));
|
||||
let render_area = Aabr {
|
||||
min: info.wpos(),
|
||||
max: info.wpos() + area_size,
|
||||
};
|
||||
|
||||
let mut arena = bumpalo::Bump::new();
|
||||
|
||||
info.chunks()
|
||||
.gen_ctx
|
||||
.shrub_gen
|
||||
.iter(render_area.min, render_area.max)
|
||||
.filter_map(|(wpos, seed)| {
|
||||
let lottery = info.chunks().make_forest_lottery(wpos);
|
||||
let kind = *lottery.choose_seeded(seed).as_ref()?;
|
||||
|
||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||
if rng.gen_bool(kind.shrub_density_factor() as f64) {
|
||||
info.col_or_gen(wpos)
|
||||
.and_then(move |col| {
|
||||
const BASE_SHRUB_DENSITY: f64 = 0.15;
|
||||
if rng.gen_bool((BASE_SHRUB_DENSITY * col.tree_density as f64).clamped(0.0, 1.0))
|
||||
&& col.water_dist.map_or(true, |d| d > 8.0)
|
||||
&& col.alt > col.water_level
|
||||
&& col.spawn_rate > 0.9
|
||||
&& col.path.map_or(true, |(d, _, _, _)| d > 6.0)
|
||||
{
|
||||
Some(Shrub {
|
||||
wpos: wpos.with_z(col.alt as i32),
|
||||
seed,
|
||||
kind,
|
||||
rng,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.for_each(|mut shrub| {
|
||||
/* canvas.foreach_col(|_, wpos2d, _| {
|
||||
shrub_gen.get(wpos2d, |wpos, seed| {
|
||||
let col = info.col_or_gen(wpos)?;
|
||||
|
||||
@ -66,20 +110,37 @@ pub fn apply_shrubs_to(canvas: &mut Canvas, _dynamic_rng: &mut impl Rng) {
|
||||
});
|
||||
|
||||
for shrub in shrub_gen.generated() {
|
||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(shrub.seed));
|
||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(shrub.seed)); */
|
||||
|
||||
let units = UnitChooser::new(shrub.seed).get(shrub.seed).into();
|
||||
// let units = UnitChooser::new(shrub.seed).get(shrub.seed).into();
|
||||
|
||||
let shrubs = match shrub.kind {
|
||||
ForestKind::Mangrove => &*JUNGLE_SHRUBS,
|
||||
ForestKind::Acacia | ForestKind::Baobab => &*SAVANNAH_SHRUBS,
|
||||
ForestKind::Oak | ForestKind::Chestnut => &*TEMPERATE_SHRUBS,
|
||||
ForestKind::Pine => &*TAIGA_SHRUBS,
|
||||
_ => continue, // TODO: Add more shrub varieties
|
||||
_ => return, // TODO: Add more shrub varieties
|
||||
}
|
||||
.read();
|
||||
./*read*/get();
|
||||
|
||||
let structure = shrubs.choose(&mut rng).unwrap();
|
||||
canvas.blit_structure(shrub.wpos, structure, shrub.seed, units, true);
|
||||
}
|
||||
let structure = shrubs.choose(&mut shrub.rng).unwrap();
|
||||
|
||||
site2::render_collect(
|
||||
&arena,
|
||||
info,
|
||||
render_area,
|
||||
canvas,
|
||||
|painter, filler| {
|
||||
painter
|
||||
.prefab(structure)
|
||||
.translate(/*totem_pos*/shrub.wpos)
|
||||
.fill(filler.prefab(structure, shrub.wpos, shrub.seed), filler);
|
||||
},
|
||||
);
|
||||
|
||||
arena.reset();
|
||||
|
||||
// canvas.blit_structure(shrub.wpos, structure, shrub.seed, units, true);
|
||||
/* } */
|
||||
});
|
||||
}
|
||||
|
@ -127,7 +127,8 @@ pub(crate) struct GenCtx {
|
||||
|
||||
// pub _fast_turb_x_nz: FastNoise,
|
||||
pub rock_gen: StructureGen2d,
|
||||
pub _fast_turb_y_nz: FastNoise,
|
||||
// pub _fast_turb_y_nz: FastNoise,
|
||||
pub shrub_gen: StructureGen2d,
|
||||
|
||||
pub _town_gen: StructureGen2d,
|
||||
pub river_seed: RandomField,
|
||||
@ -581,7 +582,8 @@ impl WorldSim {
|
||||
// _fast_turb_x_nz: FastNoise::new(rng.gen()),
|
||||
rock_gen: StructureGen2d::new(rng.gen(), 24, 10),
|
||||
fast_hill_nz: Value::new().set_seed(hill_nz_seed),
|
||||
_fast_turb_y_nz: FastNoise::new(rng.gen()),
|
||||
/* _fast_turb_y_nz: FastNoise::new(rng.gen()), */
|
||||
shrub_gen: StructureGen2d::new(rng.gen(), 8, 4),
|
||||
|
||||
_town_gen: StructureGen2d::new(rng.gen(), 2048, 1024),
|
||||
river_seed: RandomField::new(rng.gen()),
|
||||
|
Loading…
Reference in New Issue
Block a user