NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FW::SAHBVHBuilder Class Reference

Class that builds a BVH using SAH. More...

#include <SAHBVHBuilder.hpp>

Classes

struct  NodeSpec
 Structure holding specifications of a BVH's node. More...
 
struct  ObjectSplit
 Structure holding info about a split of the BVH node. More...
 
struct  Reference
 Structure holding triangle's index together with its bounding box. More...
 

Public Member Functions

 SAHBVHBuilder (BVH &bvh, const BVH::BuildParams &params)
 Constructor. More...
 
virtual ~SAHBVHBuilder (void)
 Destructor. More...
 
virtual BVHNoderun (void)
 Performs the actual build. More...
 

Protected Types

enum  { MaxDepth = 64 }
 Maximum depth of the BVH. More...
 

Protected Member Functions

BVHNodebuildNode (const NodeSpec &spec, int level, F32 progressStart, F32 progressEnd)
 Builds a BVH node. The built node may be an inner node as well as a leaf node. More...
 
BVHNodebuildNode (const NodeSpec &spec, int start, int end, int level, F32 progressStart, F32 progressEnd)
 Builds a node. The built node may be an inner node as well as leaf node. Processes specific part of the reference stack. More...
 
BVHNodecreateLeaf (const NodeSpec &spec)
 Builds a leaf node. More...
 
BVHNodecreateLeaf (const NodeSpec &spec, int start, int end)
 Builds a leaf node. Processes specific part of the reference stack. More...
 
ObjectSplit findObjectSplit (const NodeSpec &spec, F32 nodeSAH)
 Finds the best object split of the node. More...
 
ObjectSplit findObjectSplit (int start, int end, F32 nodeSAH)
 Finds the best object split of the node. More...
 
void performObjectSplit (NodeSpec &left, NodeSpec &right, const NodeSpec &spec, const ObjectSplit &split)
 Performs the split operation. More...
 
void performObjectSplit (NodeSpec &left, NodeSpec &right, const NodeSpec &spec, int start, int end, const ObjectSplit &split)
 Performs the split operation. More...
 

Static Protected Member Functions

static bool sortCompare (void *data, int idxA, int idxB)
 Sort comparator. Sorts references according to their position in descending order. For details see framework/base.Sort.hpp. More...
 
static void sortSwap (void *data, int idxA, int idxB)
 Sort swap function. Swaps two references placed in the reference stack. For details see framework/base.Sort.hpp. More...
 

Protected Attributes

BVHm_bvh
 BVH being built. More...
 
const Platformm_platform
 Platform settings. More...
 
const BVH::BuildParamsm_params
 Build parameters. More...
 
Array< Referencem_refStack
 Reference stack. More...
 
Array< AABBm_rightBounds
 Bounding boxes of all the possible right children. More...
 
S32 m_sortDim
 Sort dimension. Used by the sort method. More...
 
Timer m_progressTimer
 Progress timer. More...
 
S32 m_numDuplicates
 Number of duplicated references. More...
 

Detailed Description

Class that builds a BVH using SAH.

Definition at line 38 of file SAHBVHBuilder.hpp.

Member Enumeration Documentation

anonymous enum
protected

Maximum depth of the BVH.

Enumerator
MaxDepth 

Definition at line 45 of file SAHBVHBuilder.hpp.

Constructor & Destructor Documentation

SAHBVHBuilder::SAHBVHBuilder ( BVH bvh,
const BVH::BuildParams params 
)

Constructor.

Parameters
[out]bvhBVH to be built.
[in]paramsBuild parameters.

Definition at line 24 of file SAHBVHBuilder.cpp.

SAHBVHBuilder::~SAHBVHBuilder ( void  )
virtual

Destructor.

Definition at line 34 of file SAHBVHBuilder.cpp.

Member Function Documentation

BVHNode * SAHBVHBuilder::buildNode ( const NodeSpec spec,
int  level,
F32  progressStart,
F32  progressEnd 
)
protected

Builds a BVH node. The built node may be an inner node as well as a leaf node.

Parameters
[in]specSpecifications of the node.
[in]levelLevel of the node in the tree.
[in]proggressStartPercentage of already built subtree.
[in]progressEndPercentage of already built subtree including node's subtree.
Returns
Built node.

Definition at line 133 of file SAHBVHBuilder.cpp.

BVHNode * SAHBVHBuilder::buildNode ( const NodeSpec spec,
int  start,
int  end,
int  level,
F32  progressStart,
F32  progressEnd 
)
protected

Builds a node. The built node may be an inner node as well as leaf node. Processes specific part of the reference stack.

Parameters
[in]specSpecifications of the node.
[in]startProcesses reference stack section starting from this position.
[in]endProcesses reference stack section ending in this position.
[in]levelLevel of the node in the tree.
[in]proggressStartPercentage of already built subtree.
[in]progressEndPercentage of already built subtree including node's subtree.
Returns
Built node.

Definition at line 184 of file SAHBVHBuilder.cpp.

BVHNode * SAHBVHBuilder::createLeaf ( const NodeSpec spec)
protected

Builds a leaf node.

Parameters
[in]specSpecification of the node.
Returns
Built leaf node.

Definition at line 236 of file SAHBVHBuilder.cpp.

BVHNode * SAHBVHBuilder::createLeaf ( const NodeSpec spec,
int  start,
int  end 
)
protected

Builds a leaf node. Processes specific part of the reference stack.

Parameters
[in]specSpecifications of the node.
[in]startProcesses reference stack section starting from this position.
[in]endProcesses reference stack section ending in this position.
Returns
Built leaf node.

Definition at line 246 of file SAHBVHBuilder.cpp.

SAHBVHBuilder::ObjectSplit SAHBVHBuilder::findObjectSplit ( const NodeSpec spec,
F32  nodeSAH 
)
protected

Finds the best object split of the node.

Parameters
[in]specSpecifications of the node.
[in]nodeSAHCost of the split without the cost of the triangles.
Returns
Found split.

Definition at line 257 of file SAHBVHBuilder.cpp.

SAHBVHBuilder::ObjectSplit SAHBVHBuilder::findObjectSplit ( int  start,
int  end,
F32  nodeSAH 
)
protected

Finds the best object split of the node.

Parameters
[in]startProcesses reference stack section starting from this position.
[in]endProcesses reference stack section ending in this position.
[in]nodeSAHCost of the split without the cost of the triangles.
Returns
Found split.

Definition at line 300 of file SAHBVHBuilder.cpp.

void SAHBVHBuilder::performObjectSplit ( NodeSpec left,
NodeSpec right,
const NodeSpec spec,
const ObjectSplit split 
)
protected

Performs the split operation.

Parameters
[out]leftLeft child node specification.
[out]rightRight child node specification.
[in]specSpecification of the node being split.
[in]splitSplit information.

Definition at line 344 of file SAHBVHBuilder.cpp.

void SAHBVHBuilder::performObjectSplit ( NodeSpec left,
NodeSpec right,
const NodeSpec spec,
int  start,
int  end,
const ObjectSplit split 
)
protected

Performs the split operation.

Parameters
[out]leftLeft child node specification.
[out]rightRight child node specification.
[in]startProcesses reference stack section starting from this position.
[in]endProcesses reference stack section ending in this position.
[in]splitSplit information.

Definition at line 357 of file SAHBVHBuilder.cpp.

BVHNode * SAHBVHBuilder::run ( void  )
virtual

Performs the actual build.

Returns
Root node of the built BVH.

Definition at line 40 of file SAHBVHBuilder.cpp.

bool SAHBVHBuilder::sortCompare ( void data,
int  idxA,
int  idxB 
)
staticprotected

Sort comparator. Sorts references according to their position in descending order. For details see framework/base.Sort.hpp.

Returns
True if idxB should go before idxA.

WARNING - new version might not work!!!

Definition at line 112 of file SAHBVHBuilder.cpp.

void SAHBVHBuilder::sortSwap ( void data,
int  idxA,
int  idxB 
)
staticprotected

Sort swap function. Swaps two references placed in the reference stack. For details see framework/base.Sort.hpp.

Definition at line 125 of file SAHBVHBuilder.cpp.

Member Data Documentation

BVH& FW::SAHBVHBuilder::m_bvh
protected

BVH being built.

Definition at line 207 of file SAHBVHBuilder.hpp.

S32 FW::SAHBVHBuilder::m_numDuplicates
protected

Number of duplicated references.

Definition at line 216 of file SAHBVHBuilder.hpp.

const BVH::BuildParams& FW::SAHBVHBuilder::m_params
protected

Build parameters.

Definition at line 209 of file SAHBVHBuilder.hpp.

const Platform& FW::SAHBVHBuilder::m_platform
protected

Platform settings.

Definition at line 208 of file SAHBVHBuilder.hpp.

Timer FW::SAHBVHBuilder::m_progressTimer
protected

Progress timer.

Definition at line 215 of file SAHBVHBuilder.hpp.

Array<Reference> FW::SAHBVHBuilder::m_refStack
protected

Reference stack.

Definition at line 211 of file SAHBVHBuilder.hpp.

Array<AABB> FW::SAHBVHBuilder::m_rightBounds
protected

Bounding boxes of all the possible right children.

Definition at line 212 of file SAHBVHBuilder.hpp.

S32 FW::SAHBVHBuilder::m_sortDim
protected

Sort dimension. Used by the sort method.

Definition at line 213 of file SAHBVHBuilder.hpp.


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