warp.bvh\_query\_sphere ======================= .. function:: warp._src.lang.bvh_query_sphere(id: uint64, center: vec3f, radius: float32, root: int32) -> _BvhQuerySphere .. hlist:: :columns: 8 * Kernel Construct a sphere query against a BVH object. Iterates over all items whose bounding box overlaps the sphere (exact sphere-AABB squared-distance test). Tangential contact (the nearest point on the AABB surface exactly on the sphere) is included. A negative ``radius`` is clamped to zero. This is a tighter broad-phase than padding a query AABB by the radius, since the sphere is inscribed in the padded box. Advance with :func:`bvh_query_next`. :param id: The BVH identifier :param center: The center of the sphere in BVH space :param radius: The radius of the sphere; negative values are clamped to zero :param root: The node to begin the query from, or -1 (default) for the BVH's global root :returns: A :class:`warp.BvhQuery`. It is opaque; pass it to :func:`bvh_query_next`. .. rubric:: Example .. testcode:: @wp.kernel def find_items_in_sphere(bvh_id: wp.uint64, center: wp.vec3, radius: float, hits: wp.array[wp.int32]): query = wp.bvh_query_sphere(bvh_id, center, radius) item = int(0) while wp.bvh_query_next(query, item): hits[item] = wp.int32(1) lowers = wp.array([[0, 0, 0], [2, 0, 0]], dtype=wp.vec3) uppers = wp.array([[1, 1, 1], [3, 1, 1]], dtype=wp.vec3) bvh = wp.Bvh(lowers=lowers, uppers=uppers) hits = wp.zeros(2, dtype=wp.int32) wp.launch(find_items_in_sphere, dim=1, inputs=[bvh.id, wp.vec3(0.5, 0.5, 0.5), 0.6, hits]) print(hits.numpy().tolist()) .. testoutput:: [1, 0]