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! //State up/downgrades are handled here!
self.chunks.retain(|&position, chunk| { self.chunks.retain(|&position, chunk| {
match chunk.desired { match chunk.desired {
// Any => Unload downgrade
ChunkState::Unload => { ChunkState::Unload => {
return false return false
}, },
// Any => Nothing downgrade
ChunkState::Nothing => { ChunkState::Nothing => {
chunk.block_data = None; chunk.block_data = None;
chunk.vertex_buffer = None; chunk.vertex_buffer = None;
chunk.state = ChunkState::Nothing; chunk.state = ChunkState::Nothing;
}, },
// Nothing => Loading => Loaded upgrade
ChunkState::Loaded if matches!(chunk.state, ChunkState::Nothing) => { ChunkState::Loaded if matches!(chunk.state, ChunkState::Nothing) => {
//FIXME this keeps loading!
self.thread.queue_load(position); 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.vertex_buffer = None;
chunk.state = ChunkState::Loaded; chunk.state = ChunkState::Loaded;
}, },

View file

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