minor name changes

This commit is contained in:
Piotrek
2021-05-09 18:48:06 +02:00
parent 0e53810fbd
commit 3a45d4e0de
4 changed files with 17 additions and 15 deletions
+1 -1
View File
@@ -105,7 +105,7 @@ impl CameraController {
// Movement amount // Movement amount
let mut amount = delta_time * self.movement.speed; let mut amount = delta_time * self.movement.speed;
if self.movement.shift { amount *= 2.0; } if self.movement.shift { amount *= 4.0; }
// Forward and backwards // Forward and backwards
if self.movement.fwd && cam_forward.magnitude() > amount { self.cam_position += cam_forward.normalize() * amount; } if self.movement.fwd && cam_forward.magnitude() > amount { self.cam_position += cam_forward.normalize() * amount; }
+5 -5
View File
@@ -29,8 +29,8 @@ impl App {
let timer = Instant::now(); let timer = Instant::now();
for x in 0..32 { for x in 0..64 {
for z in 0..32 { for z in 0..64 {
let pos = &Point3{x,y:0,z}; let pos = &Point3{x,y:0,z};
let block = app.world.gen_block(pos); let block = app.world.gen_block(pos);
content.write(pos, block); content.write(pos, block);
@@ -38,9 +38,9 @@ impl App {
} }
println!("Generated in {}", timer.elapsed().as_secs_f32()); println!("Generated in {}", timer.elapsed().as_secs_f32());
// let timer = Instant::now(); let timer = Instant::now();
// app.world.save(); app.world.save();
// println!("Saved in {}", timer.elapsed().as_secs_f32()); println!("Saved in {}", timer.elapsed().as_secs_f32());
// let timer = Instant::now(); // let timer = Instant::now();
// app.world.load(); // app.world.load();
+9 -8
View File
@@ -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 // Split world space to chunk and block space
let ch_pos = block_pos / chunk::SIZE as u32; let ch_pos = block_wpos / chunk::SIZE as u32;
let bl_pos = block_pos % chunk::SIZE as u32; let bl_pos = block_wpos % chunk::SIZE as u32;
// Create chunk if does not exist // Create chunk if does not exist
if let None = self.chunks.get(&ch_pos) { 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 // Generate block for chunk
let chunk = self.chunks.get_mut(&ch_pos).unwrap(); let chunk = self.chunks.get_mut(&ch_pos).unwrap();
let block = chunk.get_block(&bl_pos); let block = chunk.get_block(&bl_pos);
WorldGen::generate(&bl_pos, block); WorldGen::generate(&block_wpos, block);
block block
} }
#[allow(unused)] #[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 // Split world space to chunk and block space
let ch_pos = block_pos / chunk::SIZE as u32; let ch_pos = block_wpos / chunk::SIZE as u32;
let bl_pos = block_pos % chunk::SIZE as u32; let bl_pos = block_wpos % chunk::SIZE as u32;
// Return block if exists // Return block if exists
if let Some(chunk) = self.chunks.get_mut(&ch_pos) { if let Some(chunk) = self.chunks.get_mut(&ch_pos) {
return Some(chunk.get_block(&bl_pos)); return Some(chunk.get_block(&bl_pos));
+2 -1
View File
@@ -112,7 +112,8 @@ impl Content {
let node_origin = wgpu::Origin3d{ x:0, y: 0, z: z as u32 }; let node_origin = wgpu::Origin3d{ x:0, y: 0, z: z as u32 };
let node_size = wgpu::Extent3d { width: NODE_TEX_SIZE as u32, height: NODE_TEX_SIZE as u32, depth: 1 }; let node_size = wgpu::Extent3d { width: NODE_TEX_SIZE as u32, height: NODE_TEX_SIZE as u32, depth: 1 };
let mut node_bytes = [0_u8; NODE_TEX_SIZE_SQ*4]; let mut node_bytes = [0_u8; NODE_TEX_SIZE_SQ*4];
LittleEndian::write_u32_into(&self.node_buffer[NODE_TEX_SIZE_SQ*z..NODE_TEX_SIZE_SQ*(z+1)], &mut node_bytes); let offset = NODE_TEX_SIZE_SQ*z;
LittleEndian::write_u32_into(&self.node_buffer[offset..offset+NODE_TEX_SIZE_SQ], &mut node_bytes);
// Write nodes // Write nodes
queue.write_texture( queue.write_texture(