Bounding Volume Hierarchy for fast ray intersection queries. More...
#include <bvh.h>
Classes | |
struct | BVHNode |
Public Member Functions | |
BVH () | |
Create a new and empty BVH. | |
virtual | ~BVH () |
Release all resources. | |
void | clear () |
Release all resources. | |
void | addShape (Shape *shape) |
Register a shape for inclusion in the BVH. More... | |
void | build () |
Build the BVH. | |
bool | rayIntersect (const Ray3f &ray, Intersection &its, bool shadowRay=false) const |
Intersect a ray against all shapes registered with the BVH. More... | |
uint32_t | getShapeCount () const |
Return the total number of shapes registered with the BVH. | |
uint32_t | getPrimitiveCount () const |
Return the total number of internally represented primitives. | |
Shape * | getShape (uint32_t idx) |
Return one of the registered shapes. | |
const Shape * | getShape (uint32_t idx) const |
Return one of the registered shapes (const version) | |
const BoundingBox3f & | getBoundingBox () const |
Protected Member Functions | |
uint32_t | findShape (uint32_t &idx) const |
Compute the shape and primitive indices corresponding to a primitive index used by the underlying generic BVH implementation. | |
BoundingBox3f | getBoundingBox (uint32_t index) const |
Point3f | getCentroid (uint32_t index) const |
std::pair< float, uint32_t > | statistics (uint32_t index=0) const |
Compute internal tree statistics. | |
Friends | |
class | BVHBuildTask |
Bounding Volume Hierarchy for fast ray intersection queries.
This class builds a Bounding Volume Hierarchy (BVH) using a greedy divide and conquer build strategy, which locally maximizes a criterion known as the Surface Area Heuristic (SAH) to obtain a tree that is particularly well-suited for ray intersection queries.
Construction of a BVH is generally slow; the implementation here runs in parallel to accelerate this process much as possible. For details on how this works, refer to the paper
"Fast and Parallel Construction of SAH-based Bounding Volume Hierarchies" by Ingo Wald (Proc. IEEE/EG Symposium on Interactive Ray Tracing, 2007)
void BVH::addShape | ( | Shape * | shape | ) |
bool BVH::rayIntersect | ( | const Ray3f & | ray, |
Intersection & | its, | ||
bool | shadowRay = false |
||
) | const |
Intersect a ray against all shapes registered with the BVH.
Detailed information about the intersection, if any, will be stored in the provided Intersection data record.
The shadowRay
parameter specifies whether this detailed information is really needed. When set to true
, the function just checks whether or not there is occlusion, but without providing any more detail (i.e. its
will not be filled with contents). This is usually much faster.
true
If an intersection was found