mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Cargo fmt most things (except erosion.rs).
This commit is contained in:
parent
5fd8b009a6
commit
e91578ffdb
@ -113,11 +113,8 @@ impl Client {
|
|||||||
log::debug!("Preparing image...");
|
log::debug!("Preparing image...");
|
||||||
let world_map = Arc::new(image::DynamicImage::ImageRgba8({
|
let world_map = Arc::new(image::DynamicImage::ImageRgba8({
|
||||||
// Should not fail if the dimensions are correct.
|
// Should not fail if the dimensions are correct.
|
||||||
let world_map = image::ImageBuffer::from_raw(
|
let world_map =
|
||||||
map_size.x,
|
image::ImageBuffer::from_raw(map_size.x, map_size.y, world_map_raw);
|
||||||
map_size.y,
|
|
||||||
world_map_raw,
|
|
||||||
);
|
|
||||||
world_map.ok_or(Error::Other("Server sent a bad world map image".into()))?
|
world_map.ok_or(Error::Other("Server sent a bad world map image".into()))?
|
||||||
}));
|
}));
|
||||||
log::debug!("Done preparing image...");
|
log::debug!("Done preparing image...");
|
||||||
|
@ -37,7 +37,7 @@ pub enum ServerMsg {
|
|||||||
entity_package: sync::EntityPackage<EcsCompPacket>,
|
entity_package: sync::EntityPackage<EcsCompPacket>,
|
||||||
server_info: ServerInfo,
|
server_info: ServerInfo,
|
||||||
time_of_day: state::TimeOfDay,
|
time_of_day: state::TimeOfDay,
|
||||||
world_map: (Vec2<u32>, Vec<u32>)
|
world_map: (Vec2<u32>, Vec<u32>),
|
||||||
},
|
},
|
||||||
PlayerListUpdate(PlayerListUpdate),
|
PlayerListUpdate(PlayerListUpdate),
|
||||||
StateAnswer(Result<ClientState, (RequestStateError, ClientState)>),
|
StateAnswer(Result<ClientState, (RequestStateError, ClientState)>),
|
||||||
|
@ -46,7 +46,10 @@ use std::{
|
|||||||
};
|
};
|
||||||
use uvth::{ThreadPool, ThreadPoolBuilder};
|
use uvth::{ThreadPool, ThreadPoolBuilder};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
use world::{sim::{FileOpts, WORLD_SIZE, WorldOpts}, World};
|
use world::{
|
||||||
|
sim::{FileOpts, WorldOpts, WORLD_SIZE},
|
||||||
|
World,
|
||||||
|
};
|
||||||
const CLIENT_TIMEOUT: f64 = 20.0; // Seconds
|
const CLIENT_TIMEOUT: f64 = 20.0; // Seconds
|
||||||
|
|
||||||
pub enum Event {
|
pub enum Event {
|
||||||
@ -104,7 +107,9 @@ impl Server {
|
|||||||
state.ecs_mut().register::<RegionSubscription>();
|
state.ecs_mut().register::<RegionSubscription>();
|
||||||
state.ecs_mut().register::<Client>();
|
state.ecs_mut().register::<Client>();
|
||||||
|
|
||||||
let world = World::generate(settings.world_seed, WorldOpts {
|
let world = World::generate(
|
||||||
|
settings.world_seed,
|
||||||
|
WorldOpts {
|
||||||
seed_elements: true,
|
seed_elements: true,
|
||||||
world_file: if let Some(ref file) = settings.map_file {
|
world_file: if let Some(ref file) = settings.map_file {
|
||||||
FileOpts::Load(file.clone())
|
FileOpts::Load(file.clone())
|
||||||
@ -112,7 +117,8 @@ impl Server {
|
|||||||
FileOpts::Generate
|
FileOpts::Generate
|
||||||
},
|
},
|
||||||
..WorldOpts::default()
|
..WorldOpts::default()
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let spawn_point = {
|
let spawn_point = {
|
||||||
// NOTE: all of these `.map(|e| e as [type])` calls should compile into no-ops,
|
// NOTE: all of these `.map(|e| e as [type])` calls should compile into no-ops,
|
||||||
|
@ -104,8 +104,7 @@ impl ServerSettings {
|
|||||||
max_players: 100,
|
max_players: 100,
|
||||||
start_time: 9.0 * 3600.0,
|
start_time: 9.0 * 3600.0,
|
||||||
admins: vec!["singleplayer".to_string()], // TODO: Let the player choose if they want to use admin commands or not
|
admins: vec!["singleplayer".to_string()], // TODO: Let the player choose if they want to use admin commands or not
|
||||||
..
|
..Self::load() // Fill in remaining fields from settings.ron.
|
||||||
Self::load() // Fill in remaining fields from settings.ron.
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -454,7 +454,10 @@ impl Hud {
|
|||||||
// Generate ids.
|
// Generate ids.
|
||||||
let ids = Ids::new(ui.id_generator());
|
let ids = Ids::new(ui.id_generator());
|
||||||
// Load world map
|
// Load world map
|
||||||
let world_map = (ui.add_graphic(Graphic::Image(client.world_map.0.clone())), client.world_map.1);
|
let world_map = (
|
||||||
|
ui.add_graphic(Graphic::Image(client.world_map.0.clone())),
|
||||||
|
client.world_map.1,
|
||||||
|
);
|
||||||
// Load images.
|
// Load images.
|
||||||
let imgs = Imgs::load(&mut ui).expect("Failed to load images!");
|
let imgs = Imgs::load(&mut ui).expect("Failed to load images!");
|
||||||
// Load rotation images.
|
// Load rotation images.
|
||||||
|
@ -20,7 +20,7 @@ use client::Client;
|
|||||||
use common::{
|
use common::{
|
||||||
comp,
|
comp,
|
||||||
terrain::{BlockKind, TerrainChunk, TerrainChunkSize},
|
terrain::{BlockKind, TerrainChunk, TerrainChunkSize},
|
||||||
vol::{RectVolSize, ReadVol},
|
vol::{ReadVol, RectVolSize},
|
||||||
};
|
};
|
||||||
use specs::{Join, WorldExt};
|
use specs::{Join, WorldExt};
|
||||||
use vek::*;
|
use vek::*;
|
||||||
|
@ -175,7 +175,9 @@ fn mesh_worker<V: BaseVol<Vox = Block> + RectRasterableVol + ReadVol + Debug>(
|
|||||||
let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind();
|
let kind = volume.get(wpos).unwrap_or(&Block::empty()).kind();
|
||||||
|
|
||||||
if let Some(cfg) = sprite_config_for(kind) {
|
if let Some(cfg) = sprite_config_for(kind) {
|
||||||
let seed = wpos.x as u64 * 3 + wpos.y as u64 * 7 + wpos.x as u64 * wpos.y as u64; // Awful PRNG
|
let seed = wpos.x as u64 * 3
|
||||||
|
+ wpos.y as u64 * 7
|
||||||
|
+ wpos.x as u64 * wpos.y as u64; // Awful PRNG
|
||||||
|
|
||||||
let instance = SpriteInstance::new(
|
let instance = SpriteInstance::new(
|
||||||
Mat4::identity()
|
Mat4::identity()
|
||||||
|
@ -6,10 +6,13 @@ const W: usize = 640;
|
|||||||
const H: usize = 480;
|
const H: usize = 480;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let world = World::generate(0, WorldOpts {
|
let world = World::generate(
|
||||||
|
0,
|
||||||
|
WorldOpts {
|
||||||
seed_elements: true,
|
seed_elements: true,
|
||||||
..WorldOpts::default()
|
..WorldOpts::default()
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let sampler = world.sample_columns();
|
let sampler = world.sample_columns();
|
||||||
|
|
||||||
|
@ -36,12 +36,15 @@ fn main() {
|
|||||||
let mut _map_file = PathBuf::from("./maps");
|
let mut _map_file = PathBuf::from("./maps");
|
||||||
_map_file.push(map_file);
|
_map_file.push(map_file);
|
||||||
|
|
||||||
let world = World::generate(1337, WorldOpts {
|
let world = World::generate(
|
||||||
|
1337,
|
||||||
|
WorldOpts {
|
||||||
seed_elements: false,
|
seed_elements: false,
|
||||||
// world_file: sim::FileOpts::Load(_map_file),
|
// world_file: sim::FileOpts::Load(_map_file),
|
||||||
world_file: sim::FileOpts::Save,
|
world_file: sim::FileOpts::Save,
|
||||||
..WorldOpts::default()
|
..WorldOpts::default()
|
||||||
});
|
},
|
||||||
|
);
|
||||||
|
|
||||||
let sampler = world.sim();
|
let sampler = world.sim();
|
||||||
|
|
||||||
@ -87,12 +90,14 @@ fn main() {
|
|||||||
|
|
||||||
for i in 0..W {
|
for i in 0..W {
|
||||||
for j in 0..H {
|
for j in 0..H {
|
||||||
let pos = (focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
let pos =
|
||||||
|
(focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
||||||
/* let top_left = pos;
|
/* let top_left = pos;
|
||||||
let top_right = focus + Vec2::new(i as i32 + light_res, j as i32) * scale;
|
let top_right = focus + Vec2::new(i as i32 + light_res, j as i32) * scale;
|
||||||
let bottom_left = focus + Vec2::new(i as i32, j as i32 + light_res) * scale; */
|
let bottom_left = focus + Vec2::new(i as i32, j as i32 + light_res) * scale; */
|
||||||
|
|
||||||
let (alt, basement, water_alt, humidity, temperature, downhill, river_kind) = sampler
|
let (alt, basement, water_alt, humidity, temperature, downhill, river_kind) =
|
||||||
|
sampler
|
||||||
.get(pos)
|
.get(pos)
|
||||||
.map(|sample| {
|
.map(|sample| {
|
||||||
(
|
(
|
||||||
@ -105,7 +110,15 @@ fn main() {
|
|||||||
sample.river.river_kind,
|
sample.river.river_kind,
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.unwrap_or((CONFIG.sea_level, CONFIG.sea_level, CONFIG.sea_level, 0.0, 0.0, None, None));
|
.unwrap_or((
|
||||||
|
CONFIG.sea_level,
|
||||||
|
CONFIG.sea_level,
|
||||||
|
CONFIG.sea_level,
|
||||||
|
0.0,
|
||||||
|
0.0,
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
));
|
||||||
let humidity = humidity.min(1.0).max(0.0);
|
let humidity = humidity.min(1.0).max(0.0);
|
||||||
let temperature = temperature.min(1.0).max(-1.0) * 0.5 + 0.5;
|
let temperature = temperature.min(1.0).max(-1.0) * 0.5 + 0.5;
|
||||||
let pos = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
let pos = pos * TerrainChunkSize::RECT_SIZE.map(|e| e as i32);
|
||||||
@ -177,15 +190,9 @@ fn main() {
|
|||||||
|
|
||||||
let true_water_alt = (alt.max(water_alt) as f64 - focus.z) / gain as f64;
|
let true_water_alt = (alt.max(water_alt) as f64 - focus.z) / gain as f64;
|
||||||
let true_alt = (alt as f64 - focus.z) / gain as f64;
|
let true_alt = (alt as f64 - focus.z) / gain as f64;
|
||||||
let water_depth = (true_water_alt - true_alt)
|
let water_depth = (true_water_alt - true_alt).min(1.0).max(0.0);
|
||||||
.min(1.0)
|
let water_alt = true_water_alt.min(1.0).max(0.0);
|
||||||
.max(0.0);
|
let alt = true_alt.min(1.0).max(0.0);
|
||||||
let water_alt = true_water_alt
|
|
||||||
.min(1.0)
|
|
||||||
.max(0.0);
|
|
||||||
let alt = true_alt
|
|
||||||
.min(1.0)
|
|
||||||
.max(0.0);
|
|
||||||
let quad =
|
let quad =
|
||||||
|x: f32| ((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1);
|
|x: f32| ((x as f64 * QUADRANTS as f64).floor() as usize).min(QUADRANTS - 1);
|
||||||
if river_kind.is_none() || humidity != 0.0 {
|
if river_kind.is_none() || humidity != 0.0 {
|
||||||
@ -207,15 +214,27 @@ fn main() {
|
|||||||
buf[j * W + i] = match (river_kind, (is_water, true_alt >= true_sea_level)) {
|
buf[j * W + i] = match (river_kind, (is_water, true_alt >= true_sea_level)) {
|
||||||
(_, (false, _)) | (None, (_, true)) => {
|
(_, (false, _)) | (None, (_, true)) => {
|
||||||
let (r, g, b) = (
|
let (r, g, b) = (
|
||||||
(if is_shaded { alt } else { alt } * if is_temperature { temperature as f64 } else if is_shaded { alt } else { 0.0 }).sqrt(),
|
(if is_shaded { alt } else { alt }
|
||||||
if is_shaded { 0.2 + (alt * 0.8) } else { alt },
|
* if is_temperature {
|
||||||
(if is_shaded { alt } else { alt } * if is_humidity { humidity as f64 } else if is_shaded { alt } else { 0.0 }).sqrt(),
|
temperature as f64
|
||||||
);
|
} else if is_shaded {
|
||||||
let light = if is_shaded {
|
alt
|
||||||
light
|
|
||||||
} else {
|
} else {
|
||||||
1.0
|
0.0
|
||||||
};
|
})
|
||||||
|
.sqrt(),
|
||||||
|
if is_shaded { 0.2 + (alt * 0.8) } else { alt },
|
||||||
|
(if is_shaded { alt } else { alt }
|
||||||
|
* if is_humidity {
|
||||||
|
humidity as f64
|
||||||
|
} else if is_shaded {
|
||||||
|
alt
|
||||||
|
} else {
|
||||||
|
0.0
|
||||||
|
})
|
||||||
|
.sqrt(),
|
||||||
|
);
|
||||||
|
let light = if is_shaded { light } else { 1.0 };
|
||||||
u32::from_le_bytes([
|
u32::from_le_bytes([
|
||||||
(b * light * 255.0) as u8,
|
(b * light * 255.0) as u8,
|
||||||
(g * light * 255.0) as u8,
|
(g * light * 255.0) as u8,
|
||||||
@ -228,7 +247,7 @@ fn main() {
|
|||||||
(/*alt*//*alt * *//*(1.0 - humidity)*/(alt * temperature).sqrt() * 255.0) as u8,
|
(/*alt*//*alt * *//*(1.0 - humidity)*/(alt * temperature).sqrt() * 255.0) as u8,
|
||||||
255,
|
255,
|
||||||
]) */
|
]) */
|
||||||
},
|
}
|
||||||
(Some(RiverKind::Ocean), _) => u32::from_le_bytes([
|
(Some(RiverKind::Ocean), _) => u32::from_le_bytes([
|
||||||
((64.0 - water_depth * 64.0) * 1.0) as u8,
|
((64.0 - water_depth * 64.0) * 1.0) as u8,
|
||||||
((32.0 - water_depth * 32.0) * 1.0) as u8,
|
((32.0 - water_depth * 32.0) * 1.0) as u8,
|
||||||
@ -280,7 +299,8 @@ fn main() {
|
|||||||
}
|
}
|
||||||
if win.get_mouse_down(minifb::MouseButton::Left) {
|
if win.get_mouse_down(minifb::MouseButton::Left) {
|
||||||
if let Some((mx, my)) = win.get_mouse_pos(minifb::MouseMode::Clamp) {
|
if let Some((mx, my)) = win.get_mouse_pos(minifb::MouseMode::Clamp) {
|
||||||
let pos = (focus_rect + (Vec2::new(mx as f64, my as f64) * scale)).map(|e| e as i32);
|
let pos =
|
||||||
|
(focus_rect + (Vec2::new(mx as f64, my as f64) * scale)).map(|e| e as i32);
|
||||||
println!(
|
println!(
|
||||||
"Chunk position: {:?}",
|
"Chunk position: {:?}",
|
||||||
pos.map2(TerrainChunkSize::RECT_SIZE, |e, f| e * f as i32)
|
pos.map2(TerrainChunkSize::RECT_SIZE, |e, f| e * f as i32)
|
||||||
|
@ -265,7 +265,8 @@ impl<'a> BlockGen<'a> {
|
|||||||
sub_surface_color,
|
sub_surface_color,
|
||||||
stone_col.map(|e| e as f32 / 255.0),
|
stone_col.map(|e| e as f32 / 255.0),
|
||||||
(height - grass_depth - wposf.z as f32) * 0.15,
|
(height - grass_depth - wposf.z as f32) * 0.15,
|
||||||
).map(|e| (e * 255.0) as u8);
|
)
|
||||||
|
.map(|e| (e * 255.0) as u8);
|
||||||
|
|
||||||
// Underground
|
// Underground
|
||||||
if (wposf.z as f32) > alt - 32.0 * chaos {
|
if (wposf.z as f32) > alt - 32.0 * chaos {
|
||||||
|
@ -443,7 +443,8 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
|||||||
sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)?
|
sim.get_interpolated_monotone(wpos, |chunk| chunk.alt)?
|
||||||
// sim.get_interpolated(wpos, |chunk| chunk.alt)?
|
// sim.get_interpolated(wpos, |chunk| chunk.alt)?
|
||||||
};
|
};
|
||||||
let basement = alt + sim./*get_interpolated*/get_interpolated_monotone(wpos, |chunk| chunk.basement.sub(chunk.alt))?;
|
let basement = alt
|
||||||
|
+ sim./*get_interpolated*/get_interpolated_monotone(wpos, |chunk| chunk.basement.sub(chunk.alt))?;
|
||||||
|
|
||||||
// Find the average distance to each neighboring body of water.
|
// Find the average distance to each neighboring body of water.
|
||||||
let mut river_count = 0.0f64;
|
let mut river_count = 0.0f64;
|
||||||
@ -830,7 +831,6 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
|||||||
.mul(1.0 - humidity) */
|
.mul(1.0 - humidity) */
|
||||||
/* .mul(32.0) */;
|
/* .mul(32.0) */;
|
||||||
|
|
||||||
|
|
||||||
let riverless_alt_delta = Lerp::lerp(0.0, riverless_alt_delta, warp_factor);
|
let riverless_alt_delta = Lerp::lerp(0.0, riverless_alt_delta, warp_factor);
|
||||||
let alt = alt_ + riverless_alt_delta;
|
let alt = alt_ + riverless_alt_delta;
|
||||||
let basement = basement.min(alt);
|
let basement = basement.min(alt);
|
||||||
@ -953,11 +953,7 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
|||||||
.mul(1.0),
|
.mul(1.0),
|
||||||
);
|
);
|
||||||
|
|
||||||
let sub_surface_color = Lerp::lerp(
|
let sub_surface_color = Lerp::lerp(cliff, ground, alt.sub(basement).mul(0.25));
|
||||||
cliff,
|
|
||||||
ground,
|
|
||||||
alt.sub(basement).mul(0.25)
|
|
||||||
);
|
|
||||||
|
|
||||||
/* let ground = Rgb::lerp(
|
/* let ground = Rgb::lerp(
|
||||||
dead_tundra,
|
dead_tundra,
|
||||||
@ -1087,15 +1083,18 @@ impl<'a> Sampler<'a> for ColumnGen<'a> {
|
|||||||
); */
|
); */
|
||||||
|
|
||||||
// Snow covering
|
// Snow covering
|
||||||
let snow_cover =
|
let snow_cover = temp
|
||||||
temp.sub(CONFIG.snow_temp)
|
.sub(CONFIG.snow_temp)
|
||||||
.max(-humidity.sub(CONFIG.desert_hum))
|
.max(-humidity.sub(CONFIG.desert_hum))
|
||||||
.mul(16.0)
|
.mul(16.0)
|
||||||
.add((marble_small - 0.5) * 0.5);
|
.add((marble_small - 0.5) * 0.5);
|
||||||
let (alt, ground, sub_surface_color) = if snow_cover /*< 0.1*/<= 0.5 && alt > water_level {
|
let (alt, ground, sub_surface_color) = if snow_cover /*< 0.1*/<= 0.5 && alt > water_level {
|
||||||
// Allow snow cover.
|
// Allow snow cover.
|
||||||
(alt + 1.0 - snow_cover.max(0.0), Rgb::lerp(snow, ground, snow_cover),
|
(
|
||||||
Lerp::lerp(sub_surface_color, ground, alt.sub(basement).mul(0.15)))
|
alt + 1.0 - snow_cover.max(0.0),
|
||||||
|
Rgb::lerp(snow, ground, snow_cover),
|
||||||
|
Lerp::lerp(sub_surface_color, ground, alt.sub(basement).mul(0.15)),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
(alt, ground, sub_surface_color)
|
(alt, ground, sub_surface_color)
|
||||||
};
|
};
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use rayon::prelude::*;
|
|
||||||
use super::Alt;
|
use super::Alt;
|
||||||
|
use rayon::prelude::*;
|
||||||
|
|
||||||
/// From https://github.com/fastscape-lem/fastscapelib-fortran/blob/master/src/Diffusion.f90
|
/// From https://github.com/fastscape-lem/fastscapelib-fortran/blob/master/src/Diffusion.f90
|
||||||
///
|
///
|
||||||
@ -36,9 +36,17 @@ use super::Alt;
|
|||||||
|
|
||||||
implicit none
|
implicit none
|
||||||
*/
|
*/
|
||||||
pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
pub fn diffusion(
|
||||||
h: &mut [Alt], b: &mut [Alt],
|
nx: usize,
|
||||||
kd: impl Fn(usize) -> f64, kdsed: f64,
|
ny: usize,
|
||||||
|
xl: f64,
|
||||||
|
yl: f64,
|
||||||
|
dt: f64,
|
||||||
|
_ibc: (),
|
||||||
|
h: &mut [Alt],
|
||||||
|
b: &mut [Alt],
|
||||||
|
kd: impl Fn(usize) -> f64,
|
||||||
|
kdsed: f64,
|
||||||
) {
|
) {
|
||||||
let aij = |i: usize, j: usize| j * nx + i;
|
let aij = |i: usize, j: usize| j * nx + i;
|
||||||
/*
|
/*
|
||||||
@ -148,10 +156,9 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
diag[i] = 1.0 + factxp + factxm;
|
diag[i] = 1.0 + factxp + factxm;
|
||||||
sup[i] = -factxp;
|
sup[i] = -factxp;
|
||||||
inf[i] = -factxm;
|
inf[i] = -factxm;
|
||||||
f[i] =
|
f[i] = zintp[aij(i, j)] + factyp * zintp[aij(i, j + 1)]
|
||||||
zintp[aij(i, j)] + factyp * zintp[aij(i, j+1)] -
|
- (factyp + factym) * zintp[aij(i, j)]
|
||||||
(factyp + factym) *
|
+ factym * zintp[aij(i, j - 1)];
|
||||||
zintp[aij(i, j)] + factym * zintp[aij(i, j-1)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
! left bc
|
! left bc
|
||||||
@ -179,10 +186,9 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
factym = (kdint[aij(0, j - 1)] + kdint[aij(0, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
factym = (kdint[aij(0, j - 1)] + kdint[aij(0, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
||||||
diag[0] = 1.0 + factxp;
|
diag[0] = 1.0 + factxp;
|
||||||
sup[0] = -factxp;
|
sup[0] = -factxp;
|
||||||
f[0] =
|
f[0] = zintp[aij(0, j)] + factyp * zintp[aij(0, j + 1)]
|
||||||
zintp[aij(0, j)] + factyp * zintp[aij(0, j+1)] -
|
- (factyp + factym) * zintp[aij(0, j)]
|
||||||
(factyp + factym) *
|
+ factym * zintp[aij(0, j - 1)];
|
||||||
zintp[aij(0, j)] + factym * zintp[aij(0, j-1)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
! right bc
|
! right bc
|
||||||
@ -206,14 +212,15 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
} else {
|
} else {
|
||||||
// reflective boundary
|
// reflective boundary
|
||||||
factxm = (kdint[aij(nx - 2, j)] + kdint[aij(nx - 1, j)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
factxm = (kdint[aij(nx - 2, j)] + kdint[aij(nx - 1, j)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
||||||
factyp = (kdint[aij(nx-1, j+1)] + kdint[aij(nx-1, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
factyp =
|
||||||
factym = (kdint[aij(nx-1, j-1)] + kdint[aij(nx-1, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
(kdint[aij(nx - 1, j + 1)] + kdint[aij(nx - 1, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
||||||
|
factym =
|
||||||
|
(kdint[aij(nx - 1, j - 1)] + kdint[aij(nx - 1, j)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
||||||
diag[nx - 1] = 1.0 + factxm;
|
diag[nx - 1] = 1.0 + factxm;
|
||||||
inf[nx - 1] = -factxm;
|
inf[nx - 1] = -factxm;
|
||||||
f[nx - 1] =
|
f[nx - 1] = zintp[aij(nx - 1, j)] + factyp * zintp[aij(nx - 1, j + 1)]
|
||||||
zintp[aij(nx-1, j)] + factyp * zintp[aij(nx-1, j+1)] -
|
- (factyp + factym) * zintp[aij(nx - 1, j)]
|
||||||
(factyp + factym) *
|
+ factym * zintp[aij(nx - 1, j - 1)];
|
||||||
zintp[aij(nx-1, j)] + factym * zintp[aij(nx-1, j-1)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
call tridag (inf,diag,sup,f,res,nx)
|
call tridag (inf,diag,sup,f,res,nx)
|
||||||
@ -268,10 +275,9 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
diag[j] = 1.0 + factyp + factym;
|
diag[j] = 1.0 + factyp + factym;
|
||||||
sup[j] = -factyp;
|
sup[j] = -factyp;
|
||||||
inf[j] = -factym;
|
inf[j] = -factym;
|
||||||
f[j] =
|
f[j] = zint[aij(i, j)] + factxp * zint[aij(i + 1, j)]
|
||||||
zint[aij(i, j)] + factxp * zint[aij(i+1, j)] -
|
- (factxp + factxm) * zint[aij(i, j)]
|
||||||
(factxp + factxm) *
|
+ factxm * zint[aij(i - 1, j)];
|
||||||
zint[aij(i, j)] + factxm * zint[aij(i-1, j)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
! bottom bc
|
! bottom bc
|
||||||
@ -302,10 +308,9 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
factyp = (kdint[aij(i, 1)] + kdint[aij(i, 0)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
factyp = (kdint[aij(i, 1)] + kdint[aij(i, 0)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
||||||
diag[0] = 1.0 + factyp;
|
diag[0] = 1.0 + factyp;
|
||||||
sup[0] = -factyp;
|
sup[0] = -factyp;
|
||||||
f[0] =
|
f[0] = zint[aij(i, 0)] + factxp * zint[aij(i + 1, 0)]
|
||||||
zint[aij(i, 0)] + factxp * zint[aij(i+1, 0)] -
|
- (factxp + factxm) * zint[aij(i, 0)]
|
||||||
(factxp + factxm) *
|
+ factxm * zint[aij(i - 1, 0)];
|
||||||
zint[aij(i, 0)] + factxm * zint[aij(i-1, 0)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
! top bc
|
! top bc
|
||||||
@ -328,15 +333,16 @@ pub fn diffusion(nx: usize, ny: usize, xl: f64, yl: f64, dt: f64, _ibc: (),
|
|||||||
f[ny - 1] = zint[aij(i, ny - 1)];
|
f[ny - 1] = zint[aij(i, ny - 1)];
|
||||||
} else {
|
} else {
|
||||||
// reflective boundary
|
// reflective boundary
|
||||||
factxp = (kdint[aij(i+1, ny-1)] + kdint[aij(i, ny-1)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
factxp =
|
||||||
factxm = (kdint[aij(i-1, ny-1)] + kdint[aij(i, ny-1)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
(kdint[aij(i + 1, ny - 1)] + kdint[aij(i, ny - 1)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
||||||
|
factxm =
|
||||||
|
(kdint[aij(i - 1, ny - 1)] + kdint[aij(i, ny - 1)]) / 2.0 * (dt / 2.0) / (dx * dx);
|
||||||
factym = (kdint[aij(i, ny - 2)] + kdint[aij(i, ny - 1)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
factym = (kdint[aij(i, ny - 2)] + kdint[aij(i, ny - 1)]) / 2.0 * (dt / 2.0) / (dy * dy);
|
||||||
diag[ny - 1] = 1.0 + factym;
|
diag[ny - 1] = 1.0 + factym;
|
||||||
inf[ny - 1] = -factym;
|
inf[ny - 1] = -factym;
|
||||||
f[ny - 1] =
|
f[ny - 1] = zint[aij(i, ny - 1)] + factxp * zint[aij(i + 1, ny - 1)]
|
||||||
zint[aij(i, ny-1)] + factxp * zint[aij(i+1, ny-1)] -
|
- (factxp + factxm) * zint[aij(i, ny - 1)]
|
||||||
(factxp + factxm) *
|
+ factxm * zint[aij(i - 1, ny - 1)];
|
||||||
zint[aij(i, ny-1)] + factxm * zint[aij(i-1, ny-1)];
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
call tridag (inf,diag,sup,f,res,ny)
|
call tridag (inf,diag,sup,f,res,ny)
|
||||||
|
@ -12,9 +12,9 @@ pub use self::erosion::{
|
|||||||
pub use self::location::Location;
|
pub use self::location::Location;
|
||||||
pub use self::settlement::Settlement;
|
pub use self::settlement::Settlement;
|
||||||
pub use self::util::{
|
pub use self::util::{
|
||||||
cdf_irwin_hall, downhill, get_oceans, HybridMulti as HybridMulti_, local_cells, map_edge_factor, neighbors,
|
cdf_irwin_hall, downhill, get_oceans, local_cells, map_edge_factor, neighbors,
|
||||||
NEIGHBOR_DELTA, ScaleBias,
|
uniform_idx_as_vec2, uniform_noise, uphill, vec2_as_uniform_idx, HybridMulti as HybridMulti_,
|
||||||
uniform_idx_as_vec2, uniform_noise, uphill, vec2_as_uniform_idx, InverseCdf,
|
InverseCdf, ScaleBias, NEIGHBOR_DELTA,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@ -29,8 +29,8 @@ use common::{
|
|||||||
vol::RectVolSize,
|
vol::RectVolSize,
|
||||||
};
|
};
|
||||||
use noise::{
|
use noise::{
|
||||||
BasicMulti, Billow, Fbm, HybridMulti, MultiFractal, NoiseFn, RangeFunction,
|
BasicMulti, Billow, Fbm, HybridMulti, MultiFractal, NoiseFn, RangeFunction, RidgedMulti,
|
||||||
RidgedMulti, Seedable, SuperSimplex, Worley,
|
Seedable, SuperSimplex, Worley,
|
||||||
};
|
};
|
||||||
use num::{Float, Signed};
|
use num::{Float, Signed};
|
||||||
use rand::{Rng, SeedableRng};
|
use rand::{Rng, SeedableRng};
|
||||||
@ -39,9 +39,9 @@ use rayon::prelude::*;
|
|||||||
use serde_derive::{Deserialize, Serialize};
|
use serde_derive::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
io::{BufReader, BufWriter},
|
|
||||||
f32, f64,
|
f32, f64,
|
||||||
fs::File,
|
fs::File,
|
||||||
|
io::{BufReader, BufWriter},
|
||||||
ops::{Add, Div, Mul, Neg, Sub},
|
ops::{Add, Div, Mul, Neg, Sub},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@ -54,10 +54,7 @@ use vek::*;
|
|||||||
// cleanly representable in f32 (that stops around 1024 * 4 * 1024 * 4, for signed floats anyway)
|
// cleanly representable in f32 (that stops around 1024 * 4 * 1024 * 4, for signed floats anyway)
|
||||||
// but I think that is probably less important since I don't think we actually cast a chunk id to
|
// but I think that is probably less important since I don't think we actually cast a chunk id to
|
||||||
// float, just coordinates... could be wrong though!
|
// float, just coordinates... could be wrong though!
|
||||||
pub const WORLD_SIZE: Vec2<usize> = Vec2 {
|
pub const WORLD_SIZE: Vec2<usize> = Vec2 { x: 1024, y: 1024 };
|
||||||
x: 1024,
|
|
||||||
y: 1024,
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A structure that holds cached noise values and cumulative distribution functions for the input
|
/// A structure that holds cached noise values and cumulative distribution functions for the input
|
||||||
/// that led to those values. See the definition of InverseCdf for a description of how to
|
/// that led to those values. See the definition of InverseCdf for a description of how to
|
||||||
@ -107,7 +104,7 @@ pub(crate) struct GenCtx {
|
|||||||
pub town_gen: StructureGen2d,
|
pub town_gen: StructureGen2d,
|
||||||
|
|
||||||
pub river_seed: RandomField,
|
pub river_seed: RandomField,
|
||||||
pub rock_strength_nz: /*HybridMulti_*/Fbm,
|
pub rock_strength_nz: Fbm,
|
||||||
pub uplift_nz: Worley,
|
pub uplift_nz: Worley,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,7 +163,9 @@ pub struct WorldSim {
|
|||||||
impl WorldSim {
|
impl WorldSim {
|
||||||
pub fn generate(seed: u32, opts: WorldOpts) -> Self {
|
pub fn generate(seed: u32, opts: WorldOpts) -> Self {
|
||||||
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
let mut rng = ChaChaRng::from_seed(seed_expan::rng_state(seed));
|
||||||
let continent_scale = 5_000.0f64/*32768.0*/.div(32.0).mul(TerrainChunkSize::RECT_SIZE.x as f64);
|
let continent_scale = 5_000.0f64 /*32768.0*/
|
||||||
|
.div(32.0)
|
||||||
|
.mul(TerrainChunkSize::RECT_SIZE.x as f64);
|
||||||
let rock_lacunarity = /*0.5*/2.0/*HybridMulti::DEFAULT_LACUNARITY*/;
|
let rock_lacunarity = /*0.5*/2.0/*HybridMulti::DEFAULT_LACUNARITY*/;
|
||||||
let uplift_scale = /*512.0*//*256.0*/128.0;
|
let uplift_scale = /*512.0*//*256.0*/128.0;
|
||||||
let uplift_turb_scale = uplift_scale / 4.0/*32.0*//*64.0*/;
|
let uplift_turb_scale = uplift_scale / 4.0/*32.0*//*64.0*/;
|
||||||
@ -304,7 +303,8 @@ impl WorldSim {
|
|||||||
|
|
||||||
let exp_inverse_cdf = |x: f64/*, pow: f64*/| -(-x).ln_1p()/* / ln(pow)*/;
|
let exp_inverse_cdf = |x: f64/*, pow: f64*/| -(-x).ln_1p()/* / ln(pow)*/;
|
||||||
// 2 / pi * ln(tan(pi/2 * p))
|
// 2 / pi * ln(tan(pi/2 * p))
|
||||||
let hypsec_inverse_cdf = |x: f64| f64::consts::FRAC_2_PI * ((x * f64::consts::FRAC_PI_2).tan().ln());
|
let hypsec_inverse_cdf =
|
||||||
|
|x: f64| f64::consts::FRAC_2_PI * ((x * f64::consts::FRAC_PI_2).tan().ln());
|
||||||
|
|
||||||
let min_epsilon =
|
let min_epsilon =
|
||||||
1.0 / (WORLD_SIZE.x as f64 * WORLD_SIZE.y as f64).max(f64::EPSILON as f64 * 0.5);
|
1.0 / (WORLD_SIZE.x as f64 * WORLD_SIZE.y as f64).max(f64::EPSILON as f64 * 0.5);
|
||||||
@ -364,8 +364,7 @@ impl WorldSim {
|
|||||||
.alt_nz
|
.alt_nz
|
||||||
.get((wposf.div(10_000.0)).into_array())
|
.get((wposf.div(10_000.0)).into_array())
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
.max(-1.0)
|
.max(-1.0)/* .mul(0.25)
|
||||||
/* .mul(0.25)
|
|
||||||
.add(0.125) */)
|
.add(0.125) */)
|
||||||
// .add(0.5)
|
// .add(0.5)
|
||||||
.sub(0.05)
|
.sub(0.05)
|
||||||
@ -525,7 +524,8 @@ impl WorldSim {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Calculate oceans.
|
// Calculate oceans.
|
||||||
let old_height = |posi: usize| alt_old[posi].1 * CONFIG.mountain_scale * height_scale as f32;
|
let old_height =
|
||||||
|
|posi: usize| alt_old[posi].1 * CONFIG.mountain_scale * height_scale as f32;
|
||||||
/* let is_ocean = (0..WORLD_SIZE.x * WORLD_SIZE.y)
|
/* let is_ocean = (0..WORLD_SIZE.x * WORLD_SIZE.y)
|
||||||
.into_par_iter()
|
.into_par_iter()
|
||||||
.map(|i| map_edge_factor(i) == 0.0)
|
.map(|i| map_edge_factor(i) == 0.0)
|
||||||
@ -534,42 +534,43 @@ impl WorldSim {
|
|||||||
let is_ocean_fn = |posi: usize| is_ocean[posi];
|
let is_ocean_fn = |posi: usize| is_ocean[posi];
|
||||||
let turb_wposf_div = 8.0/*64.0*/;
|
let turb_wposf_div = 8.0/*64.0*/;
|
||||||
|
|
||||||
let uplift_nz_dist = gen_ctx.uplift_nz
|
let uplift_nz_dist = gen_ctx.uplift_nz.clone().enable_range(true);
|
||||||
.clone()
|
|
||||||
.enable_range(true);
|
|
||||||
// Recalculate altitudes without oceans.
|
// Recalculate altitudes without oceans.
|
||||||
// NaNs in these uniform vectors wherever is_ocean_fn returns true.
|
// NaNs in these uniform vectors wherever is_ocean_fn returns true.
|
||||||
let (alt_old_no_ocean, alt_old_inverse) =
|
let (alt_old_no_ocean, alt_old_inverse) = uniform_noise(|posi, _| {
|
||||||
uniform_noise(|posi, _| {
|
|
||||||
if is_ocean_fn(posi) {
|
if is_ocean_fn(posi) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
Some(old_height(posi) /*.abs()*/)
|
Some(old_height(posi) /*.abs()*/)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let (uplift_uniform, _) =
|
let (uplift_uniform, _) = uniform_noise(|posi, wposf| {
|
||||||
uniform_noise(|posi, wposf| {
|
|
||||||
if is_ocean_fn(posi) {
|
if is_ocean_fn(posi) {
|
||||||
None
|
None
|
||||||
} else {
|
} else {
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// let turb = Vec2::zero();
|
// let turb = Vec2::zero();
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let turb_wposi = turb_wposf
|
let turb_wposi = turb_wposf
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
||||||
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
||||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||||
let udist = uplift_nz_dist.get(turb_wposf.into_array())
|
let udist = uplift_nz_dist
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
.max(-1.0)
|
.max(-1.0)
|
||||||
.mul(0.5)
|
.mul(0.5)
|
||||||
.add(0.5);
|
.add(0.5);
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -593,10 +594,17 @@ impl WorldSim {
|
|||||||
let udist_2 = udist.mul(2.0).min(1.0);
|
let udist_2 = udist.mul(2.0).min(1.0);
|
||||||
let udist_3 = (1.0 - udist).max(0.0);
|
let udist_3 = (1.0 - udist).max(0.0);
|
||||||
let udist_4 = udist.min(1.0);
|
let udist_4 = udist.min(1.0);
|
||||||
let variation = 1.0.min(64.0 * 64.0 / (WORLD_SIZE.x as f64 * WORLD_SIZE.y as f64 * (TerrainChunkSize::RECT_SIZE.x as f64 * TerrainChunkSize::RECT_SIZE.y as f64 / 128.0 / 128.0)));
|
let variation = 1.0.min(
|
||||||
|
64.0 * 64.0
|
||||||
|
/ (WORLD_SIZE.x as f64
|
||||||
|
* WORLD_SIZE.y as f64
|
||||||
|
* (TerrainChunkSize::RECT_SIZE.x as f64
|
||||||
|
* TerrainChunkSize::RECT_SIZE.y as f64
|
||||||
|
/ 128.0
|
||||||
|
/ 128.0)),
|
||||||
|
);
|
||||||
let variation_1 = (uheight * /*udist_2*/udist_4).min(variation);
|
let variation_1 = (uheight * /*udist_2*/udist_4).min(variation);
|
||||||
let height =
|
let height = (oheight + 0.5).powf(2.0);
|
||||||
(oheight + 0.5).powf(2.0);
|
|
||||||
// 1.0 - variation + variation * uchaos_1;
|
// 1.0 - variation + variation * uchaos_1;
|
||||||
// uheight * /*udist_2*/udist_4 - variation_1 + variation_1 * uchaos_1;
|
// uheight * /*udist_2*/udist_4 - variation_1 + variation_1 * uchaos_1;
|
||||||
// uheight * (0.5 + 0.5 * ((uchaos as f64) / 1.32)) - 0.125;
|
// uheight * (0.5 + 0.5 * ((uchaos as f64) / 1.32)) - 0.125;
|
||||||
@ -617,7 +625,6 @@ impl WorldSim {
|
|||||||
// (uheight + oheight.powf(2.0) * 0.2).max(0.0).min(1.0);
|
// (uheight + oheight.powf(2.0) * 0.2).max(0.0).min(1.0);
|
||||||
// * (1.0 - udist);// uheight * (1.0 - udist)/*oheight*//* * udist*/ + oheight * udist;/*uheight * (1.0 - udist);*/
|
// * (1.0 - udist);// uheight * (1.0 - udist)/*oheight*//* * udist*/ + oheight * udist;/*uheight * (1.0 - udist);*/
|
||||||
// let height = uheight * (0.5 - udist) * 0.8 + (oheight.signum() * oheight.max(0.0).abs().powf(2.0)) * 0.2;// * (1.0 - udist);// uheight * (1.0 - udist)/*oheight*//* * udist*/ + oheight * udist;/*uheight * (1.0 - udist);*/
|
// let height = uheight * (0.5 - udist) * 0.8 + (oheight.signum() * oheight.max(0.0).abs().powf(2.0)) * 0.2;// * (1.0 - udist);// uheight * (1.0 - udist)/*oheight*//* * udist*/ + oheight * udist;/*uheight * (1.0 - udist);*/
|
||||||
|
|
||||||
Some(height)
|
Some(height)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -684,22 +691,25 @@ impl WorldSim {
|
|||||||
if is_ocean_fn(posi) {
|
if is_ocean_fn(posi) {
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
let wposf = (uniform_idx_as_vec2(posi)
|
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
|
||||||
.map(|e| e as f64);
|
.map(|e| e as f64);
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// let turb = Vec2::zero();
|
// let turb = Vec2::zero();
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let turb_wposi = turb_wposf
|
let turb_wposi = turb_wposf
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
||||||
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
||||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -716,9 +726,7 @@ impl WorldSim {
|
|||||||
// ((3.5 - 1.5) * (1.0 - uheight) + 1.5) as f32
|
// ((3.5 - 1.5) * (1.0 - uheight) + 1.5) as f32
|
||||||
1.0
|
1.0
|
||||||
};
|
};
|
||||||
let theta_func = |posi| {
|
let theta_func = |posi| 0.4;
|
||||||
0.4
|
|
||||||
};
|
|
||||||
let kf_func = {
|
let kf_func = {
|
||||||
|posi| {
|
|posi| {
|
||||||
if is_ocean_fn(posi) {
|
if is_ocean_fn(posi) {
|
||||||
@ -731,19 +739,23 @@ impl WorldSim {
|
|||||||
let wposf = (uniform_idx_as_vec2(posi)
|
let wposf = (uniform_idx_as_vec2(posi)
|
||||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||||
.map(|e| e as f64);
|
.map(|e| e as f64);
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// let turb = Vec2::zero();
|
// let turb = Vec2::zero();
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let turb_wposi = turb_wposf
|
let turb_wposi = turb_wposf
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
||||||
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
||||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -798,19 +810,23 @@ impl WorldSim {
|
|||||||
let wposf = (uniform_idx_as_vec2(posi)
|
let wposf = (uniform_idx_as_vec2(posi)
|
||||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||||
.map(|e| e as f64);
|
.map(|e| e as f64);
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// let turb = Vec2::zero();
|
// let turb = Vec2::zero();
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let turb_wposi = turb_wposf
|
let turb_wposi = turb_wposf
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
||||||
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
||||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -824,28 +840,32 @@ impl WorldSim {
|
|||||||
// (uheight * (1.0e-1 - 1.0e-2) + 1.0e-2)
|
// (uheight * (1.0e-1 - 1.0e-2) + 1.0e-2)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let g_func =
|
let g_func = |posi| {
|
||||||
|posi| {
|
if
|
||||||
if /*is_ocean_fn(posi)*/map_edge_factor(posi) == 0.0 {
|
/*is_ocean_fn(posi)*/
|
||||||
|
map_edge_factor(posi) == 0.0 {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
// return 5.0;
|
// return 5.0;
|
||||||
}
|
}
|
||||||
let wposf = (uniform_idx_as_vec2(posi)
|
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
|
||||||
.map(|e| e as f64);
|
.map(|e| e as f64);
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// let turb = Vec2::zero();
|
// let turb = Vec2::zero();
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let turb_wposi = turb_wposf
|
let turb_wposi = turb_wposf
|
||||||
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
.map2(TerrainChunkSize::RECT_SIZE, |e, f| e / f as f64)
|
||||||
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
.map2(WORLD_SIZE, |e, f| (e as i32).max(f as i32 - 1).min(0));
|
||||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -884,15 +904,13 @@ impl WorldSim {
|
|||||||
1.0
|
1.0
|
||||||
// 1.5
|
// 1.5
|
||||||
};
|
};
|
||||||
let uplift_fn =
|
let uplift_fn = |posi| {
|
||||||
|posi| {
|
|
||||||
if is_ocean_fn(posi) {
|
if is_ocean_fn(posi) {
|
||||||
/* return 1e-2
|
/* return 1e-2
|
||||||
.mul(max_erosion_per_delta_t) as f32; */
|
.mul(max_erosion_per_delta_t) as f32; */
|
||||||
return 0.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
let wposf = (uniform_idx_as_vec2(posi)
|
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
|
||||||
.map(|e| e as f64);
|
.map(|e| e as f64);
|
||||||
let alt_main = {
|
let alt_main = {
|
||||||
// Extension upwards from the base. A positive number from 0 to 1 curved to be
|
// Extension upwards from the base. A positive number from 0 to 1 curved to be
|
||||||
@ -918,8 +936,7 @@ impl WorldSim {
|
|||||||
.mul(alt_main.powf(0.8).max(/*0.25*/ 0.15))
|
.mul(alt_main.powf(0.8).max(/*0.25*/ 0.15))
|
||||||
.mul(0.3)
|
.mul(0.3)
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
.mul(0.4)
|
.mul(0.4)/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
||||||
/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
|
||||||
.mul(0.045)*/)
|
.mul(0.045)*/)
|
||||||
};
|
};
|
||||||
let height =
|
let height =
|
||||||
@ -966,7 +983,8 @@ impl WorldSim {
|
|||||||
// assert!(alt_main >= 0.0);
|
// assert!(alt_main >= 0.0);
|
||||||
let (bump_factor, bump_max) = if
|
let (bump_factor, bump_max) = if
|
||||||
/*height < f32::EPSILON as f64 * 0.5*//*false*/
|
/*height < f32::EPSILON as f64 * 0.5*//*false*/
|
||||||
/*true*/false {
|
/*true*/
|
||||||
|
false {
|
||||||
(
|
(
|
||||||
/*(alt_main./*to_le_bytes()[7]*/to_bits() & 1) as f64*/
|
/*(alt_main./*to_le_bytes()[7]*/to_bits() & 1) as f64*/
|
||||||
(alt_main / CONFIG.mountain_scale as f64 * 128.0).mul(0.1).powf(1.2) * /*(1.0 / CONFIG.mountain_scale as f64)*/(f32::EPSILON * 0.5) as f64,
|
(alt_main / CONFIG.mountain_scale as f64 * 128.0).mul(0.1).powf(1.2) * /*(1.0 / CONFIG.mountain_scale as f64)*/(f32::EPSILON * 0.5) as f64,
|
||||||
@ -981,14 +999,18 @@ impl WorldSim {
|
|||||||
// tan(pi/6)*32 ~ 18
|
// tan(pi/6)*32 ~ 18
|
||||||
// tan(54/360*2*pi)*32
|
// tan(54/360*2*pi)*32
|
||||||
// let height = 1.0f64;
|
// let height = 1.0f64;
|
||||||
let turb_wposf =
|
let turb_wposf = wposf
|
||||||
wposf.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64)).div(turb_wposf_div);
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_x_nz.get(turb_wposf.into_array()),
|
||||||
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
gen_ctx.turb_y_nz.get(turb_wposf.into_array()),
|
||||||
) * uplift_turb_scale * TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
) * uplift_turb_scale
|
||||||
|
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
let turb_wposf = wposf + turb;
|
let turb_wposf = wposf + turb;
|
||||||
let uheight = gen_ctx.uplift_nz.get(turb_wposf.into_array())
|
let uheight = gen_ctx
|
||||||
|
.uplift_nz
|
||||||
|
.get(turb_wposf.into_array())
|
||||||
/* .min(0.5)
|
/* .min(0.5)
|
||||||
.max(-0.5)*/
|
.max(-0.5)*/
|
||||||
.min(1.0)
|
.min(1.0)
|
||||||
@ -1062,8 +1084,7 @@ impl WorldSim {
|
|||||||
.mul(alt_main.powf(0.8).max(/*0.25*/ 0.15))
|
.mul(alt_main.powf(0.8).max(/*0.25*/ 0.15))
|
||||||
.mul(0.3)
|
.mul(0.3)
|
||||||
.add(1.0)
|
.add(1.0)
|
||||||
.mul(0.4)
|
.mul(0.4)/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
||||||
/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
|
||||||
.mul(0.045)*/)
|
.mul(0.045)*/)
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1120,7 +1141,9 @@ impl WorldSim {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if map.alt.len() != map.basement.len() || map.alt.len() != WORLD_SIZE.x as usize * WORLD_SIZE.y as usize {
|
if map.alt.len() != map.basement.len()
|
||||||
|
|| map.alt.len() != WORLD_SIZE.x as usize * WORLD_SIZE.y as usize
|
||||||
|
{
|
||||||
log::warn!("World size of map is invalid.");
|
log::warn!("World size of map is invalid.");
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@ -1150,7 +1173,15 @@ impl WorldSim {
|
|||||||
&river_seed,
|
&river_seed,
|
||||||
&rock_strength_nz,
|
&rock_strength_nz,
|
||||||
|posi| alt_func(posi), // + if is_ocean_fn(posi) { 0.0 } else { 128.0 },
|
|posi| alt_func(posi), // + if is_ocean_fn(posi) { 0.0 } else { 128.0 },
|
||||||
|posi| alt_func(posi) - if is_ocean_fn(posi) { 0.0 } else { /*1400.0*//*CONFIG.mountain_scale * 0.75*/0.0 },// if is_ocean_fn(posi) { old_height(posi) } else { 0.0 },
|
|posi| {
|
||||||
|
alt_func(posi)
|
||||||
|
- if is_ocean_fn(posi) {
|
||||||
|
0.0
|
||||||
|
} else {
|
||||||
|
/*1400.0*//*CONFIG.mountain_scale * 0.75*/
|
||||||
|
0.0
|
||||||
|
}
|
||||||
|
}, // if is_ocean_fn(posi) { old_height(posi) } else { 0.0 },
|
||||||
is_ocean_fn,
|
is_ocean_fn,
|
||||||
uplift_fn,
|
uplift_fn,
|
||||||
|posi| n_func(posi),
|
|posi| n_func(posi),
|
||||||
@ -1180,13 +1211,10 @@ impl WorldSim {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Save map, if necessary.
|
// Save map, if necessary.
|
||||||
let map = WorldFile {
|
let map = WorldFile { alt, basement };
|
||||||
alt,
|
|
||||||
basement,
|
|
||||||
};
|
|
||||||
(|| {
|
(|| {
|
||||||
if let FileOpts::Save = opts.world_file {
|
if let FileOpts::Save = opts.world_file {
|
||||||
use std::{time::SystemTime};
|
use std::time::SystemTime;
|
||||||
// Check if folder exists and create it if it does not
|
// Check if folder exists and create it if it does not
|
||||||
let mut path = PathBuf::from("./maps");
|
let mut path = PathBuf::from("./maps");
|
||||||
if !path.exists() {
|
if !path.exists() {
|
||||||
@ -1243,7 +1271,10 @@ impl WorldSim {
|
|||||||
|
|
||||||
let is_ocean = get_oceans(|posi| alt[posi]);
|
let is_ocean = get_oceans(|posi| alt[posi]);
|
||||||
let is_ocean_fn = |posi: usize| is_ocean[posi];
|
let is_ocean_fn = |posi: usize| is_ocean[posi];
|
||||||
let mut dh = downhill(|posi| alt[posi] as f32/*&alt*/, /*old_height*/ is_ocean_fn);
|
let mut dh = downhill(
|
||||||
|
|posi| alt[posi] as f32, /*&alt*/
|
||||||
|
/*old_height*/ is_ocean_fn,
|
||||||
|
);
|
||||||
let (boundary_len, indirection, water_alt_pos, _) = get_lakes(/*&/*water_alt*/alt*/|posi| alt[posi] as f32, &mut dh);
|
let (boundary_len, indirection, water_alt_pos, _) = get_lakes(/*&/*water_alt*/alt*/|posi| alt[posi] as f32, &mut dh);
|
||||||
let flux_old = get_drainage(&water_alt_pos, &dh, boundary_len);
|
let flux_old = get_drainage(&water_alt_pos, &dh, boundary_len);
|
||||||
|
|
||||||
@ -1258,7 +1289,9 @@ impl WorldSim {
|
|||||||
/* // Find the pass this lake is flowing into (i.e. water at the lake bottom gets
|
/* // Find the pass this lake is flowing into (i.e. water at the lake bottom gets
|
||||||
// pushed towards the point identified by pass_idx).
|
// pushed towards the point identified by pass_idx).
|
||||||
let neighbor_pass_idx = dh[lake_idx]; */
|
let neighbor_pass_idx = dh[lake_idx]; */
|
||||||
let chunk_water_alt = if /*neighbor_pass_idx*/dh[lake_idx] < 0 {
|
let chunk_water_alt = if
|
||||||
|
/*neighbor_pass_idx*/
|
||||||
|
dh[lake_idx] < 0 {
|
||||||
// This is either a boundary node (dh[chunk_idx] == -2, i.e. water is at sea level)
|
// This is either a boundary node (dh[chunk_idx] == -2, i.e. water is at sea level)
|
||||||
// or part of a lake that flows directly into the ocean. In the former case, water
|
// or part of a lake that flows directly into the ocean. In the former case, water
|
||||||
// is at sea level so we just return 0.0. In the latter case, the lake bottom must
|
// is at sea level so we just return 0.0. In the latter case, the lake bottom must
|
||||||
@ -1312,7 +1345,9 @@ impl WorldSim {
|
|||||||
/* // Find the pass this lake is flowing into (i.e. water at the lake bottom gets
|
/* // Find the pass this lake is flowing into (i.e. water at the lake bottom gets
|
||||||
// pushed towards the point identified by pass_idx).
|
// pushed towards the point identified by pass_idx).
|
||||||
let neighbor_pass_idx = dh[lake_idx]; */
|
let neighbor_pass_idx = dh[lake_idx]; */
|
||||||
if /*neighbor_pass_idx*/dh[lake_idx] < 0 {
|
if
|
||||||
|
/*neighbor_pass_idx*/
|
||||||
|
dh[lake_idx] < 0 {
|
||||||
// This is either a boundary node (dh[chunk_idx] == -2, i.e. water is at sea level)
|
// This is either a boundary node (dh[chunk_idx] == -2, i.e. water is at sea level)
|
||||||
// or part of a lake that flows directly into the ocean. In the former case, water
|
// or part of a lake that flows directly into the ocean. In the former case, water
|
||||||
// is at sea level so we just return 0.0. In the latter case, the lake bottom must
|
// is at sea level so we just return 0.0. In the latter case, the lake bottom must
|
||||||
@ -1970,9 +2005,7 @@ impl SimChunk {
|
|||||||
let height_scale = 1.0; // 1.0 / CONFIG.mountain_scale;
|
let height_scale = 1.0; // 1.0 / CONFIG.mountain_scale;
|
||||||
let mut alt = CONFIG.sea_level.add(alt_pre.div(height_scale));
|
let mut alt = CONFIG.sea_level.add(alt_pre.div(height_scale));
|
||||||
let mut basement = CONFIG.sea_level.add(basement_pre.div(height_scale));
|
let mut basement = CONFIG.sea_level.add(basement_pre.div(height_scale));
|
||||||
let water_alt = CONFIG
|
let water_alt = CONFIG.sea_level.add(water_alt_pre.div(height_scale));
|
||||||
.sea_level
|
|
||||||
.add(water_alt_pre.div(height_scale));
|
|
||||||
let downhill = if downhill_pre == -2 {
|
let downhill = if downhill_pre == -2 {
|
||||||
None
|
None
|
||||||
} else if downhill_pre < 0 {
|
} else if downhill_pre < 0 {
|
||||||
@ -2030,7 +2063,9 @@ impl SimChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// No trees in the ocean, with zero humidity (currently), or directly on bedrock.
|
// No trees in the ocean, with zero humidity (currently), or directly on bedrock.
|
||||||
let tree_density = if is_underwater/* || alt - basement.min(alt) < 2.0 */ {
|
let tree_density = if is_underwater
|
||||||
|
/* || alt - basement.min(alt) < 2.0 */
|
||||||
|
{
|
||||||
0.0
|
0.0
|
||||||
} else {
|
} else {
|
||||||
let tree_density = (gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()))
|
let tree_density = (gen_ctx.tree_nz.get((wposf.div(1024.0)).into_array()))
|
||||||
|
@ -249,10 +249,14 @@ pub fn uphill<'a>(dh: &'a [isize], posi: usize) -> impl Clone + Iterator<Item =
|
|||||||
/// Compute the neighbor "most downhill" from all chunks.
|
/// Compute the neighbor "most downhill" from all chunks.
|
||||||
///
|
///
|
||||||
/// TODO: See if allocating in advance is worthwhile.
|
/// TODO: See if allocating in advance is worthwhile.
|
||||||
pub fn downhill<F: Float>(h: impl Fn(usize) -> F + Sync, is_ocean: impl Fn(usize) -> bool + Sync) -> Box<[isize]> {
|
pub fn downhill<F: Float>(
|
||||||
|
h: impl Fn(usize) -> F + Sync,
|
||||||
|
is_ocean: impl Fn(usize) -> bool + Sync,
|
||||||
|
) -> Box<[isize]> {
|
||||||
// Constructs not only the list of downhill nodes, but also computes an ordering (visiting
|
// Constructs not only the list of downhill nodes, but also computes an ordering (visiting
|
||||||
// nodes in order from roots to leaves).
|
// nodes in order from roots to leaves).
|
||||||
(0..WORLD_SIZE.x * WORLD_SIZE.y).into_par_iter()
|
(0..WORLD_SIZE.x * WORLD_SIZE.y)
|
||||||
|
.into_par_iter()
|
||||||
// .enumerate()
|
// .enumerate()
|
||||||
.map(|(posi/*, &nh*/)| {
|
.map(|(posi/*, &nh*/)| {
|
||||||
let nh = h(posi);
|
let nh = h(posi);
|
||||||
@ -702,5 +706,3 @@ impl<'a, F: NoiseFn<T> + 'a, T> NoiseFn<T> for ScaleBias<'a, F> {
|
|||||||
(self.source.get(point) * self.scale) + self.bias
|
(self.source.get(point) * self.scale) + self.bias
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user