mesh_to_sdf
mesh_to_sdf copied to clipboard
generate_grid_sdf with Raycast crashes when bbox does not countain the mesh
// x.
for y in min_cell[1]..=max_cell[1] {
for z in min_cell[2]..=max_cell[2] {
let cell = [0, y, z];
let cell_pos = grid.get_cell_center(&cell);
raycasts_done += 1;
if let Some(distance) = geo::ray_triangle_intersection_aligned(
&cell_pos,
[a, b, c],
geo::GridAlign::X,
) {
let cell_count = distance / grid.get_cell_size().x();
let cell_count = cell_count.floor() as usize;
for x in 0..=cell_count {
let cell = [x, y, z];
let cell_idx = grid.get_cell_idx(&cell);
intersections[cell_idx][0] += 1; // <--- HERE, for all three x, y, z loops
}
}
}
}
does not check if the triangle is within the bounding box.