Scatter testing (not complete)

This commit is contained in:
Joshua Yanovski 2022-07-17 20:11:36 -07:00
parent 35deaae540
commit 09a5e49c25
6 changed files with 238 additions and 88 deletions

View File

@ -7,7 +7,7 @@
rocks: true, rocks: true,
shrubs: true, shrubs: true,
trees: true, trees: true,
scatter: false, scatter: true,
paths: true, paths: true,
spots: true, spots: true,
snow: true, snow: true,

View File

@ -78,7 +78,7 @@ pub struct ColumnGen<'a> {
pub sim_chunk: &'a SimChunk, pub sim_chunk: &'a SimChunk,
pub(crate) catmull_rom_gen: SplineGen2D<&'a SimChunk>, pub(crate) catmull_rom_gen: SplineGen2D<&'a SimChunk>,
pub(crate) neighbor_river_data: Vec<(Vec2<i32>, &'a SimChunk, &'a RiverData)>, pub(crate) neighbor_river_data: Vec<(Vec2<i32>, &'a SimChunk, &'a RiverData)>,
pub(crate) homogeneous_water_level: Option<f32>, pub(crate) homogeneous_water_level: Option<Option<f32>>,
// pub(crate) spawn_rules: SpawnRules, // pub(crate) spawn_rules: SpawnRules,
} }
@ -545,13 +545,15 @@ impl<'a> ColumnGen<'a> {
let river_kind = sim_chunk.river.river_kind; let river_kind = sim_chunk.river.river_kind;
let homogeneous_water_level = neighbor_river_data let homogeneous_water_level = neighbor_river_data
.iter() .iter()
.filter(|(pos, _, _)| (pos - chunk_pos).map(i32::abs).reduce_max() <= 1)
.all(|(pos, chunk, river)| river.river_kind == river_kind || .all(|(pos, chunk, river)| river.river_kind == river_kind ||
chunk.water_alt == sim_chunk.water_alt); chunk.water_alt == sim_chunk.water_alt);
let base_sea_level = CONFIG.sea_level - 1.0 + 0.01; let base_sea_level = CONFIG.sea_level - 1.0 + 0.01;
let homogeneous_water_level = if homogeneous_water_level { let homogeneous_water_level = if homogeneous_water_level {
match river_kind { match river_kind {
None | Some(RiverKind::Ocean) => Some(base_sea_level), None => Some(None),
Some(RiverKind::Lake { .. }) => Some(sim_chunk.water_alt), Some(RiverKind::Ocean) => Some(Some(base_sea_level)),
Some(RiverKind::Lake { .. }) => Some(Some(sim_chunk.water_alt)),
_ => None, _ => None,
} }
} else { } else {
@ -751,10 +753,10 @@ impl<'a, 'b> Sampler<'a, 'b> for ColumnGen1D<'a, 'b> {
let base_sea_level = CONFIG.sea_level - 1.0 + 0.01; let base_sea_level = CONFIG.sea_level - 1.0 + 0.01;
let riverless_alt = alt; let riverless_alt = alt;
let (alt, water_level, water_dist) = if let Some(water_level) = homogeneous_water_level { let (alt, water_level, water_dist, water_dist_) = if let Some(water_level) = homogeneous_water_level {
(alt, water_level, None::<f32>) (alt, water_level.unwrap_or(base_sea_level), water_level.and(Some(0.0)), None::<f32>)
} else { } else {
(alt, base_sea_level, None::<f32>) (alt, base_sea_level, None::<f32>, None::<f32>)
/* let lake_width = (TerrainChunkSize::RECT_SIZE.x as f64 * 2.0f64.sqrt()) + 6.0; /* let lake_width = (TerrainChunkSize::RECT_SIZE.x as f64 * 2.0f64.sqrt()) + 6.0;
let neighbor_river_data = neighbor_river_data let neighbor_river_data = neighbor_river_data
.iter() .iter()
@ -1462,7 +1464,7 @@ impl<'a, 'b> Sampler<'a, 'b> for ColumnGen1D<'a, 'b> {
let cliff_offset = cliff * cliff_height; let cliff_offset = cliff * cliff_height;
let riverless_alt_delta = riverless_alt_delta + (cliff - 0.5) * cliff_height; let riverless_alt_delta = riverless_alt_delta + (cliff - 0.5) * cliff_height;
let warp_factor = water_dist.map_or(1.0, |d| ((d - 0.0) / 64.0).clamped(0.0, 1.0)); let warp_factor = water_dist_.map_or(1.0, |d| ((d - 0.0) / 64.0).clamped(0.0, 1.0));
// NOTE: To disable warp, uncomment this line. // NOTE: To disable warp, uncomment this line.
// let warp_factor = 0.0; // let warp_factor = 0.0;

View File

@ -1,6 +1,7 @@
use crate::{ use crate::{
layer::wildlife::{self, DensityFn, SpawnEntry}, layer::wildlife::{self, DensityFn, SpawnEntry},
site::{economy::TradeInformation, Site}, site::{economy::TradeInformation, Site},
util::FastNoise2d,
Colors, Features, Colors, Features,
}; };
use common::{ use common::{
@ -135,14 +136,14 @@ impl IndexOwned {
pub struct Noise { pub struct Noise {
pub cave_nz: SuperSimplex, pub cave_nz: SuperSimplex,
pub scatter_nz: SuperSimplex, pub scatter_nz: /*SuperSimplex*/FastNoise2d,
} }
impl Noise { impl Noise {
fn new(seed: u32) -> Self { fn new(seed: u32) -> Self {
Self { Self {
cave_nz: SuperSimplex::new().set_seed(seed + 0), cave_nz: SuperSimplex::new().set_seed(seed + 0),
scatter_nz: SuperSimplex::new().set_seed(seed + 1), scatter_nz: /*SuperSimplex::new().set_seed(seed + 1)*/FastNoise2d::new(seed + 1),
} }
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -289,7 +289,7 @@ pub fn apply_trees_to(
/* criterion::black_box(tree); */ /* criterion::black_box(tree); */
/*for tree in trees {*/ /*for tree in trees {*/
/* /*
arena: &'b bumpalo::Bump, arena: &'b bumpalo::Bump,
canvas_info: CanvasInfo<'c>, canvas_info: CanvasInfo<'c>,
render_area: Aabr<i32>, render_area: Aabr<i32>,

View File

@ -49,8 +49,12 @@ pub struct RandomPerm {
impl RandomPerm { impl RandomPerm {
pub const fn new(seed: u32) -> Self { Self { seed } } pub const fn new(seed: u32) -> Self { Self { seed } }
pub fn get_f32(&self, perm: u32) -> f32 {
(self.get(perm) % (1 << 16)) as f32 / ((1 << 16) as f32)
}
pub fn chance(&self, perm: u32, chance: f32) -> bool { pub fn chance(&self, perm: u32, chance: f32) -> bool {
(self.get(perm) % (1 << 16)) as f32 / ((1 << 16) as f32) < chance self.get_f32(perm) < chance
} }
} }