warp.bvh\_query\_aabb ===================== .. function:: warp._src.lang.bvh_query_aabb(id: uint64, low: vec3f, high: vec3f, root: int32) -> BvhQuery .. hlist:: :columns: 8 * Kernel Construct an axis-aligned bounding box (AABB) query against a BVH. Returns a query that iterates over every item in the BVH whose stored bounding box overlaps the query box ``[low, high]``. Advance the query and read each result with :func:`bvh_query_next`. ``low`` and ``high`` are given in BVH space, i.e. the same coordinate space as the ``lowers``/``uppers`` arrays passed to :class:`warp.Bvh`. To restrict traversal to a subtree, set ``root`` to that node's index (for a grouped BVH the group root is obtained from :func:`bvh_get_group_root`). If ``root`` is -1 (default), traversal starts at the BVH's global root. :param id: The BVH identifier :param low: The lower bound of the query box, in BVH space :param high: The upper bound of the query box, in BVH space :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`, which writes the index of each overlapping item (an index into the arrays passed to :class:`warp.Bvh`) to its ``index`` argument. .. rubric:: Example .. testcode:: @wp.kernel def query_region(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(bvh_id, lo, hi) item = int(0) while wp.bvh_query_next(query, item): 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) # center of each object whose box overlaps the region wp.launch(query_region, dim=1, inputs=[bvh.id, lowers, uppers, wp.vec3(0.5, 0.5, 0.5), wp.vec3(2.5, 0.5, 0.5)], outputs=[centers]) print(centers.numpy().tolist()) .. testoutput:: [[0.5, 0.5, 0.5], [2.5, 0.5, 0.5], [0.0, 0.0, 0.0]]