Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived > Class Template Reference

Optimized KD-tree acceleration data structure for n-dimensional (n<=4) shapes and various queries on them. More...

#include <mitsuba/render/gkdtree.h>

+ Inheritance diagram for mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >:

Classes

struct  BuildContext
 Per-thread context used to manage memory allocations, also records some useful statistics. More...
 
struct  BuildInterface
 Communication data structure used to pass jobs to kd-tree builder threads. More...
 
struct  EdgeEvent
 Describes the beginning or end of a primitive when projected onto a certain dimension. More...
 
struct  EdgeEventOrdering
 Edge event comparison functor. More...
 
struct  EventList
 
struct  MinMaxBins
 Min-max binning as described in "Highly Parallel Fast KD-tree Construction for Interactive Ray Tracing of Dynamic Scenes" by M. Shevtsov, A. Soupikov and A. Kapustin. More...
 
struct  RewriteItem
 Once the tree has been constructed, it is rewritten into a more convenient binary storage format. More...
 
struct  SplitCandidate
 Data type for split candidates computed by the O(n log n) greedy optimization method. More...
 
class  TreeBuilder
 kd-tree builder thread More...
 

Public Types

typedef KDTreeBase< AABBType > Parent
 
typedef Parent::SizeType SizeType
 
typedef Parent::IndexType IndexType
 
typedef Parent::KDNode KDNode
 
typedef AABBType::Scalar Scalar
 
typedef AABBType::PointType PointType
 
typedef AABBType::VectorType VectorType
 
- Public Types inherited from mitsuba::KDTreeBase< AABBType >
typedef uint32_t IndexType
 Index number format (max 2^32 prims) More...
 
typedef uint32_t SizeType
 Size number format. More...
 

Public Member Functions

 GenericKDTree ()
 Create a new kd-tree instance initialized with the default parameters. More...
 
virtual ~GenericKDTree ()
 Release all memory. More...
 
void setTraversalCost (Float traversalCost)
 Set the traversal cost used by the tree construction heuristic. More...
 
IndexTypegetIndices () const
 Returns the underlying kd-tree index buffer. More...
 
Float getTraversalCost () const
 Return the traversal cost used by the tree construction heuristic. More...
 
void setQueryCost (Float queryCost)
 Set the query cost used by the tree construction heuristic (This is the average cost for testing a contained shape against a kd-tree search query) More...
 
Float getQueryCost () const
 Return the query cost used by the tree construction heuristic (This is the average cost for testing a contained shape against a kd-tree search query) More...
 
void setEmptySpaceBonus (Float emptySpaceBonus)
 Set the bonus factor for empty space used by the tree construction heuristic. More...
 
Float getEmptySpaceBonus () const
 Return the bonus factor for empty space used by the tree construction heuristic. More...
 
void setMaxDepth (SizeType maxDepth)
 Set the maximum tree depth (0 = use heuristic) More...
 
void setMinMaxBins (SizeType minMaxBins)
 Set the number of bins used for Min-Max binning. More...
 
SizeType getMinMaxBins () const
 Return the number of bins used for Min-Max binning. More...
 
SizeType getMaxDepth () const
 Return maximum tree depth (0 = use heuristic) More...
 
void setClip (bool clip)
 Specify whether or not to use primitive clipping will be used in the tree construction. More...
 
bool getClip () const
 Return whether or not to use primitive clipping will be used in the tree construction. More...
 
void setRetract (bool retract)
 Specify whether or not bad splits can be "retracted". More...
 
bool getRetract () const
 Return whether or not bad splits can be "retracted". More...
 
void setMaxBadRefines (SizeType maxBadRefines)
 Set the number of bad refines allowed to happen in succession before a leaf node will be created. More...
 
SizeType getMaxBadRefines () const
 Return the number of bad refines allowed to happen in succession before a leaf node will be created. More...
 
void setStopPrims (SizeType stopPrims)
 Set the number of primitives, at which recursion will stop when building the tree. More...
 
SizeType getStopPrims () const
 Return the number of primitives, at which recursion will stop when building the tree. More...
 
void setParallelBuild (bool parallel)
 Specify whether or not tree construction should run in parallel. More...
 
bool getParallelBuild () const
 Return whether or not tree construction will run in parallel. More...
 
void setExactPrimitiveThreshold (SizeType exactPrimThreshold)
 Specify the number of primitives, at which the builder will switch from (approximate) Min-Max binning to the accurate O(n log n) optimization method. More...
 
SizeType getExactPrimitiveThreshold () const
 Return the number of primitives, at which the builder will switch from (approximate) Min-Max binning to the accurate O(n log n) optimization method. More...
 
- Public Member Functions inherited from mitsuba::KDTreeBase< AABBType >
 BOOST_STATIC_ASSERT (sizeof(KDNode)==8)
 
ELogLevel getLogLevel () const
 Return the log level of kd-tree status messages. More...
 
void setLogLevel (ELogLevel level)
 Return the log level of kd-tree status messages. More...
 
const KDNodegetRoot () const
 Return the root node of the kd-tree. More...
 
bool isBuilt () const
 Return whether or not the kd-tree has been built. More...
 
const AABBType & getAABB () const
 Return a (slightly enlarged) axis-aligned bounding box containing all primitives. More...
 
const AABBType & getTightAABB () const
 Return a tight axis-aligned bounding box containing all primitives. More...
 
virtual const ClassgetClass () const
 Retrieve this object's class. More...
 
- Public Member Functions inherited from Object
 Object ()
 Construct a new object. More...
 
int getRefCount () const
 Return the current reference count. More...
 
void incRef () const
 Increase the reference count of the object by one. More...
 
void decRef (bool autoDeallocate=true) const
 Decrease the reference count of the object and possibly deallocate it. More...
 
virtual std::string toString () const
 Return a human-readable string representation of the object's contents. More...
 

Protected Types

enum  EClassificationResult { EBothSides = 0, ELeftSide = 1, ERightSide = 2, EBothSidesProcessed = 3 }
 Primitive classification during tree-construction. More...
 

Protected Member Functions

void buildInternal ()
 Build a KD-tree over the supplied geometry. More...
 
 BOOST_STATIC_ASSERT (sizeof(EdgeEvent)==12)
 
Derived * cast ()
 Cast to the derived class. More...
 
const Derived * cast () const
 Cast to the derived class (const version) More...
 
EventList createEventList (OrderedChunkAllocator &alloc, const AABBType &nodeAABB, IndexType *prims, SizeType primCount)
 Create an edge event list for a given list of primitives. More...
 
void createLeaf (BuildContext &ctx, KDNode *node, EdgeEvent *eventStart, EdgeEvent *eventEnd, SizeType primCount)
 Leaf node creation helper function. More...
 
void createLeaf (BuildContext &ctx, KDNode *node, SizeType *indices, SizeType primCount)
 Leaf node creation helper function. More...
 
void createLeafAfterRetraction (BuildContext &ctx, KDNode *node, SizeType start)
 Leaf node creation helper function. More...
 
Float transitionToNLogN (BuildContext &ctx, unsigned int depth, KDNode *node, const AABBType &nodeAABB, IndexType *indices, SizeType primCount, bool isLeftChild, SizeType badRefines)
 Implements the transition from min-max-binning to the O(n log n) optimization. More...
 
Float buildTreeMinMax (BuildContext &ctx, unsigned int depth, KDNode *node, const AABBType &nodeAABB, const AABBType &tightAABB, IndexType *indices, SizeType primCount, bool isLeftChild, SizeType badRefines)
 Build helper function (min-max binning) More...
 
Float buildTree (BuildContext &ctx, unsigned int depth, KDNode *node, const AABBType &nodeAABB, EdgeEvent *eventStart, EdgeEvent *eventEnd, SizeType primCount, bool isLeftChild, SizeType badRefines)
 
- Protected Member Functions inherited from mitsuba::KDTreeBase< AABBType >
virtual ~KDTreeBase ()
 
- Protected Member Functions inherited from Object
virtual ~Object ()
 Virtual private deconstructor. (Will only be called by ref) More...
 

Protected Attributes

IndexTypem_indices
 
Float m_traversalCost
 
Float m_queryCost
 
Float m_emptySpaceBonus
 
bool m_clip
 
bool m_retract
 
bool m_parallelBuild
 
SizeType m_maxDepth
 
SizeType m_stopPrims
 
SizeType m_maxBadRefines
 
SizeType m_exactPrimThreshold
 
SizeType m_minMaxBins
 
SizeType m_nodeCount
 
SizeType m_indexCount
 
std::vector< TreeBuilder * > m_builders
 
std::vector< KDNode * > m_indirections
 
ref< Mutexm_indirectionLock
 
BuildInterface m_interface
 
- Protected Attributes inherited from mitsuba::KDTreeBase< AABBType >
KDNodem_nodes
 
ELogLevel m_logLevel
 
AABBType m_aabb
 
AABBType m_tightAABB
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static void staticInitialization ()
 Initializes the built-in reference count debugger (if enabled) More...
 
static void staticShutdown ()
 Free the memory taken by staticInitialization() More...
 
- Static Public Attributes inherited from mitsuba::KDTreeBase< AABBType >
static Classm_theClass = new Class("KDTreeBase", true, "Object")
 
- Static Public Attributes inherited from Object
static Classm_theClass
 Pointer to the object's class descriptor. More...
 

Detailed Description

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
class mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >

Optimized KD-tree acceleration data structure for n-dimensional (n<=4) shapes and various queries on them.

Note that this class mainly concerns itself with data that cover a region of space. For point data, other implementations will be more suitable. The most important application in Mitsuba is the fast construction of high-quality trees for ray tracing. See the class SAHKDTree for this specialization.

The code in this class is a fully generic kd-tree implementation, which can theoretically support any kind of shape. However, subclasses still need to provide the following signatures for a functional implementation:

/// Return the total number of primitives
inline SizeType getPrimitiveCount() const;
/// Return the axis-aligned bounding box of a certain primitive
inline AABB getAABB(IndexType primIdx) const;
/// Return the AABB of a primitive when clipped to another AABB
inline AABB getClippedAABB(IndexType primIdx, const AABBType &aabb) const;

This class follows the "Curiously recurring template" design pattern so that the above functions can be inlined (in particular, no virtual calls will be necessary!).

When the kd-tree is initially built, this class optimizes a cost heuristic every time a split plane has to be chosen. For ray tracing, the heuristic is usually the surface area heuristic (SAH), but other choices are possible as well. The tree construction heuristic must be passed as a template argument, which can use a supplied AABB and split candidate to compute approximate probabilities of recursing into the left and right subrees during a typical kd-tree query operation. See SurfaceAreaHeuristic for an example of the interface that must be implemented.

The kd-tree construction algorithm creates 'perfect split' trees as outlined in the paper "On Building fast kd-Trees for Ray Tracing, and on doing that in O(N log N)" by Ingo Wald and Vlastimil Havran. This works even when the tree is not meant to be used for ray tracing. For polygonal meshes, the involved Sutherland-Hodgman iterations can be quite expensive in terms of the overall construction time. The setClip method can be used to deactivate perfect splits at the cost of a lower-quality tree.

Because the O(N log N) construction algorithm tends to cause many incoherent memory accesses, a fast approximate technique (Min-max binning) is used near the top of the tree, which significantly reduces cache misses. Once the input data has been narrowed down to a reasonable amount, the implementation switches over to the O(N log N) builder. When multiple processors are available, the build process runs in parallel.

Author
Wenzel Jakob

Member Typedef Documentation

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef Parent::IndexType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::IndexType
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef Parent::KDNode mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::KDNode
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef KDTreeBase<AABBType> mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::Parent
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef AABBType::PointType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::PointType
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef AABBType::Scalar mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::Scalar
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef Parent::SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::SizeType
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
typedef AABBType::VectorType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::VectorType

Member Enumeration Documentation

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
enum mitsuba::GenericKDTree::EClassificationResult
protected

Primitive classification during tree-construction.

Enumerator
EBothSides 

Straddling primitive.

ELeftSide 

Primitive is entirely on the left side of the split.

ERightSide 

Primitive is entirely on the right side of the split.

EBothSidesProcessed 

Edge events have been generated for the straddling primitive.

Constructor & Destructor Documentation

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::GenericKDTree ( )
inline

Create a new kd-tree instance initialized with the default parameters.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
virtual mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::~GenericKDTree ( )
inlinevirtual

Release all memory.

Member Function Documentation

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::BOOST_STATIC_ASSERT ( sizeof(EdgeEvent = =12)
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::buildInternal ( )
inlineprotected

Build a KD-tree over the supplied geometry.

To be called by the subclass.

Clean up event lists and print statistics

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::buildTree ( BuildContext ctx,
unsigned int  depth,
KDNode node,
const AABBType &  nodeAABB,
EdgeEvent eventStart,
EdgeEvent eventEnd,
SizeType  primCount,
bool  isLeftChild,
SizeType  badRefines 
)
inlineprotected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::buildTreeMinMax ( BuildContext ctx,
unsigned int  depth,
KDNode node,
const AABBType &  nodeAABB,
const AABBType &  tightAABB,
IndexType indices,
SizeType  primCount,
bool  isLeftChild,
SizeType  badRefines 
)
inlineprotected

Build helper function (min-max binning)

Parameters
ctxThread-specific build context containing allocators etc.
depthCurrent tree depth (1 == root node)
nodeKD-tree node entry to be filled
nodeAABBAxis-aligned bounding box of the current node
tightAABBTight bounding box of the contained geometry (for min-max binning)
indicesIndex list of all triangles in the current node (for min-max binning)
primCountTotal primitive count for the current node
isLeftChildIs this node the left child of its parent? This is important for memory management using the OrderedChunkAllocator.
badRefinesNumber of "probable bad refines" further up the tree. This makes it possible to split along an initially bad-looking candidate in the hope that the cost was significantly overestimated. The counter makes sure that only a limited number of such splits can happen in succession.
Returns
Final cost of the node
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Derived* mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::cast ( )
inlineprotected

Cast to the derived class.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
const Derived* mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::cast ( ) const
inlineprotected

Cast to the derived class (const version)

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
EventList mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::createEventList ( OrderedChunkAllocator alloc,
const AABBType &  nodeAABB,
IndexType prims,
SizeType  primCount 
)
inlineprotected

Create an edge event list for a given list of primitives.

This is necessary when passing from Min-Max binning to the more accurate O(n log n) optimizier.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::createLeaf ( BuildContext ctx,
KDNode node,
EdgeEvent eventStart,
EdgeEvent eventEnd,
SizeType  primCount 
)
inlineprotected

Leaf node creation helper function.

Parameters
ctxThread-specific build context containing allocators etc.
nodeKD-tree node entry to be filled
eventStartStart pointer of an edge event list
eventEndEnd pointer of an edge event list
primCountTotal primitive count for the current node
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::createLeaf ( BuildContext ctx,
KDNode node,
SizeType indices,
SizeType  primCount 
)
inlineprotected

Leaf node creation helper function.

Parameters
ctxThread-specific build context containing allocators etc.
nodeKD-tree node entry to be filled
indicesStart pointer of an index list
primCountTotal primitive count for the current node
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::createLeafAfterRetraction ( BuildContext ctx,
KDNode node,
SizeType  start 
)
inlineprotected

Leaf node creation helper function.

Creates a unique index list by collapsing a subtree with a bad cost.

Parameters
ctxThread-specific build context containing allocators etc.
nodeKD-tree node entry to be filled
startStart pointer of the subtree indices
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getClip ( ) const
inline

Return whether or not to use primitive clipping will be used in the tree construction.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getEmptySpaceBonus ( ) const
inline

Return the bonus factor for empty space used by the tree construction heuristic.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getExactPrimitiveThreshold ( ) const
inline

Return the number of primitives, at which the builder will switch from (approximate) Min-Max binning to the accurate O(n log n) optimization method.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
IndexType* mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getIndices ( ) const
inline

Returns the underlying kd-tree index buffer.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getMaxBadRefines ( ) const
inline

Return the number of bad refines allowed to happen in succession before a leaf node will be created.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getMaxDepth ( ) const
inline

Return maximum tree depth (0 = use heuristic)

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getMinMaxBins ( ) const
inline

Return the number of bins used for Min-Max binning.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getParallelBuild ( ) const
inline

Return whether or not tree construction will run in parallel.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getQueryCost ( ) const
inline

Return the query cost used by the tree construction heuristic (This is the average cost for testing a contained shape against a kd-tree search query)

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getRetract ( ) const
inline

Return whether or not bad splits can be "retracted".

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getStopPrims ( ) const
inline

Return the number of primitives, at which recursion will stop when building the tree.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::getTraversalCost ( ) const
inline

Return the traversal cost used by the tree construction heuristic.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setClip ( bool  clip)
inline

Specify whether or not to use primitive clipping will be used in the tree construction.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setEmptySpaceBonus ( Float  emptySpaceBonus)
inline

Set the bonus factor for empty space used by the tree construction heuristic.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setExactPrimitiveThreshold ( SizeType  exactPrimThreshold)
inline

Specify the number of primitives, at which the builder will switch from (approximate) Min-Max binning to the accurate O(n log n) optimization method.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setMaxBadRefines ( SizeType  maxBadRefines)
inline

Set the number of bad refines allowed to happen in succession before a leaf node will be created.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setMaxDepth ( SizeType  maxDepth)
inline

Set the maximum tree depth (0 = use heuristic)

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setMinMaxBins ( SizeType  minMaxBins)
inline

Set the number of bins used for Min-Max binning.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setParallelBuild ( bool  parallel)
inline

Specify whether or not tree construction should run in parallel.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setQueryCost ( Float  queryCost)
inline

Set the query cost used by the tree construction heuristic (This is the average cost for testing a contained shape against a kd-tree search query)

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setRetract ( bool  retract)
inline

Specify whether or not bad splits can be "retracted".

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setStopPrims ( SizeType  stopPrims)
inline

Set the number of primitives, at which recursion will stop when building the tree.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
void mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::setTraversalCost ( Float  traversalCost)
inline

Set the traversal cost used by the tree construction heuristic.

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::transitionToNLogN ( BuildContext ctx,
unsigned int  depth,
KDNode node,
const AABBType &  nodeAABB,
IndexType indices,
SizeType  primCount,
bool  isLeftChild,
SizeType  badRefines 
)
inlineprotected

Implements the transition from min-max-binning to the O(n log n) optimization.

Parameters
ctxThread-specific build context containing allocators etc.
depthCurrent tree depth (1 == root node)
nodeKD-tree node entry to be filled
nodeAABBAxis-aligned bounding box of the current node
indicesIndex list of all triangles in the current node (for min-max binning)
primCountTotal primitive count for the current node
isLeftChildIs this node the left child of its parent? This is important for memory management using the OrderedChunkAllocator.
badRefinesNumber of "probable bad refines" further up the tree. This makes it possible to split along an initially bad-looking candidate in the hope that the cost was significantly overestimated. The counter makes sure that only a limited number of such splits can happen in succession.
Returns
Final cost of the node

Member Data Documentation

template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
std::vector<TreeBuilder *> mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_builders
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_clip
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_emptySpaceBonus
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_exactPrimThreshold
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_indexCount
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
IndexType* mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_indices
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
ref<Mutex> mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_indirectionLock
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
std::vector<KDNode *> mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_indirections
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
BuildInterface mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_interface
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_maxBadRefines
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_maxDepth
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_minMaxBins
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_nodeCount
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_parallelBuild
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_queryCost
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
bool mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_retract
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
SizeType mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_stopPrims
protected
template<typename AABBType, typename TreeConstructionHeuristic, typename Derived>
Float mitsuba::GenericKDTree< AABBType, TreeConstructionHeuristic, Derived >::m_traversalCost
protected

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