Loading chunks in radius instead of by travel direction, bugged (not reloading chunks)
This commit is contained in:
+15
-1
@@ -51,12 +51,26 @@ impl World {
|
||||
*/
|
||||
pub fn load_chunk(&mut self, pos: Vector3<i32>) {
|
||||
if let Some(chunk) = self.chunks.get_mut(&pos) {
|
||||
chunk.dirty = true;
|
||||
if !chunk.loaded {
|
||||
println!("Chunk {:?} exists but not loaded! Loading now", pos);
|
||||
chunk.dirty = true;
|
||||
}
|
||||
} else {
|
||||
self.loader.load(pos);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*/
|
||||
pub fn unload_chunk(&mut self, pos: Vector3<i32>) {
|
||||
if let Some(chunk) = self.chunks.get_mut(&pos) {
|
||||
chunk.loaded = false;
|
||||
chunk.dirty = false;
|
||||
// TODO: Mark chunk as "to be unloaded" and send it to renderer for freeing resources
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Loads metadata
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user