fixed negative distance in voxel traversing
This commit is contained in:
@@ -102,6 +102,7 @@ impl BrickBuffer {
|
||||
for z in 0..32 {
|
||||
let value = if rng.gen::<f32>()> 0.99 { 1 } else { 0 };
|
||||
bricks.set(0, x, y, z, value);
|
||||
bricks.set(1, x, 0, z, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,20 +92,21 @@ impl NodeBuffer {
|
||||
// Data
|
||||
let mut nodes = NodeData::new();
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
for x in 0..WORLD_SIZE {
|
||||
for y in 0..WORLD_SIZE {
|
||||
for z in 0..WORLD_SIZE {
|
||||
let value = if rng.gen::<f32>()> 0.5 { 1 } else { 0 };
|
||||
nodes.set(x, y, z, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
// for i in 0..WORLD_SIZE {
|
||||
// nodes.set(i, 0, 0, 1);
|
||||
// nodes.set(0, i, 0, 1);
|
||||
// nodes.set(0, 0, i, 1);
|
||||
// let mut rng = rand::thread_rng();
|
||||
// for x in 0..WORLD_SIZE {
|
||||
// for y in 0..WORLD_SIZE {
|
||||
// for z in 0..WORLD_SIZE {
|
||||
// let value = if rng.gen::<f32>()> 0.5 { 1 } else { 0 };
|
||||
// nodes.set(x, y, z, value);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
for i in 0..WORLD_SIZE {
|
||||
nodes.set(i, 0, 0, 1);
|
||||
nodes.set(0, i, 0, 1);
|
||||
nodes.set(0, 0, i, 1);
|
||||
}
|
||||
nodes.set(0, 0, 0, 2);
|
||||
|
||||
// Done
|
||||
Self { nodes, texture, size, bind_layout, bind_group }
|
||||
|
||||
@@ -7,7 +7,8 @@ use wgpu::util::DeviceExt;
|
||||
pub struct UniformValues {
|
||||
view_inv: [[f32; 4]; 4],
|
||||
proj_inv: [[f32; 4]; 4],
|
||||
cam_pos: [f32; 3]
|
||||
cam_pos: [f32; 3],
|
||||
time: f32
|
||||
}
|
||||
|
||||
impl UniformValues {
|
||||
@@ -16,10 +17,11 @@ impl UniformValues {
|
||||
Self::default()
|
||||
}
|
||||
|
||||
pub fn update(&mut self, camera: &Camera) {
|
||||
pub fn update(&mut self, camera: &Camera, time: f32) {
|
||||
self.view_inv = camera.view_matrix().invert().unwrap().into();
|
||||
self.proj_inv = camera.proj_matrix().invert().unwrap().into();
|
||||
self.cam_pos = camera.position.into();
|
||||
self.time = time;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user