mirror of
https://github.com/griffi-gh/kubi.git
synced 2024-12-22 20:08:20 -06:00
skip drawing empty chunks
This commit is contained in:
parent
941f563059
commit
9ed19bfc0e
|
@ -73,6 +73,7 @@ pub fn draw_world(
|
|||
if let Some(key) = chunk.mesh_index {
|
||||
let mesh = meshes.get(key).expect("Mesh index pointing to nothing");
|
||||
let world_position = (position.as_vec3() * CHUNK_SIZE as f32).to_array();
|
||||
if mesh.index_buffer.len() > 0 { //maybe this is a bit hacky?
|
||||
target.0.draw(
|
||||
&mesh.vertex_buffer,
|
||||
&mesh.index_buffer,
|
||||
|
@ -87,4 +88,5 @@ pub fn draw_world(
|
|||
).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,19 +6,13 @@ use super::{
|
|||
|
||||
pub fn generate_world(position: IVec3, _seed: u32) -> BlockData {
|
||||
let mut blocks = Box::new([[[Block::Air; CHUNK_SIZE]; CHUNK_SIZE]; CHUNK_SIZE]);
|
||||
//TODO actual world generation
|
||||
if position.y == -1 {
|
||||
for x in 0..CHUNK_SIZE {
|
||||
for z in 0..CHUNK_SIZE {
|
||||
blocks[x][0][z] = Block::Grass;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
blocks[0][0][0] = Block::Stone;
|
||||
blocks[1][0][0] = Block::Stone;
|
||||
blocks[0][1][0] = Block::Stone;
|
||||
blocks[0][2][0] = Block::Stone;
|
||||
blocks[0][0][1] = Block::Stone;
|
||||
}
|
||||
//TODO actual world generation
|
||||
blocks
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue