mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Fixes to enable loading (relatively) large maps.
With these changes, we can successfully open, map, and play maps thare are 16x the size of a standard (1024 x 1024 chunk) map, 4x larger in each direction.
This commit is contained in:
parent
d54f22c9fa
commit
ccd85e8907
@ -67,7 +67,7 @@ const SEND_TOK: Token = Token(3);
|
|||||||
const RECV_TOK: Token = Token(4);
|
const RECV_TOK: Token = Token(4);
|
||||||
const MIDDLEMAN_TOK: Token = Token(5);
|
const MIDDLEMAN_TOK: Token = Token(5);
|
||||||
|
|
||||||
const MAX_MSG_BYTES: usize = 1 << 24;
|
const MAX_MSG_BYTES: usize = 1 << 28;
|
||||||
|
|
||||||
enum CtrlMsg {
|
enum CtrlMsg {
|
||||||
Shutdown,
|
Shutdown,
|
||||||
|
@ -43,7 +43,7 @@ impl From<channel::TryRecvError> for Error {
|
|||||||
|
|
||||||
pub trait PostMsg = Serialize + DeserializeOwned + 'static + Send;
|
pub trait PostMsg = Serialize + DeserializeOwned + 'static + Send;
|
||||||
|
|
||||||
const MAX_MSG_SIZE: usize = 1 << 24;
|
const MAX_MSG_SIZE: usize = 1 << 28;
|
||||||
|
|
||||||
pub struct PostOffice<S: PostMsg, R: PostMsg> {
|
pub struct PostOffice<S: PostMsg, R: PostMsg> {
|
||||||
listener: TcpListener,
|
listener: TcpListener,
|
||||||
|
@ -232,8 +232,8 @@ pub fn get_rivers<F: fmt::Debug + Float + Into<f64>, G: Float + Into<f64>>(
|
|||||||
let mut rivers = vec![RiverData::default(); WORLD_SIZE.x * WORLD_SIZE.y].into_boxed_slice();
|
let mut rivers = vec![RiverData::default(); WORLD_SIZE.x * WORLD_SIZE.y].into_boxed_slice();
|
||||||
let neighbor_coef = TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
let neighbor_coef = TerrainChunkSize::RECT_SIZE.map(|e| e as f64);
|
||||||
// (Roughly) area of a chunk, times minutes per second.
|
// (Roughly) area of a chunk, times minutes per second.
|
||||||
let mins_per_sec = /*64.0*/1.0/*1.0 / 16.0*/;
|
let mins_per_sec = /*16.0*/1.0/*1.0 / 16.0*//*1.0 / 64.0*/;
|
||||||
let chunk_area_factor = neighbor_coef.x * neighbor_coef.y / mins_per_sec;
|
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.
|
// NOTE: This technically makes us discontinuous, so we should be cautious about using this.
|
||||||
let derivative_divisor = 1.0;
|
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;
|
||||||
@ -944,14 +944,21 @@ fn erode(
|
|||||||
let old_b_i = b[posi];
|
let old_b_i = b[posi];
|
||||||
let sed = (h_t[posi] - old_b_i) as f64;
|
let sed = (h_t[posi] - old_b_i) as f64;
|
||||||
let n = n_f(posi);
|
let n = n_f(posi);
|
||||||
|
// Higher rock strength tends to lead to higher erodibility?
|
||||||
|
// let max_slope = max_slopes[posi]/*mid_slope*/;
|
||||||
|
let kd_factor =
|
||||||
|
1.0;
|
||||||
|
// (/*1.0 / */(max_slope / mid_slope/*.sqrt()*//*.powf(0.03125)*/).powf(/*2.0*/2.0/* * m*/))/*.min(kdsed)*/;
|
||||||
|
let k_fs = kf(posi) / kd_factor;
|
||||||
|
|
||||||
let k = if sed > sediment_thickness(n) {
|
let k = if sed > sediment_thickness(n) {
|
||||||
// Sediment
|
// Sediment
|
||||||
// k_fs
|
// k_fs
|
||||||
k_fs_mult_sed * kf(posi)
|
k_fs_mult_sed * k_fs
|
||||||
} else {
|
} else {
|
||||||
// Bedrock
|
// Bedrock
|
||||||
// k_fb
|
// k_fb
|
||||||
kf(posi)
|
k_fs
|
||||||
} * dt;
|
} * dt;
|
||||||
let n = n as f64;
|
let n = n as f64;
|
||||||
let m = m_f(posi) as f64;
|
let m = m_f(posi) as f64;
|
||||||
|
@ -133,9 +133,8 @@ impl MapConfig {
|
|||||||
(0..dimensions.y * dimensions.x)
|
(0..dimensions.y * dimensions.x)
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.for_each(|chunk_idx| {
|
.for_each(|chunk_idx| {
|
||||||
let pos = uniform_idx_as_vec2(chunk_idx);
|
let i = chunk_idx % dimensions.x as usize;
|
||||||
let i = pos.x as usize;
|
let j = chunk_idx / dimensions.x as usize;
|
||||||
let j = pos.y as usize;
|
|
||||||
|
|
||||||
let pos =
|
let pos =
|
||||||
(focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
(focus_rect + Vec2::new(i as f64, j as f64) * scale).map(|e: f64| e as i32);
|
||||||
|
@ -386,7 +386,7 @@ impl WorldSim {
|
|||||||
// (0.5^(-(1.0-0.9)))^1/256/32*2^4*256*4
|
// (0.5^(-(1.0-0.9)))^1/256/32*2^4*256*4
|
||||||
// (2^(-(1.0-0.9)))^4
|
// (2^(-(1.0-0.9)))^4
|
||||||
// 16.0
|
// 16.0
|
||||||
.set_frequency(/*0.9*/ /*Fbm*//*HybridMulti_::DEFAULT_FREQUENCY*/1.0 / (2.0/*8.0*//*256.0*//*1.0*//*16.0*/ * TerrainChunkSize::RECT_SIZE.x as f64/*4.0*//* TerrainChunkSize::RECT_SIZE.x as f64 */ * 2.0.powi(10 - 1)))
|
.set_frequency(/*0.9*/ /*Fbm*//*HybridMulti_::DEFAULT_FREQUENCY*/1.0 * (5_000.0 / continent_scale) / (2.0/*8.0*//*256.0*//*1.0*//*16.0*/ * TerrainChunkSize::RECT_SIZE.x as f64/*4.0*//* TerrainChunkSize::RECT_SIZE.x as f64 */ * 2.0.powi(10 - 1)))
|
||||||
// .set_frequency(/*0.9*/ /*Fbm*//*HybridMulti_::DEFAULT_FREQUENCY*/1.0 / (8.0/*8.0*//*256.0*//*1.0*//*16.0*/ * 32.0/*4.0*//* TerrainChunkSize::RECT_SIZE.x as f64 */ * 2.0.powi(10 - 1)))
|
// .set_frequency(/*0.9*/ /*Fbm*//*HybridMulti_::DEFAULT_FREQUENCY*/1.0 / (8.0/*8.0*//*256.0*//*1.0*//*16.0*/ * 32.0/*4.0*//* TerrainChunkSize::RECT_SIZE.x as f64 */ * 2.0.powi(10 - 1)))
|
||||||
// .set_persistence(/*0.9*/ /*2.0*/0.67)
|
// .set_persistence(/*0.9*/ /*2.0*/0.67)
|
||||||
// .set_frequency(/*0.9*/ Fbm::DEFAULT_FREQUENCY / (2.0 * 32.0))
|
// .set_frequency(/*0.9*/ Fbm::DEFAULT_FREQUENCY / (2.0 * 32.0))
|
||||||
@ -711,6 +711,7 @@ impl WorldSim {
|
|||||||
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);
|
.map(|e| e as f64);
|
||||||
let turb_wposf = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -721,6 +722,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -762,6 +764,7 @@ impl WorldSim {
|
|||||||
None
|
None
|
||||||
} else {
|
} 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(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -772,6 +775,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -918,6 +922,7 @@ impl WorldSim {
|
|||||||
* 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 = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -928,6 +933,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -977,6 +983,8 @@ impl WorldSim {
|
|||||||
// multiplied by height_scale^(2m) to account for change in area.
|
// multiplied by height_scale^(2m) to account for change in area.
|
||||||
// 2.5e-6/* / time_scale*//* / 4.0 * 0.25 *//* * 4.0*/
|
// 2.5e-6/* / time_scale*//* / 4.0 * 0.25 *//* * 4.0*/
|
||||||
1.0e-6
|
1.0e-6
|
||||||
|
// 2.0e-5 // 1.8e-4 to 2.2e-6
|
||||||
|
// 1.0e-5 // 9.0e-5 to 1.1e-6
|
||||||
// 2.0e-6
|
// 2.0e-6
|
||||||
// 2.9e-10
|
// 2.9e-10
|
||||||
// ((1.0 - uheight) * (5e-5 - 2.9e-10) + 2.9e-10)
|
// ((1.0 - uheight) * (5e-5 - 2.9e-10) + 2.9e-10)
|
||||||
@ -1000,6 +1008,7 @@ impl WorldSim {
|
|||||||
* 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 = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -1010,6 +1019,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -1053,6 +1063,7 @@ impl WorldSim {
|
|||||||
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);
|
.map(|e| e as f64);
|
||||||
let turb_wposf = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -1063,6 +1074,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -1149,6 +1161,7 @@ impl WorldSim {
|
|||||||
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);
|
.map(|e| e as f64);
|
||||||
let turb_wposf = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -1159,6 +1172,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -1230,6 +1244,7 @@ impl WorldSim {
|
|||||||
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);
|
.map(|e| e as f64);
|
||||||
let turb_wposf = wposf
|
let turb_wposf = wposf
|
||||||
|
.mul(5_000.0 / continent_scale)
|
||||||
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
.div(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
@ -1240,6 +1255,7 @@ impl WorldSim {
|
|||||||
// 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
|
||||||
|
.div(5_000.0 / continent_scale)
|
||||||
.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);
|
||||||
@ -1383,6 +1399,7 @@ impl WorldSim {
|
|||||||
// tan(54/360*2*pi)*32
|
// tan(54/360*2*pi)*32
|
||||||
// let height = 1.0f64;
|
// 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(TerrainChunkSize::RECT_SIZE.map(|e| e as f64))
|
||||||
.div(turb_wposf_div);
|
.div(turb_wposf_div);
|
||||||
let turb = Vec2::new(
|
let turb = Vec2::new(
|
||||||
|
Loading…
Reference in New Issue
Block a user