warp.bvh_query_aabb_tiled#

warp.bvh_query_aabb_tiled(
id: uint64,
low: vec3f,
high: vec3f,
) BvhQueryTiled#
  • Kernel

Construct an axis-aligned bounding box (AABB) query against a BVH for thread-block parallel traversal.

For use in tiled kernels: all threads in the block cooperatively traverse the BVH. Advance the query with bvh_query_next_tiled() (one result index per thread per step) in a loop guarded by tile_query_valid(). low and high must be identical across all threads in the block and are given in BVH space (the space of the arrays passed to warp.Bvh).

Parameters:
  • id – The BVH identifier

  • low – The lower bound of the query box, in BVH space (must be the same for all threads in the block)

  • high – The upper bound of the query box, in BVH space (must be the same for all threads in the block)

Returns:

A warp.BvhQueryTiled to advance with bvh_query_next_tiled().

Example

@wp.kernel
def tiled_query(bvh_id: wp.uint64, lowers: wp.array[wp.vec3], uppers: wp.array[wp.vec3],
                lo: wp.vec3, hi: wp.vec3, centers: wp.array[wp.vec3]):
    query = wp.bvh_query_aabb_tiled(bvh_id, lo, hi)
    while wp.tile_query_valid(query):
        result = wp.bvh_query_next_tiled(query)
        item = wp.untile(result)
        if item >= 0:
            centers[item] = 0.5 * (lowers[item] + uppers[item])

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)

centers = wp.zeros(3, dtype=wp.vec3)
wp.launch_tiled(tiled_query, dim=[1], inputs=[bvh.id, lowers, uppers, wp.vec3(0.5, 0.5, 0.5), wp.vec3(4.5, 0.5, 0.5)], outputs=[centers], block_dim=32)
print(centers.numpy().tolist())
[[0.5, 0.5, 0.5], [2.5, 0.5, 0.5], [4.5, 0.5, 0.5]]