warp.mesh_query_point_sign_parity#

warp.mesh_query_point_sign_parity(
id: uint64,
point: vec3f,
max_dist: float32,
n_sample: int32,
perturbation_scale: float32,
) MeshQueryPoint#
  • Kernel

  • Differentiable

Computes the closest point on the warp.Mesh with identifier id to the given point in space.

The method will cast multiple rays starting from the query point by applying small random perturbations to a base direction (1, 1, 1). Each perturbation is sampled independently for the x, y, and z dimensions from a uniform distribution in the range [-perturbation_scale, perturbation_scale), and added to the base direction to produce a slightly altered ray direction. This randomization helps avoid degeneracies such as rays intersecting exactly on triangle edges, vertices, or becoming parallel to mesh features.

For each perturbed ray, the method counts how many mesh faces it intersects and uses the parity (odd/even) of this count to determine whether the ray exits the mesh (odd -> inside, even -> outside). A majority vote over all sampled rays is used to classify the point.

param id:

The mesh identifier

param point:

The point in space to query

param max_dist:

Mesh faces above this distance will not be considered by the query

param n_sample:

Number of rays to cast (default: 1). Use a higher value if the sign is inaccurate.

param perturbation_scale:

Scale of the perturbation.