Nori  23
BVH Class Reference

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.
 
ShapegetShape (uint32_t idx)
 Return one of the registered shapes.
 
const ShapegetShape (uint32_t idx) const
 Return one of the registered shapes (const version)
 
const BoundingBox3fgetBoundingBox () 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
 

Detailed Description

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)

Author
Wenzel Jakob

Definition at line 43 of file bvh.h.

Member Function Documentation

◆ addShape()

void BVH::addShape ( Shape shape)

Register a shape for inclusion in the BVH.

This function can only be used before build() is called

Definition at line 308 of file bvh.cpp.

◆ rayIntersect()

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.

Returns
true If an intersection was found

Definition at line 404 of file bvh.cpp.


The documentation for this class was generated from the following files: