mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-11-22 14:58:44 -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 const CHUNK_HEIGHT: usize = 255;
|
||||||
|
|
||||||
pub enum ChunkState {
|
pub enum ChunkState {
|
||||||
AwaitsLoading,
|
Nothing,
|
||||||
Loaded,
|
|
||||||
AwaitsMesh,
|
|
||||||
Rendered,
|
|
||||||
AwaitsUnload
|
|
||||||
}
|
|
||||||
|
|
||||||
pub enum DesiredState {
|
|
||||||
Unloaded,
|
|
||||||
Loaded,
|
Loaded,
|
||||||
Rendered,
|
Rendered,
|
||||||
}
|
}
|
||||||
|
@ -30,7 +22,7 @@ pub struct Chunk {
|
||||||
pub block_data: Option<ChunkData>,
|
pub block_data: Option<ChunkData>,
|
||||||
pub vertex_buffer: Option<ChunkMesh>,
|
pub vertex_buffer: Option<ChunkMesh>,
|
||||||
pub state: ChunkState,
|
pub state: ChunkState,
|
||||||
pub desired: DesiredState,
|
pub desired: ChunkState,
|
||||||
}
|
}
|
||||||
impl Chunk {
|
impl Chunk {
|
||||||
pub fn new(position: IVec2) -> Self {
|
pub fn new(position: IVec2) -> Self {
|
||||||
|
@ -38,8 +30,8 @@ impl Chunk {
|
||||||
position,
|
position,
|
||||||
block_data: None,
|
block_data: None,
|
||||||
vertex_buffer: None,
|
vertex_buffer: None,
|
||||||
state: ChunkState::AwaitsLoading,
|
state: ChunkState::Nothing,
|
||||||
desired: DesiredState::Loaded,
|
desired: ChunkState::Nothing,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
mem
|
mem
|
||||||
};
|
};
|
||||||
use super::chunk::{ChunkData, Chunk, DesiredState};
|
use super::chunk::{Chunk, ChunkData, ChunkState};
|
||||||
|
|
||||||
mod world_gen;
|
mod world_gen;
|
||||||
mod mesh_gen;
|
mod mesh_gen;
|
||||||
|
@ -38,7 +38,7 @@ impl WorldThreading {
|
||||||
log::warn!("load: discarded {}, reason: chunk no longer exists", position);
|
log::warn!("load: discarded {}, reason: chunk no longer exists", position);
|
||||||
return false
|
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);
|
log::warn!("load: discarded {}, reason: state undesired", position);
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,9 @@ impl WorldThreading {
|
||||||
log::info!("load: done {}", position);
|
log::info!("load: done {}", position);
|
||||||
let handle = mem::take(handle).unwrap();
|
let handle = mem::take(handle).unwrap();
|
||||||
let data = handle.join().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
|
false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue