minor name changes
This commit is contained in:
@@ -108,26 +108,27 @@ impl World {
|
||||
|
||||
}
|
||||
|
||||
pub fn gen_block(&mut self, block_pos: &Point3<u32>) -> &WorldBlock {
|
||||
pub fn gen_block(&mut self, block_wpos: &Point3<u32>) -> &WorldBlock {
|
||||
// Split world space to chunk and block space
|
||||
let ch_pos = block_pos / chunk::SIZE as u32;
|
||||
let bl_pos = block_pos % chunk::SIZE as u32;
|
||||
let ch_pos = block_wpos / chunk::SIZE as u32;
|
||||
let bl_pos = block_wpos % chunk::SIZE as u32;
|
||||
// Create chunk if does not exist
|
||||
if let None = self.chunks.get(&ch_pos) {
|
||||
self.chunks.insert(block_pos.clone(), WorldChunk::new());
|
||||
self.chunks.insert(ch_pos.clone(), WorldChunk::new());
|
||||
println!("Alloc chunk [{}, {}, {}]", ch_pos.x, ch_pos.y, ch_pos.z);
|
||||
}
|
||||
// Generate block for chunk
|
||||
let chunk = self.chunks.get_mut(&ch_pos).unwrap();
|
||||
let block = chunk.get_block(&bl_pos);
|
||||
WorldGen::generate(&bl_pos, block);
|
||||
WorldGen::generate(&block_wpos, block);
|
||||
block
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn get_block(&mut self, block_pos: &Point3<u32>) -> Option<&WorldBlock> {
|
||||
pub fn get_block(&mut self, block_wpos: &Point3<u32>) -> Option<&WorldBlock> {
|
||||
// Split world space to chunk and block space
|
||||
let ch_pos = block_pos / chunk::SIZE as u32;
|
||||
let bl_pos = block_pos % chunk::SIZE as u32;
|
||||
let ch_pos = block_wpos / chunk::SIZE as u32;
|
||||
let bl_pos = block_wpos % chunk::SIZE as u32;
|
||||
// Return block if exists
|
||||
if let Some(chunk) = self.chunks.get_mut(&ch_pos) {
|
||||
return Some(chunk.get_block(&bl_pos));
|
||||
|
||||
Reference in New Issue
Block a user