AcademySoftwareFoundation / AcademySoftwareFoundation/openvdb
Ray intersects with an empty BBox
- Dominant language
- C++
- Stars
- 3.4k
- Forks
- 774
- Avg merge
- 3d 9h
- Merged PRs (30d)
- 34
Description
openvdb::math::Ray::intersects does not correctly handle an empty openvdb::math::BBox. That can lead to "interesting" behavior down the road :-)
It is caused by the reordering of a and b to account for both possible ray directions, which can also reorder the empty bbox into a valid bbox. I'm fairly certain it would work as expected if instead the sign of the direction was tested and a,b computed with the correct bbox side accordingly. Simple enough to reproduce:
```
#include
#include
#include
int main()
{
openvdb::math::Ray ray(openvdb::Vec3d(0.0), openvdb::Vec3d(1.0, 0.0, 0.0), 0.0, 1e2);
openvdb::math::BBox bbox;
double t0, t1;
bool hit = ray.intersects(bbox, t0, t1);
std::cout << "empty (" << bbox.empty() << ") hits (" << hit << ") with range " << t0 << " " << t1 << "\n";
}
```
Contributor guide
Research direction
Start by reading openvdb/math/Ray.h and openvdb/math/BBox.h, then compile and run the reproducer from the issue to observe how an empty BBox is handled. Trace the a and b reordering in Ray::intersects and verify that the finished behavior reports no intersection for an empty BBox while preserving correct results for valid boxes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- computer-graphics
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100