mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fix all warnings.
This commit is contained in:
parent
ccd85e8907
commit
1d6d0ea03d
586
Cargo.lock
generated
586
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -38,7 +38,8 @@ opt-level = 2
|
||||
opt-level = 2
|
||||
[profile.dev.package."veloren-world"]
|
||||
opt-level = 2
|
||||
[profile.no_overflow.overrides."veloren-world"]
|
||||
|
||||
[profile.no_overflow.package."veloren-world"]
|
||||
opt-level = 3
|
||||
|
||||
# this profile is used by developers if dev doesn't has enough debug information, the name must != debug, as debug is used by dev because....
|
||||
|
@ -19,8 +19,8 @@ use crate::{
|
||||
use client::Client;
|
||||
use common::{
|
||||
comp,
|
||||
terrain::{BlockKind, TerrainChunk, TerrainChunkSize},
|
||||
vol::{ReadVol, RectVolSize},
|
||||
terrain::{BlockKind, TerrainChunk},
|
||||
vol::ReadVol,
|
||||
};
|
||||
use specs::{Join, WorldExt};
|
||||
use vek::*;
|
||||
|
@ -3,13 +3,11 @@ mod natural;
|
||||
use crate::{
|
||||
column::{ColumnGen, ColumnSample},
|
||||
generator::{Generator, TownGen},
|
||||
sim::WorldSim,
|
||||
util::{RandomField, Sampler, SmallCache},
|
||||
CONFIG,
|
||||
};
|
||||
use common::{
|
||||
terrain::{structure::StructureBlock, Block, BlockKind, Structure},
|
||||
util::saturate_srgb,
|
||||
vol::{ReadVol, Vox},
|
||||
};
|
||||
use std::ops::{Add, Div, Mul, Neg};
|
||||
|
@ -4,7 +4,7 @@ mod vol;
|
||||
use super::{Generator, SpawnRules};
|
||||
use crate::{
|
||||
block::{block_from_structure, BlockGen},
|
||||
column::{ColumnGen, ColumnSample},
|
||||
column::ColumnSample,
|
||||
util::Sampler,
|
||||
CONFIG,
|
||||
};
|
||||
|
@ -63,15 +63,13 @@ pub fn diffusion(
|
||||
let mut zint: Vec<f64>;
|
||||
let mut kdint: Vec<f64>;
|
||||
let mut zintp: Vec<f64>;
|
||||
let mut i: usize;
|
||||
let mut j: usize;
|
||||
let mut ij: usize;
|
||||
let mut factxp: f64;
|
||||
let mut factxm: f64;
|
||||
let mut factyp: f64;
|
||||
let mut factym: f64;
|
||||
let mut dx: f64;
|
||||
let mut dy: f64;
|
||||
let dx: f64;
|
||||
let dy: f64;
|
||||
/*
|
||||
character cbc*4
|
||||
|
||||
@ -93,7 +91,7 @@ pub fn diffusion(
|
||||
*/
|
||||
zint = vec![Default::default(); nx * ny];
|
||||
kdint = vec![Default::default(); nx * ny];
|
||||
zintp = vec![Default::default(); nx * ny];
|
||||
// zintp = vec![Default::default(); nx * ny];
|
||||
/*
|
||||
do j=1,ny
|
||||
do i=1,nx
|
||||
@ -381,7 +379,7 @@ pub fn diffusion(
|
||||
}
|
||||
}
|
||||
|
||||
b.par_iter_mut().zip(h).for_each(|(mut b, h)| {
|
||||
b.par_iter_mut().zip(h).for_each(|(b, h)| {
|
||||
*b = h.min(*b);
|
||||
});
|
||||
/*
|
||||
@ -415,9 +413,7 @@ pub fn tridag(a: &[f64], b: &[f64], c: &[f64], r: &[f64], u: &mut [f64], n: usiz
|
||||
|
||||
if(b(1).eq.0.d0) stop 'in tridag'
|
||||
*/
|
||||
let mut j: usize;
|
||||
let mut bet: f64;
|
||||
let mut precision: f64;
|
||||
let mut gam: Vec<f64>;
|
||||
|
||||
gam = vec![Default::default(); n];
|
||||
|
@ -3,21 +3,18 @@ use super::{
|
||||
NEIGHBOR_DELTA, WORLD_SIZE,
|
||||
};
|
||||
use crate::{config::CONFIG, util::RandomField};
|
||||
use arr_macro::arr;
|
||||
use bitvec::prelude::{bitbox, bitvec, BitBox};
|
||||
use common::{terrain::TerrainChunkSize, vol::RectVolSize};
|
||||
use faster::*;
|
||||
// use faster::*;
|
||||
use itertools::izip;
|
||||
use noise::{NoiseFn, Point3};
|
||||
use num::{Float, FromPrimitive, One, Zero};
|
||||
use num::{Float, Zero};
|
||||
use ordered_float::NotNan;
|
||||
use packed_simd::{/*f32x8, f64x8,*/ m32, m64};
|
||||
use packed_simd::m32;
|
||||
use rayon::prelude::*;
|
||||
use std::{
|
||||
cmp::{Ordering, Reverse},
|
||||
collections::BinaryHeap,
|
||||
f32, f64, fmt, mem,
|
||||
path::PathBuf,
|
||||
time::Instant,
|
||||
u32,
|
||||
};
|
||||
@ -28,7 +25,7 @@ pub type Alt = f64;
|
||||
pub type Compute = f64;
|
||||
pub type Computex8 = [Compute; 8];
|
||||
|
||||
/// This is a fast approximation of powf. This should only be used when minor accuracy loss is acceptable.
|
||||
/* /// This is a fast approximation of powf. This should only be used when minor accuracy loss is acceptable.
|
||||
#[inline(always)]
|
||||
#[allow(unsafe_code)]
|
||||
fn approx_powf(b: f32, e: f32) -> f32 {
|
||||
@ -44,7 +41,7 @@ fn approx_powf(b: f32, e: f32) -> f32 {
|
||||
b.a[0] = 0;
|
||||
b.f as f32
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
/// Compute the water flux at all chunks, given a list of chunk indices sorted by increasing
|
||||
/// height.
|
||||
@ -236,7 +233,7 @@ pub fn get_rivers<F: fmt::Debug + Float + Into<f64>, G: Float + Into<f64>>(
|
||||
let chunk_area_factor = neighbor_coef.x * neighbor_coef.y * mins_per_sec;
|
||||
// NOTE: This technically makes us discontinuous, so we should be cautious about using this.
|
||||
let derivative_divisor = 1.0;
|
||||
let height_scale = 1.0; // 1.0 / CONFIG.mountain_scale as f64;
|
||||
// let height_scale = 1.0; // 1.0 / CONFIG.mountain_scale as f64;
|
||||
newh.into_iter().rev().for_each(|&chunk_idx| {
|
||||
let chunk_idx = chunk_idx as usize;
|
||||
let downhill_idx = downhill[chunk_idx];
|
||||
@ -326,7 +323,7 @@ pub fn get_rivers<F: fmt::Debug + Float + Into<f64>, G: Float + Into<f64>>(
|
||||
let pass_idx = (-indirection_idx) as usize;
|
||||
/* let pass_pos = uniform_idx_as_vec2(pass_idx);
|
||||
let lake_direction = neighbor_coef * (neighbor_pass_pos - pass_pos).map(|e| e as f64); */
|
||||
let pass = &rivers[pass_idx];
|
||||
// let pass = &rivers[pass_idx];
|
||||
/* // Our side of the pass must have already been traversed (even if our side of the pass
|
||||
// is the lake bottom), so we acquire its computed river_spline_derivative.
|
||||
debug_assert!(pass.is_lake()); */
|
||||
@ -711,9 +708,8 @@ fn erode(
|
||||
// a: &mut [Alt],
|
||||
// Height above sea level of water
|
||||
wh: &mut [Alt],
|
||||
is_done: &mut BitBox,
|
||||
done_val: bool,
|
||||
erosion_base: f32,
|
||||
// is_done: &mut BitBox,
|
||||
// done_val: bool,
|
||||
max_uplift: f32,
|
||||
max_g: f32,
|
||||
kdsed: f64,
|
||||
@ -768,7 +764,7 @@ fn erode(
|
||||
// let l = /*200.0 * max_uplift as f64;*/(1.0e-2 /*/ CONFIG.mountain_scale as f64*/ * height_scale);
|
||||
// let l_tot = l * dt;
|
||||
// Debris flow coefficient (m / year).
|
||||
let k_df = 1.0e-4/*0.0*/;
|
||||
// let k_df = 1.0e-4/*0.0*/;
|
||||
// Debris flow area coefficient (m^(-2q)).
|
||||
let q = 0.2;
|
||||
let q_ = /*1.0*/1.5/*1.0*/;
|
||||
@ -832,7 +828,7 @@ fn erode(
|
||||
/* let n = 2.4;// 1.0;//1.5;//2.4;//1.0;
|
||||
let m = n * 0.5;// n * 0.4;// 0.96;// 0.4;//0.6;//0.96;//0.4; */
|
||||
// Stream power erosion constant (bedrock), in m^(1-2m) / year (times dt).
|
||||
let k_fb = // erosion_base as f64 + 2.244 / mmaxh as f64 * max_uplift as f64;
|
||||
/* let k_fb = // erosion_base as f64 + 2.244 / mmaxh as f64 * max_uplift as f64;
|
||||
// 2.244*(5.010e-4)/512*5- (1.097e-5)
|
||||
// 2.244*(5.010e-4)/2048*5- (1.097e-5)
|
||||
// 2.244*(5.010e-4)/512- (8e-6)
|
||||
@ -844,7 +840,7 @@ fn erode(
|
||||
// ln(tan(30/360*2*pi))-ln(tan(6/360*2*pi))*1500 = 3378
|
||||
//erosion_base as f64 + 2.244 / mmaxh as f64 * /*10.0*//*5.0*//*9.0*//*7.5*//*5.0*//*2.5*//*1.5*//*5.0*//*1.0*//*1.5*//*2.5*//*3.75*/ * max_uplift as f64;
|
||||
// 2.5e-6 * dt;
|
||||
2e-5 * dt;
|
||||
2e-5 * dt; */
|
||||
// see http://geosci.uchicago.edu/~kite/doc/Whipple_and_Tucker_1999.pdf
|
||||
//5e-6 * dt; // 2e-5 was designed for steady state uplift of 2mm / y whih would amount to 500 m / 250,000 y.
|
||||
// (2.244*(5.010e-4)/512)/(2.244*(5.010e-4)/2500) = 4.88...
|
||||
@ -852,13 +848,13 @@ fn erode(
|
||||
// Stream power erosion constant (sediment), in m^(1-2m) / year (times dt).
|
||||
let k_fs_mult_sed = /*1.0;*//*2.0*/4.0; /*1.0;*///2.0;/*1.5*/;
|
||||
// Stream power erosion constant (underwater).
|
||||
let k_fs_mult_water = /*1.0*//*0.5*/0.25;
|
||||
// let k_fs_mult_water = /*1.0*//*0.5*/0.25;
|
||||
let g_fs_mult_sed = 1.0/*0.5*/;
|
||||
// let k_fs = k_fb * 1.0/*1.5*//*2.0*//*2.0*//*4.0*/;
|
||||
// u = k * h_max / 2.244
|
||||
// let uplift_scale = erosion_base as f64 + (k_fb * mmaxh / 2.244 / 5.010e-4 as f64 * mmaxh as f64) * dt;
|
||||
let (
|
||||
(dh, indirection, newh, maxh, mrec, mstack, mwrec, area),
|
||||
(dh, /*indirection, */ newh, maxh, mrec, mstack, mwrec, area),
|
||||
(mut max_slopes, /*(ht, at)*/ h_t),
|
||||
) = rayon::join(
|
||||
|| {
|
||||
@ -871,7 +867,7 @@ fn erode(
|
||||
},
|
||||
);
|
||||
log::debug!("Computed downhill...");
|
||||
let (boundary_len, indirection, newh, maxh) = get_lakes(
|
||||
let (boundary_len, _indirection, newh, maxh) = get_lakes(
|
||||
|posi| h[posi], /* + uplift(posi) as Alt*/
|
||||
/* + a[posi].max(0.0)*//* + uplift(posi) as Alt*/
|
||||
&mut dh,
|
||||
@ -892,7 +888,9 @@ fn erode(
|
||||
// let area = get_drainage(&newh, &dh, boundary_len);
|
||||
let area = get_multi_drainage(&mstack, &mrec, &*mwrec, boundary_len);
|
||||
log::debug!("Got flux...");
|
||||
(dh, indirection, newh, maxh, mrec, mstack, mwrec, area)
|
||||
(
|
||||
dh, /*indirection, */ newh, maxh, mrec, mstack, mwrec, area,
|
||||
)
|
||||
},
|
||||
|| {
|
||||
rayon::join(
|
||||
@ -928,7 +926,7 @@ fn erode(
|
||||
|
||||
type SimdType = f32;
|
||||
type MaskType = m32;
|
||||
let simd_func = /*f64s*/f32s;
|
||||
// let simd_func = /*f64s*/f32s;
|
||||
|
||||
// Precompute factors for Stream Power Law.
|
||||
let czero = </*Compute*/SimdType as Zero>::zero();
|
||||
@ -1014,7 +1012,7 @@ fn erode(
|
||||
// Higher rock strength tends to lead to higher curvature?
|
||||
let kd_factor =
|
||||
// 1.0;
|
||||
(/*1.0 / */(max_slope / mid_slope/*.sqrt()*//*.powf(0.03125)*/).powf(/*2.0*/2.0/* * q*/))/*.min(kdsed)*/;
|
||||
/*(1.0 / */(max_slope / mid_slope/*.sqrt()*//*.powf(0.03125)*/).powf(/*2.0*/2.0/* * q*/)/*).min(kdsed)*/;
|
||||
let k_da = k_da /*/ /*max_slope*/*/ * kd_factor;// .powf(q/* / q_*/);
|
||||
|
||||
// let k_df = /*uplift_i*/0.05e-3 / (1.0 + k_da * /*chunk_area_pow*/(10_000.0).powf(q)) / max_slope.powf(q_);
|
||||
@ -1169,7 +1167,7 @@ fn erode(
|
||||
assert!(mstack.len() == dh.len());
|
||||
assert!(b.len() == dh.len());
|
||||
assert!(h_t.len() == dh.len());
|
||||
let mut mstack_inv = &mut *mstack_inv;
|
||||
let mstack_inv = &mut *mstack_inv;
|
||||
mstack.iter().enumerate().for_each(|(stacki, &posi)| {
|
||||
let posi = posi as usize;
|
||||
mstack_inv[posi] = stacki;
|
||||
@ -1215,7 +1213,7 @@ fn erode(
|
||||
(&mut *h_p, &*h_stack)
|
||||
.into_par_iter()
|
||||
// .enumerate()
|
||||
.for_each(|(/*stacki, */((mut h_p, h_)/*, wh_*/))| {
|
||||
.for_each(|(/*stacki, ((*/h_p, h_/*), wh_*//*)*/)| {
|
||||
*h_p = (*h_)/*.max(*wh_)*/ as Compute/* + (0.5 - (stacki & 1) as Compute) * err as Compute*/;
|
||||
});
|
||||
/* hp.par_iter_mut().zip(h.par_iter()).for_each(|(mut hp, h)| {
|
||||
@ -1236,7 +1234,7 @@ fn erode(
|
||||
{
|
||||
// calculate erosion/deposition of sediment at each node
|
||||
(&*mstack, &mut *deltah, &*h_t_stack, &*h_stack).into_par_iter()/*.enumerate()*/
|
||||
.for_each(|(/*stacki, */(&posi, mut deltah, &h_t_i, &h_i))| {
|
||||
.for_each(|(/*stacki, (*/&posi, deltah, &h_t_i, &h_i/*)*/)| {
|
||||
let posi = posi as usize;
|
||||
/* assert_eq!(mstack_inv[posi], stacki);
|
||||
assert_eq!(h_t[posi], h_t_i); */
|
||||
@ -1295,7 +1293,7 @@ fn erode(
|
||||
/* lake_sediment[posi] = deltah_sediment[posi];
|
||||
lake_alluvium[posi] = deltah_alluvium[posi]; */
|
||||
} else {
|
||||
let posj = posj as usize;
|
||||
// let posj = posj as usize;
|
||||
let uplift_i = uplift(posi) as Alt;
|
||||
/* if (deltah[posi] - (deltah_sediment[posi] + deltah_alluvium[posi])).abs() > 1.0e-2 {
|
||||
println!("deltah_sediment: {:?}, deltah_alluvium: {:?}, deltah: {:?}, hp: {:?}, ap: {:?}, h_p: {:?}, ht: {:?}, at: {:?}, h: {:?}, a: {:?}, h_: {:?}",
|
||||
@ -1372,7 +1370,7 @@ fn erode(
|
||||
// enddo
|
||||
|
||||
let start_time = Instant::now();
|
||||
(&*mstack, &mut *elev, &*dh_stack, &*h_t_stack, &*area_stack, &*deltah, &*h_p, &*b_stack).into_par_iter()./*enumerate().*/for_each(|(/*stacki, */(&posi, mut elev, &dh_i, &h_t_i, &area_i, &deltah_i, &h_p_i, &b_i))| {
|
||||
(&*mstack, &mut *elev, &*dh_stack, &*h_t_stack, &*area_stack, &*deltah, &*h_p, &*b_stack).into_par_iter()./*enumerate().*/for_each(|(/*stacki, (*/&posi, elev, &dh_i, &h_t_i, &area_i, &deltah_i, &h_p_i, &b_i/*)*/)| {
|
||||
let posi = posi as usize;
|
||||
/* assert_eq!(mstack_inv[posi], stacki);
|
||||
assert_eq!(dh_i, dh[posi]);
|
||||
@ -1411,7 +1409,7 @@ fn erode(
|
||||
// actually was material to deposit. The current assumption is that as long as we
|
||||
// are storing at most as much sediment as there actually was along the river, we
|
||||
// are in the clear.
|
||||
let g_i_ratio = (g_i / (p * area_i))/*.min(1.0)*/;
|
||||
let g_i_ratio = /*(*/g_i / (p * area_i)/*).min(1.0)*/;
|
||||
// One side of nonlinear equation (23):
|
||||
//
|
||||
// h_i(t) + U_i * Δt + G / (p̃ * Ã_i) * Σ{j ∈ upstream_i(t)}(h_j(t, FINAL) + U_j * Δt - h_j(t + Δt, k))
|
||||
@ -1444,22 +1442,22 @@ fn erode(
|
||||
/* let mut k_df_weights = [0.0; 8];
|
||||
let mut k_fs_weights = [0.0; 8];
|
||||
let mut rec_heights = [0.0; 8]; */
|
||||
let mut simd_buf = [0.0; 8];
|
||||
/* let mut simd_buf = [0.0; 8];
|
||||
let mut simd_buf2 = [0.0; 8];
|
||||
let mut simd_buf3 = [0.0; 8];
|
||||
let mut simd_buf3 = [0.0; 8]; */
|
||||
/*&*newh*/
|
||||
itertools::izip!(&*mstack, &*elev, /*&mut *wh, */&*b_stack/*, &mut *h_stack*/, &*h_t_stack, &*dh_stack, &*h_p)
|
||||
.enumerate()
|
||||
.rev()
|
||||
.for_each(|(stacki, (&posi, &elev_i, /*wh_i, */&b_i, /*h_i, */&h_t_i, &dh_i, &h_p_i))| {
|
||||
let mut iteration_error = 0.0;
|
||||
let iteration_error = 0.0;
|
||||
let posi = posi as usize;
|
||||
/* assert_eq!(mstack_inv[posi], stacki);
|
||||
assert_eq!(dh_i, dh[posi]);
|
||||
assert_eq!(h_t_i, h_t[posi]);
|
||||
assert_eq!(b_i, b[posi]); */
|
||||
let old_elev_i = /*h*//*elev[posi]*/elev_i as f64;
|
||||
let old_wh_i = wh[posi]/*wh_i*/;
|
||||
// let old_wh_i = wh[posi]/*wh_i*/;
|
||||
let old_b_i = /*b[posi]*/b_i;
|
||||
let old_ht_i = /*ht*//*h_t[posi]*/h_t_i;
|
||||
let sed = (old_ht_i - old_b_i) as f64;
|
||||
@ -1484,7 +1482,7 @@ fn erode(
|
||||
} else {
|
||||
// *is_done.at(posi) = done_val;
|
||||
let posj = posj as usize;
|
||||
let posj_stack = mstack_inv[posj];
|
||||
// let posj_stack = mstack_inv[posj];
|
||||
// let dxy = (uniform_idx_as_vec2(posi) - uniform_idx_as_vec2(posj)).map(|e| e as f64);
|
||||
|
||||
// Has an outgoing flow edge (posi, posj).
|
||||
@ -1500,7 +1498,7 @@ fn erode(
|
||||
// h[i](t + dt) = (h[i](t) + δt * (uplift[i] + flux(i) * h[j](t + δt))) / (1 + flux(i) * δt).
|
||||
// NOTE: posj has already been computed since it's downhill from us.
|
||||
// Therefore, we can rely on wh being set to the water height for that node.
|
||||
let h_j = h[posj_stack] as f64;
|
||||
// let h_j = h[posj_stack] as f64;
|
||||
// let a_j = a[posj] as f64;
|
||||
let wh_j = wh[posj] as f64;
|
||||
// let old_a_i = a[posi] as f64;
|
||||
@ -1526,7 +1524,7 @@ fn erode(
|
||||
|
||||
// Only perform erosion if we are above the water level of the previous node.
|
||||
if old_elev_i > wh_j/*h_j*//*h_j*//*h[posj]*/ {
|
||||
let mut dtherm = 0.0f64;
|
||||
let dtherm = 0.0f64;
|
||||
/* {
|
||||
// Thermal erosion (landslide)
|
||||
let dxy = (uniform_idx_as_vec2(posi) - uniform_idx_as_vec2(posj)).map(|e| e as f64);
|
||||
@ -1575,7 +1573,7 @@ fn erode(
|
||||
k_fs_fact
|
||||
}; */
|
||||
// let elev_j = h_j/* + a_j.max(0.0)*/;
|
||||
let new_ht_i = (old_ht_i/* + uplift(posi) as f64*/);
|
||||
// let new_ht_i = (old_ht_i/* + uplift(posi) as f64*/);
|
||||
if /*n == 1.0*/(n - 1.0).abs() <= 1.0e-3/*f64::EPSILON*/ && (q_ - 1.0).abs() <= 1.0e-3 {
|
||||
let mut f = h0;
|
||||
let mut df = 1.0;
|
||||
@ -1604,14 +1602,14 @@ fn erode(
|
||||
} else {
|
||||
// Local Newton-Raphson
|
||||
let omega1 = 0.875f64 * n;
|
||||
let omega2 = 0.875f64 / q_;/*if q_ < 0.5 { 0.875f64/* * q_*/ } else { 0.875f64 / q_ }*/;
|
||||
let omega2 = 0.875f64 / q_/*if q_ < 0.5 { 0.875f64/* * q_*/ } else { 0.875f64 / q_ }*/;
|
||||
let omega = omega1.max(omega2);
|
||||
let tolp = 1.0e-3/*1.0e-4*/;
|
||||
// let tolp = tol;
|
||||
let mut errp = 2.0 * tolp;
|
||||
// let h0 = old_elev_i + (new_h_i - old_h_i);
|
||||
// let mut count = 0;
|
||||
let mut max = 0usize;
|
||||
// let mut max = 0usize;
|
||||
/* let mut k_df_weights = [0.0; 8];//f64s(0.0);//f64x8::splat(0.0);
|
||||
let mut k_fs_weights = [0.0; 8];//f64s(0.0);//f64x8::splat(0.0);
|
||||
let n_weights = simd_func(n as SimdType - 1.0);
|
||||
@ -1653,7 +1651,7 @@ fn erode(
|
||||
}; 8];
|
||||
(arr, max)
|
||||
}; */
|
||||
assert!(max <= 8);
|
||||
// assert!(max <= 8);
|
||||
/* let k_fs_weights = &k_fs_weights[..max];
|
||||
let k_df_weights = &k_df_weights[..max];
|
||||
let rec_heights = &rec_heights[..max];
|
||||
@ -1789,7 +1787,7 @@ fn erode(
|
||||
if /*mask[kk]*/mask_kk.test() {
|
||||
let h_j = rec_heights_kk;//rec_heights[kk];
|
||||
let elev_j = h_j/* + a_j.max(0.0)*/;
|
||||
let dh = 0.0.max((new_h_i as SimdType - elev_j)/*.abs()*/);
|
||||
let dh = 0.0.max(/*(*/new_h_i as SimdType - elev_j/*).abs()*/);
|
||||
let powf = |a: SimdType, b| a.powf(b);
|
||||
// let powf = |a, b| approx_powf(a as f32, b as f32) as SimdType;
|
||||
let dh_fs_sample = /*k_fs_fact[kk]*/k_fs_fact_kk as /*f64*/SimdType * powf(dh, n as SimdType - 1.0);
|
||||
@ -2139,9 +2137,9 @@ fn erode(
|
||||
|
||||
err = (sum_err / /*newh*/mstack.len() as Compute).sqrt();
|
||||
log::debug!("(RMSE: {:?})", err);
|
||||
/* if max_g == 0.0 {
|
||||
if max_g == 0.0 {
|
||||
err = 0.0;
|
||||
} */
|
||||
}
|
||||
if n_gs_stream_power_law == max_n_gs_stream_power_law {
|
||||
log::warn!(
|
||||
"Beware: Gauss-Siedel scheme not convergent: err={:?}, expected={:?}",
|
||||
@ -2210,7 +2208,7 @@ fn erode(
|
||||
b.par_iter_mut()
|
||||
.zip_eq(h.par_iter())
|
||||
.enumerate()
|
||||
.for_each(|(posi, (mut b, &h_i))| {
|
||||
.for_each(|(posi, (b, &h_i))| {
|
||||
let old_b_i = *b;
|
||||
let uplift_i = uplift(posi) as Alt;
|
||||
|
||||
@ -2257,10 +2255,14 @@ fn erode(
|
||||
log::debug!("Done updating basement and applying soil production...");
|
||||
|
||||
// update the height to reflect sediment flux.
|
||||
if max_g > 0.0 {
|
||||
// If max_g = 0.0, lake_silt will be too high during the first iteration since our
|
||||
// initial estimate for h is very poor; however, the elevation estimate will have been
|
||||
// unaffected by g.
|
||||
(&mut *h, &*mstack_inv)
|
||||
.into_par_iter()
|
||||
.enumerate()
|
||||
.for_each(|(posi, (mut h, &stacki))| {
|
||||
.for_each(|(posi, (h, &stacki))| {
|
||||
let lposi = lake_sill[stacki];
|
||||
if lposi >= 0 {
|
||||
let lposi = lposi as usize;
|
||||
@ -2276,6 +2278,7 @@ fn erode(
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// do ij=1,nn
|
||||
// if (lake_sill(ij).ne.0) then
|
||||
// if (lake_water_volume(lake_sill(ij)).gt.0.d0) h(ij)=h(ij) &
|
||||
@ -2349,9 +2352,9 @@ fn erode(
|
||||
let max_slope = max_slopes[posi];
|
||||
// Remember k_d for this chunk in max_slopes.
|
||||
// higher max_slope => much lower kd_factor.
|
||||
let kd_factor =
|
||||
/* let kd_factor =
|
||||
// 1.0;
|
||||
(1.0 / (max_slope / mid_slope/*.sqrt()*//*.powf(0.03125)*/).powf(/*2.0*/2.0))/*.min(kdsed)*/;
|
||||
(1.0 / (max_slope / mid_slope/*.sqrt()*//*.powf(0.03125)*/).powf(/*2.0*/2.0))/*.min(kdsed)*/; */
|
||||
let n = n_f(posi);
|
||||
max_slopes[posi] = if sed > sediment_thickness(n) && kdsed > 0.0 {
|
||||
// Sediment
|
||||
@ -2377,7 +2380,7 @@ fn erode(
|
||||
let posj = posj as usize;
|
||||
// Find the water height for this chunk's receiver; we only apply thermal erosion
|
||||
// for chunks above water.
|
||||
let mut wh_j = wh[posj] as f64;
|
||||
let wh_j = wh[posj] as f64;
|
||||
// If you're on the lake bottom and not right next to your neighbor, don't compute a
|
||||
// slope.
|
||||
let mut new_h_i = /*old_h_i*//*old_h_i + old_a_i.max(0.0)*/old_h_i; /*old_b_i;*/
|
||||
@ -2421,12 +2424,12 @@ fn erode(
|
||||
// exactly max_slope.
|
||||
// max_slope = (old_h_i + dh - h_j) / height_scale/* * CONFIG.mountain_scale */ / NEIGHBOR_DISTANCE
|
||||
// dh = max_slope * NEIGHBOR_DISTANCE * height_scale/* / CONFIG.mountain_scale */ + h_j - old_h_i.
|
||||
let dh = max_slope * neighbor_distance/* * height_scale*//* / CONFIG.mountain_scale as f64*/;
|
||||
// let dh = max_slope * neighbor_distance/* * height_scale*//* / CONFIG.mountain_scale as f64*/;
|
||||
// new_h_i = /*h_j.max*//*(h_k + dh).max*/(/*new_h_i*/ht[posi] as f64 + l_tot * (mag_slope - max_slope));
|
||||
// new_h_i = /*h_j.max*//*(h_k + dh).max*/(/*new_h_i*/h_k + dh + l_tot * (mag_slope - max_slope));
|
||||
// new_h_i = /*h_j.max*//*(h_k + dh).max*/(new_h_i - l_tot * (mag_slope - max_slope));
|
||||
let dtherm = 0.0/*dz - dh*//*(l_tot * (mag_slope - max_slope)).min(/*(dz/* - dh*/) / 2.0*/(1.0 + max_g) * max_uplift as f64)*/;
|
||||
new_h_i = /*h_j.max*//*(h_k + dh).max*/(/*new_h_i*//*h_k + dh*/new_h_i - dtherm);
|
||||
new_h_i = /*h_j.max*//*(h_k + dh).max*//*(new_h_i*//*h_k + dh*/new_h_i - dtherm/*)*/;
|
||||
/* let new_h_j = (old_h_j + dtherm).min(old_h_j.max(new_h_i));
|
||||
h[posj] = new_h_j as Alt;
|
||||
wh_j = wh_j.max(new_h_j);
|
||||
@ -3032,7 +3035,7 @@ pub fn get_lakes<F: Float>(
|
||||
tag[pass_idx] = Tag::InQueue;
|
||||
|
||||
let outflow_coords = uniform_idx_as_vec2(neighbor_pass_idx);
|
||||
let elev = h(neighbor_pass_idx).max(h(pass_idx));;
|
||||
let elev = h(neighbor_pass_idx).max(h(pass_idx));
|
||||
|
||||
while let Some(node) = filling_queue.pop() {
|
||||
let coords = uniform_idx_as_vec2(node);
|
||||
@ -3047,8 +3050,8 @@ pub fn get_lakes<F: Float>(
|
||||
return;
|
||||
}
|
||||
let dxy = (uniform_idx_as_vec2(ineighbor) - coords).map(|e| e as f64);
|
||||
let neighbor_distance = (/*neighbor_coef * */dxy);
|
||||
let mut tag = &mut tag[ineighbor];
|
||||
let neighbor_distance = /*neighbor_coef * */dxy;
|
||||
let tag = &mut tag[ineighbor];
|
||||
match *tag {
|
||||
Tag::WithRcv => {
|
||||
// TODO: Remove outdated comment.
|
||||
@ -3066,7 +3069,7 @@ pub fn get_lakes<F: Float>(
|
||||
//
|
||||
// Which is also the scalar component of vec_to_outflow in the
|
||||
// direction of vec_to_neighbor.
|
||||
let cost = (outflow_distance.dot(neighbor_distance / neighbor_distance.magnitude()))/*.abs()*/;
|
||||
let cost = /*(*/outflow_distance.dot(neighbor_distance / neighbor_distance.magnitude())/*).abs()*/;
|
||||
if cost > rcv_cost {
|
||||
rcv = ineighbor as isize;
|
||||
rcv_cost = cost;
|
||||
@ -3176,12 +3179,12 @@ pub fn get_multi_rec<F: fmt::Debug + Float + Sync + Into<Compute>>(
|
||||
let nn = nx * ny;
|
||||
let dxdy = Vec2::new(dx, dy);
|
||||
|
||||
// set bc
|
||||
/* // set bc
|
||||
let i1 = 0;
|
||||
let i2 = nx;
|
||||
let j1 = 0;
|
||||
let j2 = ny;
|
||||
/* let xcyclic = false;
|
||||
let xcyclic = false;
|
||||
let ycyclic = false; */
|
||||
/*
|
||||
write (cbc,'(i4)') ibc
|
||||
@ -3278,7 +3281,7 @@ pub fn get_multi_rec<F: fmt::Debug + Float + Sync + Into<Compute>>(
|
||||
wh_ij > wh_ijk {
|
||||
// Set neighboring edge lower than this one as being downhill.
|
||||
// NOTE: relying on at most 8 neighbors.
|
||||
mrec_ij |= (1 << k);
|
||||
mrec_ij |= 1 << k;
|
||||
} else if
|
||||
/*h_ijk*/
|
||||
wh_ijk > wh_ij {
|
||||
@ -3395,7 +3398,6 @@ pub fn get_multi_rec<F: fmt::Debug + Float + Sync + Into<Compute>>(
|
||||
|
||||
/// Perform erosion n times.
|
||||
pub fn do_erosion(
|
||||
erosion_base: f32,
|
||||
_max_uplift: f32,
|
||||
n_steps: usize,
|
||||
seed: &RandomField,
|
||||
@ -3534,7 +3536,7 @@ pub fn do_erosion(
|
||||
let height_scale = |n| height_scale(n);
|
||||
let k_da_scale = |q| k_da_scale(q);
|
||||
// Hillslope diffusion coefficient for sediment.
|
||||
let mut is_done = bitbox![0; WORLD_SIZE.x * WORLD_SIZE.y];
|
||||
// let mut is_done = bitbox![0; WORLD_SIZE.x * WORLD_SIZE.y];
|
||||
(0..n_steps).for_each(|i| {
|
||||
log::debug!("Erosion iteration #{:?}", i);
|
||||
erode(
|
||||
@ -3542,12 +3544,11 @@ pub fn do_erosion(
|
||||
&mut b,
|
||||
// &mut a,
|
||||
&mut wh,
|
||||
&mut is_done,
|
||||
// The value to use to indicate that erosion is complete on a chunk. Should toggle
|
||||
// &mut is_done,
|
||||
/* // The value to use to indicate that erosion is complete on a chunk. Should toggle
|
||||
// once per iteration, to avoid having to reset the bits, and start at true, since
|
||||
// we initialize to 0 (false).
|
||||
i & 1 == 0,
|
||||
erosion_base,
|
||||
i & 1 == 0, */
|
||||
max_uplift,
|
||||
max_g,
|
||||
// -1.0,
|
||||
|
@ -1,6 +1,5 @@
|
||||
use crate::{
|
||||
sim::{self, uniform_idx_as_vec2, RiverKind, WorldSim, WORLD_SIZE},
|
||||
util::Sampler,
|
||||
sim::{RiverKind, WorldSim, WORLD_SIZE},
|
||||
CONFIG,
|
||||
};
|
||||
use common::{terrain::TerrainChunkSize, vol::RectVolSize};
|
||||
|
@ -209,7 +209,7 @@ pub enum WorldFileError {
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[repr(u32)]
|
||||
pub enum WorldFile {
|
||||
Veloren_0_5_0(WorldMap_0_5_0) = 0,
|
||||
Veloren0_5_0(WorldMap_0_5_0) = 0,
|
||||
}
|
||||
|
||||
/// Data for the most recent map type. Update this when you add a new map verson.
|
||||
@ -268,15 +268,15 @@ impl WorldFile {
|
||||
/// using the latest map version.
|
||||
|
||||
pub fn new(map: ModernMap) -> Self {
|
||||
WorldFile::Veloren_0_5_0(map)
|
||||
WorldFile::Veloren0_5_0(map)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Turns a WorldFile into the latest version. Whenever a new map version is added, just add
|
||||
/// it to this match statement.
|
||||
pub fn into_modern(self) -> Result<ModernMap, (WorldFileError)> {
|
||||
pub fn into_modern(self) -> Result<ModernMap, WorldFileError> {
|
||||
match self {
|
||||
WorldFile::Veloren_0_5_0(map) => map.into_modern(),
|
||||
WorldFile::Veloren0_5_0(map) => map.into_modern(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -458,8 +458,8 @@ impl WorldSim {
|
||||
// a chunk isn't available).
|
||||
let n_approx = 1.0;
|
||||
let max_erosion_per_delta_t = /*8.0*//*32.0*//*1.0*//*32.0*//*32.0*//*16.0*//*64.0*//*32.0*/64.0/*128.0*//*1.0*//*0.2 * /*100.0*/250.0*//*128.0*//*16.0*//*128.0*//*32.0*/ * delta_t_scale(n_approx);
|
||||
let erosion_pow_low = /*0.25*//*1.5*//*2.0*//*0.5*//*4.0*//*0.25*//*1.0*//*2.0*//*1.5*//*1.5*//*0.35*//*0.43*//*0.5*//*0.45*//*0.37*/1.002;
|
||||
let erosion_pow_high = /*1.5*//*1.0*//*0.55*//*0.51*//*2.0*/1.002;
|
||||
/* let erosion_pow_low = /*0.25*//*1.5*//*2.0*//*0.5*//*4.0*//*0.25*//*1.0*//*2.0*//*1.5*//*1.5*//*0.35*//*0.43*//*0.5*//*0.45*//*0.37*/1.002;
|
||||
let erosion_pow_high = /*1.5*//*1.0*//*0.55*//*0.51*//*2.0*/1.002; */
|
||||
let erosion_center = /*0.45*//*0.75*//*0.75*//*0.5*//*0.75*/0.5;
|
||||
let n_steps = /*200*//*10_000*//*1000*//*50*//*100*/100; //100; // /*100*//*50*//*100*//*100*//*50*//*25*/25/*100*//*37*/;//150;//37/*100*/;//50;//50;//37;//50;//37; // /*37*//*29*//*40*//*150*/37; //150;//200;
|
||||
let n_small_steps = 0; //25;//8;//50;//50;//8;//8;//8;//8;//8; // 8
|
||||
@ -469,14 +469,14 @@ impl WorldSim {
|
||||
let logit = |x: f64| x.ln() - (-x).ln_1p();
|
||||
// 0.5 + 0.5 * tanh(ln(1 / (1 - 0.1) - 1) / (2 * (sqrt(3)/pi)))
|
||||
let logistic_2_base = 3.0f64.sqrt() * f64::consts::FRAC_2_PI;
|
||||
let logistic_base = /*3.0f64.sqrt() * f64::consts::FRAC_1_PI*/1.0f64;
|
||||
// let logistic_base = /*3.0f64.sqrt() * f64::consts::FRAC_1_PI*/1.0f64;
|
||||
// Assumes μ = 0, σ = 1
|
||||
let logistic_cdf = |x: f64| (x / logistic_2_base).tanh() * 0.5 + 0.5;
|
||||
|
||||
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))
|
||||
let hypsec_inverse_cdf =
|
||||
|x: f64| f64::consts::FRAC_2_PI * ((x * f64::consts::FRAC_PI_2).tan().ln());
|
||||
|x: f64| f64::consts::FRAC_2_PI * ((x * f64::consts::FRAC_PI_2).tan().ln()); */
|
||||
|
||||
let min_epsilon =
|
||||
1.0 / (WORLD_SIZE.x as f64 * WORLD_SIZE.y as f64).max(f64::EPSILON as f64 * 0.5);
|
||||
@ -708,9 +708,9 @@ impl WorldSim {
|
||||
if is_ocean_fn(posi) {
|
||||
return 1.0;
|
||||
}
|
||||
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64);
|
||||
let turb_wposf = wposf
|
||||
/* let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64); */
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -720,13 +720,13 @@ impl WorldSim {
|
||||
) * uplift_turb_scale
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
let turb_wposf = wposf + turb; */
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||
let uheight = gen_ctx
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi); */
|
||||
/* let uheight = gen_ctx
|
||||
.uplift_nz
|
||||
.get(turb_wposf.into_array())
|
||||
/* .min(0.5)
|
||||
@ -734,7 +734,7 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
.add(0.5); */
|
||||
/* if uheight > 0.8 {
|
||||
1.5
|
||||
} else {
|
||||
@ -749,7 +749,7 @@ impl WorldSim {
|
||||
alt_old[posi].1 * CONFIG.mountain_scale * height_scale(n_func(posi)) as f32
|
||||
};
|
||||
|
||||
let uplift_nz_dist = gen_ctx.uplift_nz.clone().enable_range(true);
|
||||
// let uplift_nz_dist = gen_ctx.uplift_nz.clone().enable_range(true);
|
||||
// Recalculate altitudes without oceans.
|
||||
// NaNs in these uniform vectors wherever is_ocean_fn returns true.
|
||||
let (alt_old_no_ocean, alt_old_inverse) = uniform_noise(|posi, _| {
|
||||
@ -759,11 +759,11 @@ impl WorldSim {
|
||||
Some(old_height(posi) /*.abs()*/)
|
||||
}
|
||||
});
|
||||
let (uplift_uniform, _) = uniform_noise(|posi, wposf| {
|
||||
let (uplift_uniform, _) = uniform_noise(|posi, _wposf| {
|
||||
if is_ocean_fn(posi) {
|
||||
None
|
||||
} else {
|
||||
let turb_wposf = wposf
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -773,13 +773,13 @@ impl WorldSim {
|
||||
) * uplift_turb_scale
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
let turb_wposf = wposf + turb; */
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||
let udist = uplift_nz_dist
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi); */
|
||||
/* let udist = uplift_nz_dist
|
||||
.get(turb_wposf.into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
@ -793,18 +793,18 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.add(0.5); */
|
||||
/* let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5); */
|
||||
chaos[posi].1;
|
||||
|
||||
let uchaos_1 = (uchaos as f64) / 1.32;
|
||||
let uchaos_1 = (uchaos as f64) / 1.32; */
|
||||
|
||||
let oheight = /*alt_old*//*alt_base*/alt_old_no_ocean[/*(turb_posi / 64) * 64*/posi].0 as f64 - 0.5;
|
||||
assert!(udist >= 0.0);
|
||||
/* assert!(udist >= 0.0);
|
||||
assert!(udist <= 1.0);
|
||||
let uheight_1 = uheight; //.powf(2.0);
|
||||
let udist_1 = (0.5 - udist).mul(2.0).max(0.0);
|
||||
@ -820,7 +820,7 @@ impl WorldSim {
|
||||
/ 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 = (oheight + 0.5).powf(2.0);
|
||||
// 1.0 - variation + variation * uchaos_1;
|
||||
// uheight * /*udist_2*/udist_4 - variation_1 + variation_1 * uchaos_1;
|
||||
@ -846,16 +846,16 @@ impl WorldSim {
|
||||
}
|
||||
});
|
||||
|
||||
let old_height_uniform = |posi: usize| alt_old_no_ocean[posi].0;
|
||||
// let old_height_uniform = |posi: usize| alt_old_no_ocean[posi].0;
|
||||
let alt_old_min_uniform = 0.0;
|
||||
let alt_old_max_uniform = 1.0;
|
||||
let alt_old_center_uniform = erosion_center;
|
||||
let (_alt_old_min_index, alt_old_min) = alt_old_inverse.first().unwrap();
|
||||
let (_alt_old_max_index, alt_old_max) = alt_old_inverse.last().unwrap();
|
||||
let (_alt_old_mid_index, alt_old_mid) =
|
||||
// let alt_old_center_uniform = erosion_center;
|
||||
let (_alt_old_min_index, _alt_old_min) = alt_old_inverse.first().unwrap();
|
||||
let (_alt_old_max_index, _alt_old_max) = alt_old_inverse.last().unwrap();
|
||||
let (_alt_old_mid_index, _alt_old_mid) =
|
||||
alt_old_inverse[(alt_old_inverse.len() as f64 * erosion_center) as usize];
|
||||
let alt_old_center =
|
||||
((alt_old_mid - alt_old_min) as f64 / (alt_old_max - alt_old_min) as f64);
|
||||
/* let alt_old_center =
|
||||
((alt_old_mid - alt_old_min) as f64 / (alt_old_max - alt_old_min) as f64); */
|
||||
|
||||
/* // Find the minimum and maximum original altitudes.
|
||||
// NOTE: Will panic if there is no land, and will not work properly if the minimum and
|
||||
@ -893,19 +893,19 @@ impl WorldSim {
|
||||
// let erosion_pow = 2.0;
|
||||
// let n_steps = 100;//150;
|
||||
// let erosion_factor = |x: f64| logistic_cdf(erosion_pow * logit(x));
|
||||
let log_odds = |x: f64| {
|
||||
/* let log_odds = |x: f64| {
|
||||
logit(x)
|
||||
- logit(
|
||||
/*erosion_center*/ alt_old_center_uniform, /*alt_old_center*/
|
||||
)
|
||||
};
|
||||
}; */
|
||||
/* let erosion_factor = |x: f64| logistic_cdf(logistic_base * if x <= /*erosion_center*/alt_old_center_uniform/*alt_old_center*/ { erosion_pow_low.ln() } else { erosion_pow_high.ln() } * log_odds(x))/*0.5 + (x - 0.5).signum() * ((x - 0.5).mul(2.0).abs(
|
||||
).powf(erosion_pow).mul(0.5))*/; */
|
||||
let erosion_factor = |x: f64| (/*if x <= /*erosion_center*/alt_old_center_uniform/*alt_old_center*/ { erosion_pow_low.ln() } else { erosion_pow_high.ln() } * */(/*exp_inverse_cdf*//*logit*/inv_func(x) - alt_exp_min_uniform) / (alt_exp_max_uniform - alt_exp_min_uniform))/*0.5 + (x - 0.5).signum() * ((x - 0.5).mul(2.0).abs(
|
||||
).powf(erosion_pow).mul(0.5))*//*.powf(0.5)*//*.powf(1.5)*//*.powf(2.0)*/;
|
||||
let rock_strength_div_factor = /*8.0*/(2.0 * TerrainChunkSize::RECT_SIZE.x as f64) / 8.0;
|
||||
// let time_scale = 1.0; //4.0/*4.0*/;
|
||||
let theta_func = |posi| 0.4;
|
||||
let theta_func = |_posi| 0.4;
|
||||
let kf_func = {
|
||||
|posi| {
|
||||
let kf_scale_i = k_fs_scale(theta_func(posi), n_func(posi)) as f64;
|
||||
@ -918,10 +918,10 @@ impl WorldSim {
|
||||
// return 2.0e-10;
|
||||
// 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))
|
||||
.map(|e| e as f64);
|
||||
let turb_wposf = wposf
|
||||
.map(|e| e as f64); */
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -931,13 +931,13 @@ impl WorldSim {
|
||||
) * uplift_turb_scale
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
let turb_wposf = wposf + turb; */
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||
let uheight = gen_ctx
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi); */
|
||||
/* let uheight = gen_ctx
|
||||
.uplift_nz
|
||||
.get(turb_wposf.into_array())
|
||||
/* .min(0.5)
|
||||
@ -945,17 +945,17 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
.add(0.5); */
|
||||
|
||||
let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
/* let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5); */
|
||||
chaos[posi].1;
|
||||
chaos[posi].1; */
|
||||
|
||||
let oheight = /*alt_old*//*alt_base*/alt_old_no_ocean[/*(turb_posi / 64) * 64*/posi].0 as f64;
|
||||
let oheight_2 = /*alt_old*//*alt_base*/(alt_old_no_ocean[/*(turb_posi / 64) * 64*/posi].1 as f64 / CONFIG.mountain_scale as f64);
|
||||
/* let oheight = /*alt_old*//*alt_base*/alt_old_no_ocean[/*(turb_posi / 64) * 64*/posi].0 as f64;
|
||||
let oheight_2 = /*alt_old*//*alt_base*/(alt_old_no_ocean[/*(turb_posi / 64) * 64*/posi].1 as f64 / CONFIG.mountain_scale as f64); */
|
||||
|
||||
let kf_i = // kf = 1.5e-4: high-high (plateau [fan sediment])
|
||||
// kf = 1e-4: high (plateau)
|
||||
@ -1002,12 +1002,12 @@ impl WorldSim {
|
||||
/*1.0e-2*/
|
||||
1.0e-2 / 4.0
|
||||
;
|
||||
kd_i * kd_scale_i;
|
||||
return kd_i * kd_scale_i;
|
||||
}
|
||||
let wposf = (uniform_idx_as_vec2(posi)
|
||||
/* let wposf = (uniform_idx_as_vec2(posi)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64);
|
||||
let turb_wposf = wposf
|
||||
.map(|e| e as f64); */
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -1017,13 +1017,13 @@ impl WorldSim {
|
||||
) * uplift_turb_scale
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
let turb_wposf = wposf + turb; */
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||
let uheight = gen_ctx
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi); */
|
||||
/* let uheight = gen_ctx
|
||||
.uplift_nz
|
||||
.get(turb_wposf.into_array())
|
||||
/* .min(0.5)
|
||||
@ -1031,13 +1031,13 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.add(0.5); */
|
||||
/* let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5); */
|
||||
chaos[posi].1;
|
||||
chaos[posi].1; */
|
||||
|
||||
// kd = 1e-1: high (mountain, dike)
|
||||
// kd = 1.5e-2: normal-high (plateau [fan sediment])
|
||||
@ -1045,7 +1045,7 @@ impl WorldSim {
|
||||
// multiplied by height_scale² to account for change in area, then divided by
|
||||
// time_scale to account for lower dt.
|
||||
let kd_i = // 1.0e-2 * kd_scale_i;// m_old^2 / y * (1 m_new / 4 m_old)^2
|
||||
1.10e-2 / 4.0
|
||||
1.0e-2 / 4.0
|
||||
// (uheight * (1.0e-1 - 1.0e-2) + 1.0e-2)
|
||||
// ((1.0 - uheight) * (0.5 + 0.5 * ((1.32 - uchaos as f64) / 1.32)) * (1.0e-2 - 1.0e-3) + 1.0e-3)
|
||||
// (uheight * (1.0e-2 - 1.0e-3) + 1.0e-3) / 2.0
|
||||
@ -1060,9 +1060,9 @@ impl WorldSim {
|
||||
return 0.0;
|
||||
// return 5.0;
|
||||
}
|
||||
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64);
|
||||
let turb_wposf = wposf
|
||||
/* let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64); */
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -1072,13 +1072,13 @@ impl WorldSim {
|
||||
) * uplift_turb_scale
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
let turb_wposf = wposf + turb; */
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi);
|
||||
let uheight = gen_ctx
|
||||
let turb_posi = vec2_as_uniform_idx(turb_wposi); */
|
||||
/* let uheight = gen_ctx
|
||||
.uplift_nz
|
||||
.get(turb_wposf.into_array())
|
||||
/* .min(0.5)
|
||||
@ -1086,16 +1086,16 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
.add(0.5); */
|
||||
|
||||
let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
/* let uchaos = /* gen_ctx.chaos_nz.get((wposf.div(3_000.0)).into_array())
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5); */
|
||||
chaos[posi].1;
|
||||
|
||||
assert!(uchaos <= 1.32);
|
||||
assert!(uchaos <= 1.32); */
|
||||
|
||||
// G = d* v_s / p_0, where
|
||||
// v_s is the settling velocity of sediment grains
|
||||
@ -1171,11 +1171,11 @@ impl WorldSim {
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
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())
|
||||
@ -1221,7 +1221,6 @@ impl WorldSim {
|
||||
let epsilon_0_i =
|
||||
// ((1.0 - ustrength) * (/*3.18e-4*/2.078e-3 - 5.3e-5) + 5.3e-5) as f32
|
||||
((1.0 - ustrength) * (/*3.18e-4*/2.078e-3 - 5.3e-5) + 5.3e-5) as f32 / 4.0
|
||||
;
|
||||
/* * time_scale*/
|
||||
// 0.0
|
||||
;
|
||||
@ -1254,11 +1253,11 @@ impl WorldSim {
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||
// let turb = Vec2::zero();
|
||||
let turb_wposf = wposf + turb;
|
||||
let turb_wposi = turb_wposf
|
||||
/* let turb_wposi = turb_wposf
|
||||
.div(5_000.0 / continent_scale)
|
||||
.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));
|
||||
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())
|
||||
@ -1309,7 +1308,7 @@ impl WorldSim {
|
||||
.mul(max_erosion_per_delta_t) as f32; */
|
||||
return 0.0;
|
||||
}
|
||||
let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
/* let wposf = (uniform_idx_as_vec2(posi) * TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64);
|
||||
let alt_main = {
|
||||
// Extension upwards from the base. A positive number from 0 to 1 curved to be
|
||||
@ -1337,10 +1336,10 @@ impl WorldSim {
|
||||
.add(1.0)
|
||||
.mul(0.4)/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
||||
.mul(0.045)*/)
|
||||
};
|
||||
}; */
|
||||
let height =
|
||||
((/*old_height_uniform*/uplift_uniform[posi]./*0*/1 - alt_old_min_uniform) as f64
|
||||
/ (alt_old_max_uniform - alt_old_min_uniform) as f64)
|
||||
(/*old_height_uniform*/uplift_uniform[posi]./*0*/1 - alt_old_min_uniform) as f64
|
||||
/ (alt_old_max_uniform - alt_old_min_uniform) as f64
|
||||
/*((old_height(posi) - alt_old_min) as f64
|
||||
/ (alt_old_max - alt_old_min) as f64)*/
|
||||
;
|
||||
@ -1386,7 +1385,8 @@ impl WorldSim {
|
||||
false {
|
||||
(
|
||||
/*(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, */
|
||||
0.0,
|
||||
(f32::EPSILON * 0.5) as f64,
|
||||
)
|
||||
} else {
|
||||
@ -1398,7 +1398,7 @@ impl WorldSim {
|
||||
// tan(pi/6)*32 ~ 18
|
||||
// tan(54/360*2*pi)*32
|
||||
// let height = 1.0f64;
|
||||
let turb_wposf = wposf
|
||||
/* let turb_wposf = wposf
|
||||
.mul(5_000.0 / continent_scale)
|
||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||
.div(turb_wposf_div);
|
||||
@ -1416,7 +1416,7 @@ impl WorldSim {
|
||||
.min(1.0)
|
||||
.max(-1.0)
|
||||
.mul(0.5)
|
||||
.add(0.5);
|
||||
.add(0.5); */
|
||||
// u = 1e-3: normal-high (dike, mountain)
|
||||
// u = 5e-4: normal (mid example in Yuan, average mountain uplift)
|
||||
// u = 2e-4: low (low example in Yuan; known that lagoons etc. may have u ~ 0.05).
|
||||
@ -1457,7 +1457,7 @@ impl WorldSim {
|
||||
old_height(posi) // 0.0
|
||||
} else {
|
||||
// uplift_fn(posi)
|
||||
let wposf = (uniform_idx_as_vec2(posi)
|
||||
/* let wposf = (uniform_idx_as_vec2(posi)
|
||||
* TerrainChunkSize::RECT_SIZE.map(|e| e as i32))
|
||||
.map(|e| e as f64);
|
||||
let alt_main = {
|
||||
@ -1486,7 +1486,7 @@ impl WorldSim {
|
||||
.add(1.0)
|
||||
.mul(0.4)/* + spring(alt_main.abs().powf(0.5).min(0.75).mul(60.0).sin(), 4.0)
|
||||
.mul(0.045)*/)
|
||||
};
|
||||
}; */
|
||||
|
||||
// (kf_func(posi) / 1.5e-4 * CONFIG.mountain_scale as f64) as f32
|
||||
// (old_height_uniform(posi) as f64 * CONFIG.mountain_scale as f64) as f32
|
||||
@ -1611,7 +1611,6 @@ impl WorldSim {
|
||||
)
|
||||
} else {
|
||||
let (alt, basement /*, alluvium*/) = do_erosion(
|
||||
0.0,
|
||||
max_erosion_per_delta_t as f32,
|
||||
n_steps,
|
||||
&river_seed,
|
||||
@ -1647,7 +1646,6 @@ impl WorldSim {
|
||||
|
||||
// Quick "small scale" erosion cycle in order to lower extreme angles.
|
||||
do_erosion(
|
||||
0.0,
|
||||
(1.0/* * height_scale*/) as f32,
|
||||
n_small_steps,
|
||||
&river_seed,
|
||||
@ -1716,7 +1714,6 @@ impl WorldSim {
|
||||
(alt, basement /*, alluvium*/)
|
||||
} else {
|
||||
do_erosion(
|
||||
0.0,
|
||||
(1.0/* * height_scale*/) as f32,
|
||||
n_post_load_steps,
|
||||
&river_seed,
|
||||
@ -2483,7 +2480,7 @@ impl SimChunk {
|
||||
|
||||
// let height_scale = 1.0; // 1.0 / CONFIG.mountain_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 basement = CONFIG.sea_level.add(basement_pre /*.div(height_scale)*/);
|
||||
let water_alt = CONFIG.sea_level.add(water_alt_pre /*.div(height_scale)*/);
|
||||
let downhill = if downhill_pre == -2 {
|
||||
None
|
||||
|
@ -258,7 +258,7 @@ pub fn downhill<F: Float>(
|
||||
(0..WORLD_SIZE.x * WORLD_SIZE.y)
|
||||
.into_par_iter()
|
||||
// .enumerate()
|
||||
.map(|(posi/*, &nh*/)| {
|
||||
.map(|/*(*/ posi /*, &nh)*/| {
|
||||
let nh = h(posi);
|
||||
let _pos = uniform_idx_as_vec2(posi);
|
||||
if is_ocean(posi) {
|
||||
|
@ -1,5 +1,4 @@
|
||||
use super::{RandomField, Sampler};
|
||||
use crate::block::BlockGen;
|
||||
use rayon::prelude::*;
|
||||
use vek::*;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user