working bricks ray traversing

This commit is contained in:
Piotrek
2021-04-23 15:27:04 +02:00
parent 8368545e6c
commit af5c2f2532
5 changed files with 66 additions and 15 deletions
+4 -2
View File
@@ -2,7 +2,7 @@ use wgpu::util::DeviceExt;
use std::convert::TryInto;
const BRICK_SIZE : usize = 32; // 32x32x32 brick size
const BRICK_NUM : usize = 1; // 64 bricks in texture
const BRICK_NUM : usize = 2; // x bricks in texture
const BRICK_LEN : usize = BRICK_SIZE*BRICK_SIZE*BRICK_SIZE;
const DATA_LEN : usize = BRICK_LEN * BRICK_NUM;
@@ -98,9 +98,11 @@ impl BrickBuffer {
for y in 0..16 {
for z in 0..32 {
bricks.set(0, x, y, z, 1);
bricks.set(1, y, x, z, 1);
}
}
}
bricks.set(0, 0, 0, 0, 0);
// Done
Self { bricks, texture, size, bind_layout, bind_group }
@@ -116,7 +118,7 @@ impl BrickBuffer {
let brick_offset = offset*BRICK_LEN;
let brick_bytes : [u8;BRICK_LEN] = self.bricks.data[brick_offset..brick_offset+BRICK_LEN].try_into().unwrap();
let brick_size = wgpu::Extent3d{ width: BRICK_SIZE as u32, height: BRICK_SIZE as u32, depth: BRICK_SIZE as u32 };
let brick_origin = wgpu::Origin3d{ x:0, y:0, z: offset as u32 };
let brick_origin = wgpu::Origin3d{ x:0, y:0, z: (offset*BRICK_SIZE) as u32 };
// Write
queue.write_texture(
+1 -1
View File
@@ -70,7 +70,7 @@ impl NodeBuffer {
// Data
let mut nodes : [u32; NUM_NODES] = [Default::default(); NUM_NODES];
nodes[0] = 1;
nodes[0] = 2;
// Done
Self { nodes, texture, size, bind_layout, bind_group }