warp icon indicating copy to clipboard operation
warp copied to clipboard

[REQ] More flexible BVH interfaces

Open WenchaoHuang opened this issue 6 months ago • 2 comments

Description

  1. Could Bvh class provides a rebuild() method?
  2. Could wp.bvh_query_ray() accept a rayTime parameter?

Context

  1. In scenes with dynamic objects, the BVH often needs to be rebuilt frequently. Currently, rebuilding requires creating a new Bvh object, which results in a new bvh.id. This behavior is not friendly to wp.ScopeCapture(), as it requires re-capturing the BVH traversal each time it is rebuilt—introducing additional overhead. Having a rebuild() method would allow in-place updates and improve performance for dynamic scenes.
  2. As for rayTime, from the current implementation of wp.bvh_query_ray(), adding this parameter would require only a small modification (e.g., changing the condition t > 0 to 0 < t < rayTime). This would make it possible to support efficient line-AABB intersection tests directly within the BVH traversal. Without it, users must perform additional hit-time checks manually in wp.kernel, including reloading leaf AABBs, which incurs extra cost. Adding rayTime would streamline this use case with minimal change to the core logic.

WenchaoHuang avatar Jul 08 '25 13:07 WenchaoHuang

@AnkaChan added a rebuild() method as requested. See 3ece71f796f5ab72c4c8b4c6d40fc17b5b5b0c9c. It will be in Warp v1.10 (scheduled for beginning of November) but you can start using it sooner by building Warp from main or using a nightly build starting with the next set.

The rayTime request is not addressed by 3ece71f796f5ab72c4c8b4c6d40fc17b5b5b0c9c. Feel free to open a pull request if you need it sooner.

shi-eric avatar Aug 22 '25 18:08 shi-eric

@WenchaoHuang: @StafaH's recent commit 0e08171333f80307c4ed1d2384a8b09c3d54dc42 adds a feature that should address your rayTime request.

shi-eric avatar Nov 11 '25 01:11 shi-eric