This commit is contained in:
Piotrek
2021-05-06 15:38:51 +02:00
parent 5b1ca38d75
commit 45362afbf4
7 changed files with 26 additions and 30 deletions
+9 -4
View File
@@ -89,18 +89,23 @@ impl Content {
// Allocate new block
if value == 0 {
value = self.block_freeidx;
value = self.block_freeidx + 1;
self.node_buffer[index] = value as u32;
self.block_freeidx += 1;
self.block_freeidx = value;
//println!("Alloc: {}", value);
}
//println!("Index: {} Value: {}", index, value);
// Calculate position in block texture
let y = (value % BLOCK_TEX_SIZE * BLOCK_SIZE) as u32;
let z = (value / BLOCK_TEX_SIZE * BLOCK_SIZE) as u32;
let y = ((value-1) % BLOCK_TEX_SIZE * BLOCK_SIZE) as u32;
let z = ((value-1) / BLOCK_TEX_SIZE * BLOCK_SIZE) as u32;
let block_origin = wgpu::Origin3d{ x:0, y, z };
let block_size = wgpu::Extent3d{ width: BLOCK_SIZE as u32, height: BLOCK_SIZE as u32, depth: BLOCK_SIZE as u32 };
let block_bytes : [u8;BLOCK_SIZE*BLOCK_SIZE*BLOCK_SIZE] = block.materials.try_into().unwrap();
//println!("Y: {} Z: {}", y, z);
// Write block
queue.write_texture(
wgpu::TextureCopyView { texture: &self.block_texture, mip_level: 0, origin: block_origin }, &block_bytes,