warp.tile_query_valid#

warp.tile_query_valid(query: BvhQueryTiled) bool#
  • Kernel: true
  • Python: false
  • Differentiable: false

Return whether a thread-block parallel BVH query should continue.

Guard the traversal loop with this function and test every index returned by tile_bvh_query_next() for >= 0. Every thread must execute the same traversal loop.

This built-in is also defined for the mesh queries built by tile_mesh_query_aabb().

Parameters:

query – The query to test, from tile_bvh_query_aabb() or tile_bvh_query_ray()

Returns:

The same value for every thread in the block. True initially and after a result batch containing at least one nonnegative index; False after an all-negative batch.

Example

@wp.kernel
def mark_overlaps(bvh_id: wp.uint64, lo: wp.vec3, hi: wp.vec3, hits: wp.array[wp.int32]):
    query = wp.tile_bvh_query_aabb(bvh_id, lo, hi)
    while wp.tile_query_valid(query):
        bound = wp.untile(wp.tile_bvh_query_next(query))
        if bound >= 0:
            hits[bound] = 1

lowers = wp.array([[0, 0, 0], [2, 0, 0], [4, 0, 0]], dtype=wp.vec3)
uppers = wp.array([[1, 1, 1], [3, 1, 1], [5, 1, 1]], dtype=wp.vec3)
bvh = wp.Bvh(lowers=lowers, uppers=uppers)

hits = wp.zeros(3, dtype=wp.int32)
wp.launch_tiled(mark_overlaps, dim=1,
                inputs=[bvh.id, wp.vec3(-1.0, -1.0, -1.0), wp.vec3(2.5, 2.0, 2.0)],
                outputs=[hits], block_dim=4)
print("overlaps:", hits.numpy().tolist())
overlaps: [1, 1, 0]
warp.tile_query_valid(query: MeshQueryAABBTiled) bool
  • Kernel: true
  • Python: false
  • Differentiable: false

Return whether a thread-block parallel mesh AABB query should continue.

This overload accepts a warp.MeshQueryAABBTiled. The overload taking a warp.BvhQueryTiled documents the shared iteration protocol and includes a usage example; use tile_mesh_query_aabb_next() to advance this query. Always test each returned face index for >= 0.

Parameters:

query – The query to test, from tile_mesh_query_aabb()

Returns:

The same value for every thread in the block. True initially and after a result batch containing at least one nonnegative index; False after an all-negative batch.