This commit is contained in:
griffi-gh 2023-01-26 14:44:11 +01:00
parent a512fffcc4
commit 294648b1b2

View file

@ -13,6 +13,9 @@ use super::{
tasks::{ChunkTaskManager, ChunkTaskResponse, ChunkTask},
};
//todo limit task starts insted
const MAX_CHUNK_RECV: usize = 8;
pub fn update_loaded_world_around_player() -> Workload {
(
update_chunks_if_player_moved,
@ -121,7 +124,7 @@ fn start_required_tasks(
DesiredChunkState::Loaded | DesiredChunkState::Rendered if chunk.current_state == CurrentChunkState::Nothing => {
//start load task
task_manager.spawn_task(ChunkTask::LoadChunk {
seed: 0xdead_cafe,
seed: 0xbeef_face_dead_cafe,
position
});
//Update chunk state
@ -157,7 +160,8 @@ fn process_completed_tasks(
mut meshes: NonSendSync<UniqueViewMut<ChunkMeshStorage>>,
renderer: NonSendSync<UniqueView<Renderer>>
) {
while let Some(res) = task_manager.receive() {
for _ in 0..MAX_CHUNK_OPS {
if let Some(res) = task_manager.receive() {
match res {
ChunkTaskResponse::LoadedChunk { position, chunk_data } => {
//check if chunk exists
@ -208,4 +212,5 @@ fn process_completed_tasks(
}
}
}
}
}