diff --git a/src/world/chunk.rs b/src/world/chunk.rs index abfa45e..d47b680 100644 --- a/src/world/chunk.rs +++ b/src/world/chunk.rs @@ -1 +1,41 @@ -pub struct Chunk; +use glam::IVec3; +use glium::{VertexBuffer, IndexBuffer}; +use super::block::Block; + +pub const CHUNK_SIZE: usize = 32; + +type ChunkBlockData = Box<[[[Block; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]>; + +pub struct ChunkData { + pub blocks: ChunkBlockData, + pub has_renderable_blocks: bool, +} +impl ChunkData { + pub fn update_metadata(&mut self) { + todo!() + } +} + +pub struct ChunkMesh { + pub is_dirty: bool, + pub vertex_buffer: VertexBuffer, + pub index_buffer: IndexBuffer, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)] +pub enum ChunkState { + ToUnload, //desired only + Nothing, + Loading, //current only + Loaded, + Meshing, //current only + Rendered +} + +pub struct Chunk { + pub position: IVec3, + pub block_data: Option, + pub mesh: Option, + pub current_state: ChunkState, + pub desired_state: ChunkState, +}