ChunkLoader

This commit is contained in:
Piotrek
2021-05-16 14:04:45 +02:00
parent f8760e876c
commit 77c74be02f
6 changed files with 152 additions and 141 deletions
+2 -12
View File
@@ -41,14 +41,8 @@ impl Game {
for x in -RENDER_DIST..RENDER_DIST+1 {
for z in -RENDER_DIST..RENDER_DIST+1 {
let pos = Vector3{x, y: 0, z};
instance.world.load_chunk_async(pos);
instance.world.load_chunk(pos);
count += 1;
//if instance.world.load_chunk(pos) {
//let chunk = instance.world.get_chunk(&pos).unwrap();
//chunk.write_to(renderer, pos * world::chunk::SIZE as i32);
//println!("Writing chunk to {:?}", pos * world::chunk::SIZE as i32);
//count += 1;
//}
}
}
println!("Preloaded {} chunks in {} ms (about {} voxels)", count, timer.elapsed().as_millis(), count * world::block::SIZE_QB);
@@ -103,11 +97,7 @@ impl Game {
for a in -RENDER_DIST..RENDER_DIST+1 {
let pos = center + Vector3{x: mask.z*a, y: 0, z: mask.x*a};
self.world.load_chunk_async(pos);
// if self.world.load_chunk(pos) {
// self.world.get_chunk(&pos).unwrap().dirty = true;
// }
self.world.load_chunk(pos);
}
}
self.prev_chunk_pos = Some(chunk_pos);