Fix toroidal structure table
This commit is contained in:
+5
-2
@@ -193,8 +193,6 @@ impl State
|
||||
required_features: Features::IMMEDIATES
|
||||
| Features::SHADER_EARLY_DEPTH_TEST
|
||||
| Features::TIMESTAMP_QUERY
|
||||
| Features::SHADER_I16
|
||||
| Features::SHADER_F16
|
||||
| Features::TIMESTAMP_QUERY_INSIDE_ENCODERS
|
||||
| Features::TIMESTAMP_QUERY_INSIDE_PASSES
|
||||
| Features::STORAGE_RESOURCE_BINDING_ARRAY
|
||||
@@ -1151,6 +1149,11 @@ impl State
|
||||
self.insert_profile
|
||||
.lock()
|
||||
.show_flamegraph("second_profile".into(), q, ui);
|
||||
|
||||
ui.label(format!(
|
||||
"{:.2} {:.2} {:.2}",
|
||||
self.camera.position.x, self.camera.position.y, self.camera.position.z
|
||||
));
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
+1
-14
@@ -515,14 +515,6 @@ where
|
||||
p[0].fract()
|
||||
}
|
||||
|
||||
let col_r = hash([
|
||||
chunk_pos.0 as f32 * 93487.,
|
||||
912873. + 348. * chunk_pos.1 as f32,
|
||||
0.,
|
||||
]);
|
||||
let col_g = hash([chunk_pos.1 as f32 * 12093., 92837. * chunk_pos.0 as f32, 0.]);
|
||||
let col_b = hash([0., 981882. * chunk_pos.0 as f32, 9092. * chunk_pos.1 as f32]);
|
||||
|
||||
// let sdf = |x: f32, y: f32, z: f32| {
|
||||
// Vec3::new((x % 1024.) - 512., (y % 1024.) - 512., (z % 1024.) - 512.).length() - 512.
|
||||
// };
|
||||
@@ -676,12 +668,7 @@ where
|
||||
// alpha,
|
||||
// ));
|
||||
children.push(ChildInformation::new(subdivided, subdivided || alpha != 0.));
|
||||
children_color.push(Color(
|
||||
color + random::<f32>() * 0.02 + col_r,
|
||||
color + col_g,
|
||||
color + col_b,
|
||||
alpha,
|
||||
));
|
||||
children_color.push(Color(color + random::<f32>() * 0.02, color, color, alpha));
|
||||
children_normals.push((normal.x, normal.y, normal.z));
|
||||
//children_color.push(Color(normal.x, normal.y, normal.z, alpha));
|
||||
}
|
||||
|
||||
+16
-18
@@ -131,34 +131,32 @@ impl ToroidalStructureTable
|
||||
/// Given the structure id, returns the position of the requesting chunk
|
||||
pub fn get_request_position(&self, structure_id: u32) -> (isize, isize, isize)
|
||||
{
|
||||
// Where the block offset lies in the tore
|
||||
let offset_tore_x = self.current_offset.0.rem_euclid(self.extent.0 as isize);
|
||||
let offset_tore_y = self.current_offset.1.rem_euclid(self.extent.1 as isize);
|
||||
let offset_tore_z = self.current_offset.2.rem_euclid(self.extent.2 as isize);
|
||||
let (ex, ey, ez) = (
|
||||
self.extent.0 as isize,
|
||||
self.extent.1 as isize,
|
||||
self.extent.2 as isize,
|
||||
);
|
||||
let id = structure_id as isize;
|
||||
|
||||
// Local coordinate within the fixed table
|
||||
let x = structure_id as isize % self.extent.0 as isize;
|
||||
let z = (structure_id as isize / self.extent.0 as isize) % self.extent.2 as isize;
|
||||
let y = structure_id as isize / (self.extent.0 * self.extent.2) as isize;
|
||||
let sx = id % ex;
|
||||
let sz = (id / ex) % ez;
|
||||
let sy = id / (ex * ez);
|
||||
|
||||
// Coordinates in the tore, centered on the offset
|
||||
let x = (x - offset_tore_x).rem_euclid(self.extent.0 as isize);
|
||||
let y = (y - offset_tore_y).rem_euclid(self.extent.1 as isize);
|
||||
let z = (z - offset_tore_z).rem_euclid(self.extent.2 as isize);
|
||||
let (ox, oy, oz) = self.current_offset;
|
||||
|
||||
(
|
||||
x + self.current_offset.0,
|
||||
y + self.current_offset.1,
|
||||
z + self.current_offset.2,
|
||||
ox + (sx - ox).rem_euclid(ex),
|
||||
oy + (sy - oy).rem_euclid(ey),
|
||||
oz + (sz - oz).rem_euclid(ez),
|
||||
)
|
||||
}
|
||||
|
||||
fn offset_from_center(extent: (usize, usize, usize), position: Vec3) -> (isize, isize, isize)
|
||||
{
|
||||
(
|
||||
position.x as isize - (extent.0 as isize / 2),
|
||||
position.y as isize - (extent.1 as isize / 2),
|
||||
position.z as isize - (extent.2 as isize / 2),
|
||||
position.x.floor() as isize - (extent.0 as isize / 2),
|
||||
position.y.floor() as isize - (extent.1 as isize / 2),
|
||||
position.z.floor() as isize - (extent.2 as isize / 2),
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -34,13 +34,7 @@ fn invalidate_new(@builtin(global_invocation_id) gid: vec3<u32>)
|
||||
|
||||
fn get_position(block_position: vec3<i32>, offset: vec3<i32>) -> vec3<i32>
|
||||
{
|
||||
// Tore origin within block
|
||||
let origin = imodv(offset, vec3<i32>(immediates.extent));
|
||||
|
||||
// Position in tore coordinate
|
||||
let tore_position = imodv((block_position - origin), vec3<i32>(immediates.extent));
|
||||
|
||||
return tore_position + offset;
|
||||
return offset + imodv((block_position - offset), vec3<i32>(immediates.extent));
|
||||
}
|
||||
|
||||
fn imod(x: i32, n: i32) -> i32 {
|
||||
|
||||
Reference in New Issue
Block a user