Method for shifting world nodes texture
This commit is contained in:
@@ -101,7 +101,6 @@ impl Content {
|
||||
ContentStats { node_tex_size, block_tex_size, block_tex_used, block_count, block_used }
|
||||
}
|
||||
|
||||
#[allow(unused)]
|
||||
pub fn write(&mut self, queue: &wgpu::Queue, block_pos: &Vector3<i32>, block: &WorldBlock) {
|
||||
|
||||
// Get node
|
||||
@@ -139,6 +138,37 @@ impl Content {
|
||||
);
|
||||
}
|
||||
|
||||
pub fn shift(&mut self, offset: &Vector3<i32>) {
|
||||
let timer = Instant::now();
|
||||
let mut result = vec![0_u32; self.node_buffer.len()].into_boxed_slice();
|
||||
let ox = offset.x as usize;
|
||||
let oy = offset.y as usize;
|
||||
let oz = offset.z as usize;
|
||||
|
||||
for x0 in 0..NODE_TEX_SIZE {
|
||||
let x1 = x0+ox;
|
||||
if x1 >= NODE_TEX_SIZE { continue; }
|
||||
|
||||
for y0 in 0..NODE_TEX_SIZE {
|
||||
let y1 = y0+oy;
|
||||
if y1 >= NODE_TEX_SIZE { continue; }
|
||||
|
||||
for z0 in 0..NODE_TEX_SIZE {
|
||||
let z1 = z0+oz;
|
||||
if z1 >= NODE_TEX_SIZE { continue; }
|
||||
|
||||
let idx0 = x0 + NODE_TEX_SIZE * (y0 + NODE_TEX_SIZE * z0);
|
||||
let idx1 = x1 + NODE_TEX_SIZE * (y1 + NODE_TEX_SIZE * z1);
|
||||
result[idx1] = self.node_buffer[idx0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.node_buffer = result;
|
||||
self.node_dirty = true;
|
||||
println!("Shifted in {} ms", timer.elapsed().as_millis());
|
||||
}
|
||||
|
||||
fn write_nodes(&mut self, queue: &wgpu::Queue, z: usize) {
|
||||
// Convert u32 node buffer to u8
|
||||
let node_origin = wgpu::Origin3d{ x:0, y: 0, z: z as u32 };
|
||||
|
||||
Reference in New Issue
Block a user