MobileRT  1.0
A multi platform C++ CPU progressive Ray Tracer.
MobileRT::BVH< T > Class Template Referencefinal

#include <BVH.hpp>

Collaboration diagram for MobileRT::BVH< T >:
Collaboration graph

Classes

struct  BuildNode
 
struct  BVHNode
 
struct  lessthan
 
struct  rightshift
 

Public Member Functions

 BVH ()=default
 
 BVH (::std::vector< T > &&primitives)
 
 BVH (const BVH &bvh)=delete
 
 BVH (BVH &&bvh) noexcept=default
 
 ~BVH ()
 
BVHoperator= (const BVH &bvh)=delete
 
BVHoperator= (BVH &&bvh) noexcept=default
 
Intersection trace (Intersection intersection)
 
Intersection shadowTrace (Intersection intersection)
 
const ::std::vector< T > & getPrimitives () const
 
template<typename Iterator >
::std::int32_t getSplitIndexSah (const Iterator itBegin, const Iterator itEnd)
 

Private Member Functions

void build (::std::vector< T > &&primitives)
 
Intersection intersect (Intersection intersection)
 
template<typename Iterator >
::std::int32_t getSplitIndexSah (Iterator itBegin, Iterator itEnd)
 
template<typename Iterator >
AABB getSurroundingBox (Iterator itBegin, Iterator itEnd)
 

Private Attributes

::std::vector< BVHNodeboxes_ {}
 
::std::vector< T > primitives_ {}
 

Detailed Description

template<typename T>
class MobileRT::BVH< T >

A class which represents the Bounding Volume Hierarchy acceleration structure.

Template Parameters
TThe type of the primitives.

Constructor & Destructor Documentation

◆ BVH() [1/4]

template<typename T>
MobileRT::BVH< T >::BVH ( )
explicitdefault

◆ BVH() [2/4]

template<typename T>
MobileRT::BVH< T >::BVH ( ::std::vector< T > &&  primitives)
explicit

The constructor.

Template Parameters
TThe type of the primitives.
Parameters
primitivesThe vector containing all the primitives to store in the BVH.

◆ BVH() [3/4]

template<typename T>
MobileRT::BVH< T >::BVH ( const BVH< T > &  bvh)
delete

◆ BVH() [4/4]

template<typename T>
MobileRT::BVH< T >::BVH ( BVH< T > &&  bvh)
defaultnoexcept

◆ ~BVH()

template<typename T >
MobileRT::BVH< T >::~BVH ( )

The destructor.

Template Parameters
TThe type of the primitives.

Member Function Documentation

◆ build()

template<typename T>
void MobileRT::BVH< T >::build ( ::std::vector< T > &&  primitives)
private

A helper method which builds the BVH structure.

Template Parameters
TThe type of the primitives.
Parameters
primitivesA vector containing all the primitives to store in the BVH.
Here is the caller graph for this function:

◆ getPrimitives()

template<typename T >
const ::std::vector< T > & MobileRT::BVH< T >::getPrimitives ( ) const

Gets the primitives.

Template Parameters
TThe type of the primitives.
Returns
The primitives.

◆ getSplitIndexSah() [1/2]

template<typename T>
template<typename Iterator >
::std::int32_t MobileRT::BVH< T >::getSplitIndexSah ( Iterator  itBegin,
Iterator  itEnd 
)
private
Here is the caller graph for this function:

◆ getSplitIndexSah() [2/2]

template<typename T>
template<typename Iterator >
::std::int32_t MobileRT::BVH< T >::getSplitIndexSah ( const Iterator  itBegin,
const Iterator  itEnd 
)

Gets the index to where the vector of boxes should be split.
The algorithm used is the Surface Area Heuristic.

Template Parameters
IteratorThe type of the iterator of the AABBs.
Parameters
itBeginThe iterator of the first box in the vector.
itEndThe iterator of the last box in the vector.
Returns
The index where the vector of boxes should be split.

◆ getSurroundingBox()

template<typename T >
template<typename Iterator >
AABB MobileRT::BVH< T >::getSurroundingBox ( Iterator  itBegin,
Iterator  itEnd 
)
private

Calculates a surrounding box of all the build nodes vector received via arguments.

Template Parameters
IteratorThe type of the iterator of the BuildNodes.
Parameters
itBeginThe iterator of the first node in the vector.
itEndThe iterator of the last node in the vector.
Returns
A box surrounding all the boxes of the nodes.
Here is the caller graph for this function:

◆ intersect()

template<typename T >
Intersection MobileRT::BVH< T >::intersect ( Intersection  intersection)
private

Helper method which calculates the intersection point from the origin of the ray.
This method supports two modes:

  • trace the ray until finding the nearest intersection point from the origin of the ray
  • trace the ray until finding any intersection point from the origin of the ray
Template Parameters
TThe type of the primitives.
Parameters
intersectionThe previous intersection point of the ray (used to update its data in case it is found a nearest intersection point.
Returns
The intersection point of the ray in the scene.
Here is the caller graph for this function:

◆ operator=() [1/2]

template<typename T>
BVH& MobileRT::BVH< T >::operator= ( const BVH< T > &  bvh)
delete

◆ operator=() [2/2]

template<typename T>
BVH& MobileRT::BVH< T >::operator= ( BVH< T > &&  bvh)
defaultnoexcept

◆ shadowTrace()

template<typename T >
Intersection MobileRT::BVH< T >::shadowTrace ( Intersection  intersection)

This method casts a ray into the geometry and calculates a random intersection point. The intersection point itself is not important, the important is to determine if the ray intersects some primitive in the scene or not.

Template Parameters
TThe type of the primitives.
Parameters
intersectionThe current intersection of the ray with previous primitives.
Returns
The intersection of the ray with the geometry.

◆ trace()

template<typename T >
Intersection MobileRT::BVH< T >::trace ( Intersection  intersection)

This method casts a ray into the geometry and calculates the nearest intersection point from the origin of the ray.

Template Parameters
TThe type of the primitives.
Parameters
intersectionThe current intersection of the ray with previous primitives.
Returns
The intersection of the ray with the geometry.

Member Data Documentation

◆ boxes_

template<typename T>
::std::vector<BVHNode> MobileRT::BVH< T >::boxes_ {}
private

◆ primitives_

template<typename T>
::std::vector<T> MobileRT::BVH< T >::primitives_ {}
private

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