Skip to main content

signed_distances

Function signed_distances 

Source
pub fn signed_distances(
    mesh_b: &Mesh,
    bvh_b: &Bvh,
    sign: &SignData,
    points_in_b: &[[f32; 3]],
    max_distance: f32,
    out: &mut [f32],
) -> Result<()>
Expand description

Signed distances from points_in_b (in mesh B’s local coordinates) to mesh B: out[i] gets the value for points_in_b[i].

  • The magnitude is the distance to the closest point of B, from fast_mesh_query::closest_point.
  • The sign comes from sign (see SignData): negative behind the surface (inside), positive in front of it (outside). A point exactly on the surface gets +0.0; a point whose side is undecided (exactly in the tangent plane of its closest feature) counts as outside.
  • A point farther than max_distance from the surface (inclusive bound) gets f32::INFINITY, meaning far, with no sign. That includes points deeper inside than max_distance. An infinite max_distance computes every point.

Nothing is allocated per point. With the parallel feature, large batches run in chunks on rayon’s pool, each chunk into its own buffer; the values are the same, bit for bit.

§Errors

Everything is checked before anything is written, so on error out is unchanged: