Reenabled towns, lighter days

This commit is contained in:
Joshua Barretto
2019-07-03 20:58:09 +01:00
parent b3691833de
commit 77c2977c44
4 changed files with 4 additions and 17 deletions

View File

@ -3,7 +3,7 @@ const float PI = 3.141592;
const vec3 SKY_DAY_TOP = vec3(0.2, 0.3, 0.9); const vec3 SKY_DAY_TOP = vec3(0.2, 0.3, 0.9);
const vec3 SKY_DAY_MID = vec3(0.15, 0.2, 0.8); const vec3 SKY_DAY_MID = vec3(0.15, 0.2, 0.8);
const vec3 SKY_DAY_BOT = vec3(0.02, 0.1, 0.3); const vec3 SKY_DAY_BOT = vec3(0.02, 0.1, 0.3);
const vec3 DAY_LIGHT = vec3(0.5, 0.5, 0.8); const vec3 DAY_LIGHT = vec3(0.5, 0.5, 1.0);
const vec3 SKY_DUSK_TOP = vec3(0.1, 0.15, 0.3); const vec3 SKY_DUSK_TOP = vec3(0.1, 0.15, 0.3);
const vec3 SKY_DUSK_MID = vec3(0.9, 0.3, 0.2); const vec3 SKY_DUSK_MID = vec3(0.9, 0.3, 0.2);
@ -25,7 +25,7 @@ vec3 get_sun_dir(float time_of_day) {
} }
float get_sun_brightness(vec3 sun_dir) { float get_sun_brightness(vec3 sun_dir) {
return max(-sun_dir.z + 0.6, 0.0) * 0.8; return max(-sun_dir.z + 0.6, 0.0);
} }
const float PERSISTENT_AMBIANCE = 0.008; const float PERSISTENT_AMBIANCE = 0.008;

View File

@ -50,8 +50,6 @@ fn mesh_worker(
} }
} }
const MAX_WORKERS_QUEUED: usize = 32;
pub struct Terrain { pub struct Terrain {
chunks: HashMap<Vec2<i32>, TerrainChunk>, chunks: HashMap<Vec2<i32>, TerrainChunk>,
@ -60,7 +58,6 @@ pub struct Terrain {
mesh_send_tmp: mpsc::Sender<MeshWorkerResponse>, mesh_send_tmp: mpsc::Sender<MeshWorkerResponse>,
mesh_recv: mpsc::Receiver<MeshWorkerResponse>, mesh_recv: mpsc::Receiver<MeshWorkerResponse>,
mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>, mesh_todo: HashMap<Vec2<i32>, ChunkMeshState>,
workers_queued: usize,
} }
impl Terrain { impl Terrain {
@ -75,7 +72,6 @@ impl Terrain {
mesh_send_tmp: send, mesh_send_tmp: send,
mesh_recv: recv, mesh_recv: recv,
mesh_todo: HashMap::new(), mesh_todo: HashMap::new(),
workers_queued: 0,
} }
} }
@ -153,10 +149,6 @@ impl Terrain {
// Only spawn workers for meshing jobs without an active worker already. // Only spawn workers for meshing jobs without an active worker already.
.filter(|todo| !todo.active_worker) .filter(|todo| !todo.active_worker)
{ {
if self.workers_queued >= MAX_WORKERS_QUEUED {
break;
}
// Find the area of the terrain we want. Because meshing needs to compute things like // Find the area of the terrain we want. Because meshing needs to compute things like
// ambient occlusion and edge elision, we also need the borders of the chunk's // ambient occlusion and edge elision, we also need the borders of the chunk's
// neighbours too (hence the `- 1` and `+ 1`). // neighbours too (hence the `- 1` and `+ 1`).
@ -207,7 +199,6 @@ impl Terrain {
)); ));
}); });
todo.active_worker = true; todo.active_worker = true;
self.workers_queued += 1;
} }
// Receive a chunk mesh from a worker thread and upload it to the GPU, then store it. // Receive a chunk mesh from a worker thread and upload it to the GPU, then store it.
@ -245,8 +236,6 @@ impl Terrain {
// since it's either out of date or no longer needed. // since it's either out of date or no longer needed.
_ => {} _ => {}
} }
self.workers_queued -= 1;
} }
// Construct view frustum // Construct view frustum

View File

@ -165,7 +165,6 @@ impl<'a> Sampler for ColumnGen<'a> {
// Cities // Cities
// TODO: In a later MR // TODO: In a later MR
/*
let building = match &sim_chunk.location { let building = match &sim_chunk.location {
Some(loc) => { Some(loc) => {
let loc = &sim.locations[loc.loc_idx]; let loc = &sim.locations[loc.loc_idx];
@ -184,7 +183,6 @@ impl<'a> Sampler for ColumnGen<'a> {
}; };
let alt = alt + building; let alt = alt + building;
*/
// Caves // Caves
let cave_at = |wposf: Vec2<f64>| { let cave_at = |wposf: Vec2<f64>| {

View File

@ -120,9 +120,9 @@ impl WorldSim {
pub fn seed_elements(&mut self) { pub fn seed_elements(&mut self) {
let mut rng = self.rng.clone(); let mut rng = self.rng.clone();
let cell_size = 32; let cell_size = 16;
let grid_size = WORLD_SIZE / cell_size; let grid_size = WORLD_SIZE / cell_size;
let loc_count = 250; let loc_count = 100;
let mut loc_grid = vec![None; grid_size.product()]; let mut loc_grid = vec![None; grid_size.product()];
let mut locations = Vec::new(); let mut locations = Vec::new();