SPH
Classes | Public Member Functions | List of all members
Bvh< TBvhObject > Class Template Reference

Simple bounding volume hierarchy. More...

#include <Bvh.h>

Inheritance diagram for Bvh< TBvhObject >:
Noncopyable

Public Member Functions

 Bvh (const Size leafSize=4)
 
void build (Array< TBvhObject > &&objects)
 Contructs the BVH from given set of objects. More...
 
bool getFirstIntersection (const Ray &ray, IntersectionInfo &intersection) const
 Finds the closest intersection of the ray. More...
 
template<typename TOutIter >
Size getAllIntersections (const Ray &ray, TOutIter iter) const
 Returns all intersections of the ray. More...
 
bool isOccluded (const Ray &ray) const
 Returns true if the ray is occluded by some geometry. More...
 
Box getBoundingBox () const
 Returns the bounding box of all objects in BVH. More...
 
- Public Member Functions inherited from Noncopyable
 Noncopyable ()=default
 
 Noncopyable (const Noncopyable &)=delete
 
 Noncopyable (Noncopyable &&)=default
 
Noncopyableoperator= (const Noncopyable &)=delete
 
Noncopyableoperator= (Noncopyable &&)=default
 

Detailed Description

template<typename TBvhObject>
class Bvh< TBvhObject >

Simple bounding volume hierarchy.

Interface for finding an intersection of given ray with a set of geometric objects. Currently very limited and not very optimized. Bvh is explicitly specialized for BvhSphere and BvhBox; if other geometric primitives are needed, either add the specialization to cpp, or move the implementation to header.

Definition at line 198 of file Bvh.h.

Constructor & Destructor Documentation

◆ Bvh()

template<typename TBvhObject >
Bvh< TBvhObject >::Bvh ( const Size  leafSize = 4)
inlineexplicit

Definition at line 216 of file Bvh.h.

Member Function Documentation

◆ build()

template<typename TBvhObject >
void Bvh< TBvhObject >::build ( Array< TBvhObject > &&  objects)

Contructs the BVH from given set of objects.

This erased previously stored objects.

Definition at line 151 of file Bvh.inl.h.

◆ getAllIntersections()

template<typename TBvhObject >
template<typename TOutIter >
Size Bvh< TBvhObject >::getAllIntersections ( const Ray ray,
TOutIter  iter 
) const

Returns all intersections of the ray.

Intersections are returned via a generic output iterator.

Returns
Total number of intersections.

Definition at line 129 of file Bvh.inl.h.

◆ getBoundingBox()

template<typename TBvhObject >
Box Bvh< TBvhObject >::getBoundingBox

Returns the bounding box of all objects in BVH.

Definition at line 235 of file Bvh.inl.h.

◆ getFirstIntersection()

template<typename TBvhObject >
bool Bvh< TBvhObject >::getFirstIntersection ( const Ray ray,
IntersectionInfo intersection 
) const

Finds the closest intersection of the ray.

Returns true if an intersection has been found.

Definition at line 114 of file Bvh.inl.h.

◆ isOccluded()

template<typename TBvhObject >
bool Bvh< TBvhObject >::isOccluded ( const Ray ray) const

Returns true if the ray is occluded by some geometry.

Definition at line 141 of file Bvh.inl.h.


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