warp.mesh_query_sphere#
- warp.mesh_query_sphere( ) _MeshQuerySphere#
Kernel
Construct a sphere query against a
warp.Mesh.Iterates over mesh triangles that intersect a sphere. A broad phase uses an exact sphere-AABB test to find candidate triangles; a narrow phase keeps only those whose closest point on the triangle is within
radiusofcenter. Tangential contact (closest point exactly on the sphere surface) is included. A negativeradiusis clamped to zero. Degenerate (zero-area) faces are handled by falling back to a closest-point-on-longest-edge test. Advance the query withmesh_query_next().- Parameters:
id – The mesh identifier
center – The center of the sphere in mesh space
radius – The radius of the sphere; negative values are clamped to zero
Example
@wp.kernel def find_tris_in_sphere(mesh_id: wp.uint64, center: wp.vec3, radius: float, hits: wp.array[wp.int32]): query = wp.mesh_query_sphere(mesh_id, center, radius) face = int(0) while wp.mesh_query_next(query, face): hits[face] = wp.int32(1) points = wp.array([[0,0,0],[1,0,0],[0,1,0]], dtype=wp.vec3) indices = wp.array([0,1,2], dtype=wp.int32) mesh = wp.Mesh(points=points, indices=indices) hits = wp.zeros(1, dtype=wp.int32) wp.launch(find_tris_in_sphere, dim=1, inputs=[mesh.id, wp.vec3(0.1, 0.1, 0.0), 0.5, hits]) print("hit:", hits.numpy()[0])
hit: 1