This commit is contained in:
griffi-gh 2023-01-16 22:35:17 +01:00
parent 932c2086f0
commit 09d08264d5
2 changed files with 7 additions and 2 deletions

View file

@ -59,19 +59,22 @@ impl World {
//State up/downgrades are handled here!
self.chunks.retain(|&position, chunk| {
match chunk.desired {
// Any => Unload downgrade
ChunkState::Unload => {
return false
},
// Any => Nothing downgrade
ChunkState::Nothing => {
chunk.block_data = None;
chunk.vertex_buffer = None;
chunk.state = ChunkState::Nothing;
},
// Nothing => Loading => Loaded upgrade
ChunkState::Loaded if matches!(chunk.state, ChunkState::Nothing) => {
//FIXME this keeps loading!
self.thread.queue_load(position);
},
ChunkState::Loaded if matches!(chunk.state, ChunkState::Rendered) => {
//Render => Loaded downgrade
ChunkState::Loaded if matches!(chunk.state, ChunkState::Rendering | ChunkState::Rendered) => {
chunk.vertex_buffer = None;
chunk.state = ChunkState::Loaded;
},

View file

@ -11,7 +11,9 @@ pub const CHUNK_HEIGHT: usize = 255;
pub enum ChunkState {
Unload,
Nothing,
Loading,
Loaded,
Rendering,
Rendered,
}