From a3c4040063664ca5cefb376604902a2d4f67dcec Mon Sep 17 00:00:00 2001 From: Michael Droogleever Fortuyn Date: Sat, 19 Sep 2020 16:13:29 +0200 Subject: [PATCH] Scene terrain worker refactor Simplify ChunkMeshState's active worker tracking to a bool, as the tick value was never being used. --- voxygen/src/scene/terrain.rs | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/voxygen/src/scene/terrain.rs b/voxygen/src/scene/terrain.rs index 1ae0040aab..f838a4d8c8 100644 --- a/voxygen/src/scene/terrain.rs +++ b/voxygen/src/scene/terrain.rs @@ -64,7 +64,7 @@ pub struct TerrainChunkData { struct ChunkMeshState { pos: Vec2, started_tick: u64, - active_worker: Option, + is_worker_active: bool, } /// A type produced by mesh worker threads corresponding to the position and @@ -517,7 +517,7 @@ impl Terrain { self.mesh_todo.insert(pos, ChunkMeshState { pos, started_tick: current_tick, - active_worker: None, + is_worker_active: false, }); } } @@ -562,7 +562,7 @@ impl Terrain { self.mesh_todo.insert(neighbour_chunk_pos, ChunkMeshState { pos: neighbour_chunk_pos, started_tick: current_tick, - active_worker: None, + is_worker_active: false, }); } } @@ -577,12 +577,8 @@ impl Terrain { for (todo, chunk) in self .mesh_todo .values_mut() - .filter(|todo| { - todo.active_worker - .map(|worker_tick| worker_tick < todo.started_tick) - .unwrap_or(true) - }) - .min_by_key(|todo| todo.active_worker.unwrap_or(todo.started_tick)) + .filter(|todo| !todo.is_worker_active) + .min_by_key(|todo| todo.started_tick) // Find a reference to the actual `TerrainChunk` we're meshing .and_then(|todo| { let pos = todo.pos; @@ -658,7 +654,7 @@ impl Terrain { &sprite_config, )); }); - todo.active_worker = Some(todo.started_tick); + todo.is_worker_active = true; } drop(guard);