warp.bvh_query_capsule#
- warp.bvh_query_capsule( ) _BvhQueryCapsule#
Kernel
Construct a conservative capsule sweep query against a BVH.
Iterates over every BVH item whose stored bounding box overlaps the swept capsule. Each node’s bounds are inflated by
radiusbefore the ray-slab test (an axis-aligned box inflation, not a true sphere cap), so the query never misses a primitive withinradiusof the segment but may return extra candidates near box corners.To sweep a closed capsule from
p0top1, passdir = p1 - p0(unnormalized) andmax_dist = 1.0inbvh_query_next(); contact at both endpoints is included. A zero-length segment (p0 == p1) is not supported — usebvh_query_sphere()instead. A negativeradiusis clamped to zero. Advance results withbvh_query_next().- Parameters:
id – The BVH identifier
start – The segment start point (
p0), in BVH spacedir – The segment direction (
p1 - p0), in BVH spaceradius – The capsule radius; negative values are clamped to zero
root – The node to begin the query from, or -1 (default) for the BVH’s global root
- Returns:
A
warp.BvhQuery. It is opaque; pass it tobvh_query_next().
Example
@wp.kernel def capsule_sweep(bvh_id: wp.uint64, p0: wp.vec3, p1: wp.vec3, radius: float, count: wp.array[wp.int32]): query = wp.bvh_query_capsule(bvh_id, p0, p1 - p0, radius) item = int(0) while wp.bvh_query_next(query, item, 1.0): wp.atomic_add(count, 0, 1) lowers = wp.array([[0.75, -1, -1]], dtype=wp.vec3) uppers = wp.array([[2.0, 1, 1]], dtype=wp.vec3) bvh = wp.Bvh(lowers=lowers, uppers=uppers) count = wp.zeros(1, dtype=wp.int32) wp.launch(capsule_sweep, dim=1, inputs=[bvh.id, wp.vec3(0.0, 0.0, 0.0), wp.vec3(0.5, 0.0, 0.0), 0.3, count]) print(count.numpy()[0])
1