Don't skip generation of some chunks

This commit is contained in:
Jarrod Doyle 2023-05-06 12:42:47 +01:00
parent ed46752c92
commit 95dd469f7a
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
1 changed files with 86 additions and 90 deletions

View File

@ -161,12 +161,6 @@ impl BrickmapManager {
let chunk_y = data[i * 4 + 1]; let chunk_y = data[i * 4 + 1];
let chunk_z = data[i * 4 + 2]; let chunk_z = data[i * 4 + 2];
let chunk_idx = (chunk_x
+ chunk_y * world_dims[0]
+ chunk_z * world_dims[0] * world_dims[1]) as usize;
if chunk_idx % 3 == 0 || chunk_idx % 5 == 0 || chunk_idx % 7 == 0 {
self.update_brickgrid_element(context, chunk_idx, 0)
} else {
// Generate full data // Generate full data
let mut chunk = [(false, 0u32); 512]; let mut chunk = [(false, 0u32); 512];
for z in 0..8 { for z in 0..8 {
@ -231,6 +225,10 @@ impl BrickmapManager {
bitmask_data[offset + 1] = ((entry >> 32) & 0xFFFFFFFF).try_into().unwrap(); bitmask_data[offset + 1] = ((entry >> 32) & 0xFFFFFFFF).try_into().unwrap();
} }
let chunk_idx = (chunk_x
+ chunk_y * world_dims[0]
+ chunk_z * world_dims[0] * world_dims[1]) as usize;
// Update the brickgrid index // Update the brickgrid index
let brickgrid_element = ((self.brickmap_cache_idx as u32) << 8) + 4; let brickgrid_element = ((self.brickmap_cache_idx as u32) << 8) + 4;
self.update_brickgrid_element(context, chunk_idx, brickgrid_element); self.update_brickgrid_element(context, chunk_idx, brickgrid_element);
@ -248,8 +246,7 @@ impl BrickmapManager {
// Update the brickmap // Update the brickmap
self.brickmap_cache[self.brickmap_cache_idx].bitmask = bitmask_data; self.brickmap_cache[self.brickmap_cache_idx].bitmask = bitmask_data;
self.brickmap_cache[self.brickmap_cache_idx].shading_table_offset = self.brickmap_cache[self.brickmap_cache_idx].shading_table_offset = shading_idx as u32;
shading_idx as u32;
context.queue.write_buffer( context.queue.write_buffer(
&self.brickmap_buffer, &self.brickmap_buffer,
(72 * self.brickmap_cache_idx) as u64, (72 * self.brickmap_cache_idx) as u64,
@ -257,7 +254,6 @@ impl BrickmapManager {
); );
self.brickmap_cache_idx += 1; self.brickmap_cache_idx += 1;
} }
}
// Reset the request count on the gpu buffer // Reset the request count on the gpu buffer
let data = &[0, 0, 0, 0]; let data = &[0, 0, 0, 0];