warp.mesh_query_aabb_next_tiled#
- warp.mesh_query_aabb_next_tiled(
- query: MeshQueryAABBTiled,
Kernel
Move to the next triangle in a thread-block parallel mesh AABB query and return results as a tile.
Each thread in the block receives one result index in the returned tile, or -1 if no result for that thread. The function returns a register tile of shape
(block_dim,)containing the result indices.To check if any results were found, check if any element in the tile is >= 0. Call this in a loop guarded by
tile_query_valid(), which returnsFalseonce the query is exhausted. All threads in the block must call it cooperatively.- Parameters:
query – The thread-block mesh query object, from
mesh_query_aabb_tiled()- Returns:
- A register tile of shape
(block_dim,)with dtype int, where each element contains the result index for that thread (-1 if no result)
- A register tile of shape
Example
@wp.kernel def tiled_faces(mesh_id: wp.uint64, lo: wp.vec3, hi: wp.vec3, out_count: wp.array[wp.int32]): query = wp.mesh_query_aabb_tiled(mesh_id, lo, hi) while wp.tile_query_valid(query): result = wp.mesh_query_aabb_next_tiled(query) face = wp.untile(result) if face >= 0: wp.atomic_add(out_count, 0, 1) points = wp.array([[0,0,0],[1,0,0],[1,1,0],[0,1,0],[0,0,1],[1,0,1],[1,1,1],[0,1,1]], dtype=wp.vec3) indices = wp.array([0,3,2, 0,2,1, 4,5,6, 4,6,7, 0,1,5, 0,5,4, 2,3,7, 2,7,6, 0,4,7, 0,7,3, 1,2,6, 1,6,5], dtype=wp.int32) mesh = wp.Mesh(points=points, indices=indices) out_count = wp.zeros(1, dtype=wp.int32) wp.launch_tiled(tiled_faces, dim=[1], inputs=[mesh.id, wp.vec3(-1.0, -1.0, -1.0), wp.vec3(2.0, 2.0, 2.0)], outputs=[out_count], block_dim=32) print("overlapping faces:", out_count.numpy()[0])
overlapping faces: 12