mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-10 01:28:41 -06:00
uwu
This commit is contained in:
parent
77f388dd75
commit
2c86971d18
|
@ -9,15 +9,7 @@ pub const CHUNK_SIZE: usize = 16;
|
|||
pub const CHUNK_HEIGHT: usize = 255;
|
||||
|
||||
pub enum ChunkState {
|
||||
AwaitsLoading,
|
||||
Loaded,
|
||||
AwaitsMesh,
|
||||
Rendered,
|
||||
AwaitsUnload
|
||||
}
|
||||
|
||||
pub enum DesiredState {
|
||||
Unloaded,
|
||||
Nothing,
|
||||
Loaded,
|
||||
Rendered,
|
||||
}
|
||||
|
@ -30,7 +22,7 @@ pub struct Chunk {
|
|||
pub block_data: Option<ChunkData>,
|
||||
pub vertex_buffer: Option<ChunkMesh>,
|
||||
pub state: ChunkState,
|
||||
pub desired: DesiredState,
|
||||
pub desired: ChunkState,
|
||||
}
|
||||
impl Chunk {
|
||||
pub fn new(position: IVec2) -> Self {
|
||||
|
@ -38,8 +30,8 @@ impl Chunk {
|
|||
position,
|
||||
block_data: None,
|
||||
vertex_buffer: None,
|
||||
state: ChunkState::AwaitsLoading,
|
||||
desired: DesiredState::Loaded,
|
||||
state: ChunkState::Nothing,
|
||||
desired: ChunkState::Nothing,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
|||
collections::HashMap,
|
||||
mem
|
||||
};
|
||||
use super::chunk::{ChunkData, Chunk, DesiredState};
|
||||
use super::chunk::{Chunk, ChunkData, ChunkState};
|
||||
|
||||
mod world_gen;
|
||||
mod mesh_gen;
|
||||
|
@ -38,7 +38,7 @@ impl WorldThreading {
|
|||
log::warn!("load: discarded {}, reason: chunk no longer exists", position);
|
||||
return false
|
||||
}
|
||||
if !matches!(chunks.get(position).unwrap().desired, DesiredState::Loaded | DesiredState::Rendered) {
|
||||
if !matches!(chunks.get(position).unwrap().desired, ChunkState::Loaded | ChunkState::Rendered) {
|
||||
log::warn!("load: discarded {}, reason: state undesired", position);
|
||||
return false
|
||||
}
|
||||
|
@ -49,7 +49,9 @@ impl WorldThreading {
|
|||
log::info!("load: done {}", position);
|
||||
let handle = mem::take(handle).unwrap();
|
||||
let data = handle.join().unwrap();
|
||||
chunks.get_mut(position).unwrap().block_data = Some(data);
|
||||
let chunk = chunks.get_mut(position).unwrap();
|
||||
chunk.block_data = Some(data);
|
||||
chunk.state = ChunkState::Loaded;
|
||||
false
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue