warp.tile_mesh_query_aabb#
- warp.tile_mesh_query_aabb( ) MeshQueryAABBTiled#
Construct an axis-aligned bounding box query against a
warp.Meshfor thread-block parallel traversal.The whole block traverses one query cooperatively. Advance it with
tile_mesh_query_aabb_next(), which hands every thread one face index per step in unspecified order. Guard the traversal loop withtile_query_valid(). This is a broad-phase test on bounding boxes: a reported face’s triangle may not actually intersect the box, so perform an exact test yourself if required.Only one mesh query may be active per block; exhaust it before constructing another.
- Parameters:
id – The mesh identifier (must be the same for all threads in the block)
low – The lower bound of the query box, in the mesh’s local space (must be the same for all threads in the block)
high – The upper bound of the query box, in the mesh’s local space (must be the same for all threads in the block)
- Returns:
A
warp.MeshQueryAABBTiledto advance withtile_mesh_query_aabb_next().
Example
@wp.kernel def overlapping_faces(mesh_id: wp.uint64, lo: wp.vec3, hi: wp.vec3, counts: wp.array[wp.int32]): query = wp.tile_mesh_query_aabb(mesh_id, lo, hi) while wp.tile_query_valid(query): # one face index per thread, negative where this thread has no result face = wp.untile(wp.tile_mesh_query_aabb_next(query)) if face >= 0: wp.atomic_add(counts, face, 1) points = wp.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [2, 0, 0], [3, 0, 0], [2, 1, 0]], dtype=wp.vec3) indices = wp.array([0, 1, 2, 3, 4, 5], dtype=wp.int32) mesh = wp.Mesh(points=points, indices=indices) counts = wp.zeros(2, dtype=wp.int32) wp.launch_tiled(overlapping_faces, dim=1, inputs=[mesh.id, wp.vec3(-1.0, -1.0, -1.0), wp.vec3(0.5, 2.0, 1.0)], outputs=[counts], block_dim=4) print("times each face was reported:", counts.numpy().tolist())
times each face was reported: [1, 0]