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