const Standard_Real THE_NODE_MIN_SIZE = 1e-5;
}
+//! Type of metadata written in W component of
+//! BVH data vector corresponding to the node.
+enum BVH_NodeMetadata
+{
+ BVH_NODE_LEVEL = 0, //!< level (depth) of the node
+ BVH_NODE_PRIMS = 1 //!< number of node primitives
+};
+
//! Performs construction of BVH tree using bounding
//! boxes (AABBs) of abstract objects.
//! \tparam T Numeric data type
BVH_Tree<T, N>* theBVH,
const BVH_Box<T, N>& theBox) = 0;
+ //! Returns type of metadata written in BVH node.
+ BVH_NodeMetadata MetadataType() const
+ {
+ return myMetadataType;
+ }
+
+ //! Sets type of metadata written in BVH node.
+ void SetMetadataType (const BVH_NodeMetadata theMetadata)
+ {
+ myMetadataType = theMetadata;
+ }
+
protected:
//! Updates depth of constructed BVH tree.
Standard_Integer myMaxTreeDepth; //!< Maximum depth of constructed BVH
Standard_Integer myLeafNodeSize; //!< Maximum number of objects per leaf
+ BVH_NodeMetadata myMetadataType; //!< Type of metadata written in BVH node
};
BVH_Builder<T, N>::BVH_Builder (const Standard_Integer theLeafNodeSize,
const Standard_Integer theMaxTreeDepth)
: myMaxTreeDepth (theMaxTreeDepth),
- myLeafNodeSize (theLeafNodeSize)
+ myLeafNodeSize (theLeafNodeSize),
+ myMetadataType (BVH_NODE_LEVEL)
{
//
}
myBuildQueue.Enqueue (aChildIndex);
}
}
+
+ // Correct node's metadata if necessary
+ if (myMetadataType != BVH_NODE_LEVEL)
+ {
+ theBVH->NodeInfoBuffer()[theNode].w() =
+ theSubNodes.Ranges[1].Final - theSubNodes.Ranges[0].Start + 1;
+ }
}
// =======================================================================