No mod in structure table

This commit is contained in:
2026-11-09 21:14:59 +01:00
parent 918eb97342
commit a39256a0f1
9 changed files with 93 additions and 47 deletions
+5
View File
@@ -173,6 +173,8 @@ struct Immediates
chunk_width: u32,
chunk_height: u32,
chunk_alt: u32,
table_base_slot: [u32; 3],
}
#[derive(Debug, Clone, Copy, Zeroable, Pod)]
@@ -1130,6 +1132,7 @@ impl State
&[],
);
renderpass.set_bind_group(2, Some(&surface_bg), &[]);
let table_base_slot = self.structure_table.lock().base_slot();
let imm = [Immediates {
view_proj: self.camera.view_proj().inverse(),
cam_pos: self.camera.position,
@@ -1143,6 +1146,8 @@ impl State
chunk_width: self.terrain_width as u32,
chunk_height: self.terrain_height as u32,
chunk_alt: self.terrain_alt as u32,
table_base_slot,
}];
renderpass.set_immediates(0, unsafe { as_raw_bytes(&imm) });
renderpass.dispatch_workgroups(
+15
View File
@@ -191,6 +191,21 @@ impl ToroidalStructureTable
(x as isize, y as isize, z as isize)
}
/// Canonical table slot of the visible block's minimum corner.
///
/// The render shader uses this to advance its table slot incrementally, so
/// the ray traversal does not have to perform an integer modulo per chunk.
pub fn base_slot(&self) -> [u32; 3]
{
let (ox, oy, oz) = self.current_offset;
let (ex, ey, ez) = self.extent;
[
ox.rem_euclid(ex as isize) as u32,
oy.rem_euclid(ey as isize) as u32,
oz.rem_euclid(ez as isize) as u32,
]
}
fn position_for_offset(
extent: (usize, usize, usize),
structure_id: usize,