mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Update BVH to support extended metadata.
This commit is contained in:
@@ -25,6 +25,14 @@ namespace BVH
|
||||
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
|
||||
@@ -46,6 +54,18 @@ public:
|
||||
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.
|
||||
@@ -62,6 +82,7 @@ protected:
|
||||
|
||||
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
|
||||
|
||||
};
|
||||
|
||||
|
@@ -21,7 +21,8 @@ template<class T, int N>
|
||||
BVH_Builder<T, N>::BVH_Builder (const Standard_Integer theLeafNodeSize,
|
||||
const Standard_Integer theMaxTreeDepth)
|
||||
: myMaxTreeDepth (theMaxTreeDepth),
|
||||
myLeafNodeSize (theLeafNodeSize)
|
||||
myLeafNodeSize (theLeafNodeSize),
|
||||
myMetadataType (BVH_NODE_LEVEL)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
@@ -88,6 +88,13 @@ void BVH_QueueBuilder<T, N>::AddChildren (BVH_Tree<T, N>*
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// =======================================================================
|
||||
|
Reference in New Issue
Block a user