minor name changes
This commit is contained in:
@@ -105,7 +105,7 @@ impl CameraController {
|
||||
|
||||
// Movement amount
|
||||
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
|
||||
if self.movement.fwd && cam_forward.magnitude() > amount { self.cam_position += cam_forward.normalize() * amount; }
|
||||
|
||||
+5
-5
@@ -29,8 +29,8 @@ impl App {
|
||||
|
||||
|
||||
let timer = Instant::now();
|
||||
for x in 0..32 {
|
||||
for z in 0..32 {
|
||||
for x in 0..64 {
|
||||
for z in 0..64 {
|
||||
let pos = &Point3{x,y:0,z};
|
||||
let block = app.world.gen_block(pos);
|
||||
content.write(pos, block);
|
||||
@@ -38,9 +38,9 @@ impl App {
|
||||
}
|
||||
println!("Generated in {}", timer.elapsed().as_secs_f32());
|
||||
|
||||
// let timer = Instant::now();
|
||||
// app.world.save();
|
||||
// println!("Saved in {}", timer.elapsed().as_secs_f32());
|
||||
let timer = Instant::now();
|
||||
app.world.save();
|
||||
println!("Saved in {}", timer.elapsed().as_secs_f32());
|
||||
|
||||
// let timer = Instant::now();
|
||||
// app.world.load();
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -112,7 +112,8 @@ impl Content {
|
||||
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 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
|
||||
queue.write_texture(
|
||||
|
||||
Reference in New Issue
Block a user