From 3ba9ab6694d616a18a2d6d4324495c6010e2366f Mon Sep 17 00:00:00 2001 From: Paris DOUADY Date: Tue, 5 Dec 2023 18:47:23 +0100 Subject: [PATCH] make the map smaller --- engine/src/lamplights.rs | 2 +- simulation/src/lib.rs | 784 ++++++++++++------------ simulation/src/map/procgen/heightmap.rs | 12 +- 3 files changed, 399 insertions(+), 399 deletions(-) diff --git a/engine/src/lamplights.rs b/engine/src/lamplights.rs index e1d0df80..398f7775 100644 --- a/engine/src/lamplights.rs +++ b/engine/src/lamplights.rs @@ -42,7 +42,7 @@ pub struct LampLights { impl LampLights { pub const LIGHTCHUNK_SIZE: u32 = 32; // in meters, side length of a light chunk, can contain at most 4 lights - pub const MAP_SIZE: u32 = 50 * 1024; // in meters, side length of the map + pub const MAP_SIZE: u32 = 25 * 1024; // in meters, side length of the map pub const LIGHTMAP_SIZE: u32 = Self::MAP_SIZE / Self::LIGHTCHUNK_SIZE; // in light chunks pub fn new(device: &wgpu::Device, queue: &wgpu::Queue) -> Self { diff --git a/simulation/src/lib.rs b/simulation/src/lib.rs index 29dfa040..399de5b6 100644 --- a/simulation/src/lib.rs +++ b/simulation/src/lib.rs @@ -121,7 +121,7 @@ pub struct SimulationOptions { impl Default for SimulationOptions { fn default() -> Self { SimulationOptions { - terrain_size: 50, + terrain_size: 25, save_replay: true, } } @@ -141,7 +141,7 @@ impl Simulation { pub fn new(gen_terrain: bool) -> Simulation { Self::new_with_options(SimulationOptions { - terrain_size: if gen_terrain { 50 } else { 0 }, + terrain_size: if gen_terrain { 25 } else { 0 }, ..Default::default() }) } @@ -450,437 +450,439 @@ impl<'de> Deserialize<'de> for Simulation { const START_COMMANDS: &str = r#" [ - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6514.85, - 9394.27, - 0.31 - ], - "kind": "Ground" - }, - "to": { - "pos": [ - 6333.2446, - 9478.051, - 0.31 - ], - "kind": "Ground" - }, - "inter": null, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] - } - } - } - ], - [ - 0, - { - "MapBuildSpecialBuilding": { - "pos": { - "corners": [ - 5028940425962066516, - 5029683901981058912, - 5028408391183496666, - 5027664915164504270 + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4343.2334, + 6262.846, + 0.31 + ], + "kind": "Ground" + }, + "to": { + "pos": [ + 4222.163, + 6318.7007, + 0.31 + ], + "kind": "Ground" + }, + "inter": null, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 ] - }, - "kind": "RailFreightStation", - "gen": { - "kind": "no_walkway", - "door_pos": 0 - } + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 3036.1, - 221.0, - 0.3 - ], - "kind": { - "Inter": { - "idx": 2, - "version": 1 - } + } + ], + [ + 0, + { + "MapBuildSpecialBuilding": { + "pos": { + "corners": [ + 5009951615332041499, + 5010447263148181973, + 5009596924048175736, + 5009101271937067965 + ] + }, + "kind": "RailFreightStation", + "gen": { + "kind": "no_walkway", + "door_pos": 0 + }, + "zone": null + } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 2024.0668, + 147.33333, + 0.3 + ], + "kind": { + "Inter": { + "idx": 2, + "version": 1 } - }, - "to": { - "pos": [ - 4246.6924, - 3259.3774, - 0.31 - ], - "kind": "Ground" - }, - "inter": 4991505619838112483, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [ - [ - "Rail", - 9.0 - ] - ] } + }, + "to": { + "pos": [ + 2831.1282, + 2172.9182, + 0.31 + ], + "kind": "Ground" + }, + "inter": 4972985476040057325, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [ + [ + "Rail", + 9.0 + ] + ] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 4246.6924, - 3259.3774, - 0.31 - ], - "kind": { - "Inter": { - "idx": 5, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 2831.1282, + 2172.9182, + 0.31 + ], + "kind": { + "Inter": { + "idx": 5, + "version": 1 } - }, - "to": { - "pos": [ - 6147.913, - 7315.1196, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5024504635272202713, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [ - [ - "Rail", - 9.0 - ] - ] } + }, + "to": { + "pos": [ + 4098.609, + 4876.7466, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5005986054842354977, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [ + [ + "Rail", + 9.0 + ] + ] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6147.913, - 7315.1196, - 0.31 - ], - "kind": { - "Inter": { - "idx": 6, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4098.609, + 4876.7466, + 0.31 + ], + "kind": { + "Inter": { + "idx": 6, + "version": 1 } - }, - "to": { - "pos": [ - 6271.2505, - 8647.945, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5026585735910612163, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [ - [ - "Rail", - 9.0 - ] - ] } + }, + "to": { + "pos": [ + 4180.8335, + 5765.297, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5008381821963615703, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [ + [ + "Rail", + 9.0 + ] + ] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6271.2505, - 8647.945, - 0.31 - ], - "kind": { - "Inter": { - "idx": 7, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4180.8335, + 5765.297, + 0.31 + ], + "kind": { + "Inter": { + "idx": 7, + "version": 1 } - }, - "to": { - "pos": [ - 6469.385, - 8973.193, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5027576078060451273, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "to": { + "pos": [ + 4312.9233, + 5982.129, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5009042048632353377, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6469.385, - 8973.193, - 0.31 - ], - "kind": { - "Inter": { - "idx": 8, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4312.9233, + 5982.129, + 0.31 + ], + "kind": { + "Inter": { + "idx": 8, + "version": 1 } - }, - "to": { - "pos": [ - 6627.6006, - 9225.364, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5030126116108291542, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "to": { + "pos": [ + 4418.4004, + 6150.2427, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5010742073997638941, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6627.6006, - 9225.364, - 0.31 - ], - "kind": { - "Inter": { - "idx": 9, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4418.4004, + 6150.2427, + 0.31 + ], + "kind": { + "Inter": { + "idx": 9, + "version": 1 } - }, - "to": { - "pos": [ - 6514.85, - 9394.27, - 0.31 - ], - "kind": { - "Inter": { - "idx": 3, - "version": 1 - } + } + }, + "to": { + "pos": [ + 4343.2334, + 6262.846, + 0.31 + ], + "kind": { + "Inter": { + "idx": 3, + "version": 1 } - }, - "inter": 5030305808950368141, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "inter": 5010861869225921041, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6333.2446, - 9478.051, - 0.31 - ], - "kind": { - "Inter": { - "idx": 4, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4222.163, + 6318.7007, + 0.31 + ], + "kind": { + "Inter": { + "idx": 4, + "version": 1 } - }, - "to": { - "pos": [ - 6120.8, - 9363.014, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5026096268554115102, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "to": { + "pos": [ + 4080.5332, + 6242.0093, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5008055507530249597, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6120.8, - 9363.014, - 0.31 - ], - "kind": { - "Inter": { - "idx": 10, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4080.5332, + 6242.0093, + 0.31 + ], + "kind": { + "Inter": { + "idx": 10, + "version": 1 } - }, - "to": { - "pos": [ - 6202.4365, - 8983.185, - 0.31 - ], - "kind": "Ground" - }, - "inter": 5025518762956125798, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "to": { + "pos": [ + 4134.9575, + 5988.7896, + 0.31 + ], + "kind": "Ground" + }, + "inter": 5007338222221478024, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ - 0, - { - "MapMakeConnection": { - "from": { - "pos": [ - 6202.4365, - 8983.185, - 0.31 - ], - "kind": { - "Inter": { - "idx": 11, - "version": 1 - } + } + ], + [ + 0, + { + "MapMakeConnection": { + "from": { + "pos": [ + 4134.9575, + 5988.7896, + 0.31 + ], + "kind": { + "Inter": { + "idx": 11, + "version": 1 } - }, - "to": { - "pos": [ - 6271.2505, - 8647.945, - 0.31 - ], - "kind": { - "Inter": { - "idx": 7, - "version": 1 - } + } + }, + "to": { + "pos": [ + 4180.8335, + 5765.297, + 0.31 + ], + "kind": { + "Inter": { + "idx": 7, + "version": 1 } - }, - "inter": 5026925811421779699, - "pat": { - "lanes_forward": [ - [ - "Rail", - 9.0 - ] - ], - "lanes_backward": [] } + }, + "inter": 5008608536108168175, + "pat": { + "lanes_forward": [ + [ + "Rail", + 9.0 + ] + ], + "lanes_backward": [] } } - ], - [ 0, - { - "AddTrain": { - "dist": 150.0, - "n_wagons": 7, - "lane": { - "idx": 3, - "version": 1 - } + } + ], + [ + 0, + { + "AddTrain": { + "dist": 150.0, + "n_wagons": 7, + "lane": { + "idx": 3, + "version": 1 } } - ] + } + ] ] "#; diff --git a/simulation/src/map/procgen/heightmap.rs b/simulation/src/map/procgen/heightmap.rs index 28ae6858..73f6c2be 100644 --- a/simulation/src/map/procgen/heightmap.rs +++ b/simulation/src/map/procgen/heightmap.rs @@ -80,12 +80,10 @@ fn fnoise(ampl: f32, in_wv: Vec2) -> (f32, Vec2) { } pub(crate) fn height(p: Vec2) -> (f32, Vec2) { - //p -= vec2(-2000.0, 2000.0); - - let (noise, mut grad) = fnoise(0.00003, p); + let (noise, mut grad) = fnoise(0.00006, p); let ratio = 0.00005; - let mut noise = noise - 0.1 + (p.y - 25000.0).abs() * ratio; - grad += vec2(0.0, (p.y - 25000.0).signum() * ratio); + let mut noise = noise - 0.1 + (p.y * 2.0 - 25000.0).abs() * ratio; + grad += vec2(0.0, (p.y * 2.0 - 25000.0).signum() * ratio); if noise < -0.0 { noise = noise * noise; grad = 2.0 * noise * grad; @@ -98,6 +96,6 @@ pub(crate) fn height(p: Vec2) -> (f32, Vec2) { pub(crate) fn tree_density(mut p: Vec2) -> f32 { p -= vec2(-20000.0, 20000.0); - let major = simplex_noise((p - vec2(-1000.0, 10000.0)) * 0.0003).0 * 0.5 + 0.5; - (-major * 1.0 + simplex_noise(p * 0.0003).0 * 1.5 + 0.5).max(0.0) + -0.1 + let major = simplex_noise((p - vec2(-1000.0, 10000.0)) * 0.0006).0 * 0.5 + 0.5; + (-major * 1.0 + simplex_noise(p * 0.0006).0 * 1.5 + 0.5).max(0.0) + -0.1 }