本文整理汇总了C++中Bounds3f::getMin方法的典型用法代码示例。如果您正苦于以下问题:C++ Bounds3f::getMin方法的具体用法?C++ Bounds3f::getMin怎么用?C++ Bounds3f::getMin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bounds3f
的用法示例。
在下文中一共展示了Bounds3f::getMin方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bounds
BVHItem::BVHItem( const Bounds3f &i_bounds )
: bounds( i_bounds )
, center( ( i_bounds.getMax() + i_bounds.getMin() ) / 2.0f )
, index( 0 )
{}
示例2: buildNode
void BVH::buildNode( SplitMethod i_method, BVHItems &i_buildItems, size_t i_start, size_t i_end )
{
Bounds3f bounds;
Bounds3f centerBounds;
// Save the index for later access of the node
size_t nodeIndex = m_nodes.size();
// Push back a node, we will initialize it later
m_nodes.push_back( BVHNode() );
// Calculate bounds
for ( size_t i = i_start; i < i_end; i++ )
{
const BVHItem &item = i_buildItems[ i ];
bounds = boundsUnion( bounds, item.bounds );
centerBounds = boundsUnion( centerBounds, item.center );
}
size_t count = i_end - i_start;
// Create a leaf
if ( count == 1 )
{
m_nodes[ nodeIndex ].initLeaf( bounds, m_items.size(), 1 );
m_items.push_back( i_buildItems[ i_start ] );
}
// Split
else
{
int dim = static_cast< int >( bounds.maximumExtent() );
const vec3f &min = centerBounds.getMin();
const vec3f &max = centerBounds.getMax();
// Cannot split, create leaf items
if ( min[ dim ] == max[ dim ] )
{
m_nodes[ nodeIndex ].initLeaf( bounds, m_items.size(), count );
for ( size_t i = i_start; i < i_end; i++ )
{
m_items.push_back( i_buildItems[ i ] );
}
}
// Split by method
else
{
size_t mid = ( i_start + i_end ) / 2.0;
switch ( i_method ) {
case SplitMethod::MIDDLE:
{
// Split the items at the midpoint of the axis
float dimMid = ( centerBounds.getMin()[ dim ] + centerBounds.getMax()[ dim ] ) / 2.0;
BVHItem* midPtr = std::partition(
&i_buildItems[ i_start ],
&i_buildItems[ i_end - 1 ] + 1,
[ dim, dimMid ]( const BVHItem &item ) {
return item.center[ dim ] < dimMid;
} );
mid = midPtr - &i_buildItems[0];
// Continue onto splitting equally if failed
if ( mid != i_start && mid != i_end )
{
break;
}
}
case SplitMethod::EQUAL:
default:
{
// Reset mid in case we are defaulting to equal splitting
mid = ( i_start + i_end ) / 2.0;
// Split into equal sized subsets
std::nth_element(
&i_buildItems[ i_start ],
&i_buildItems[ mid ],
&i_buildItems[ i_end - 1 ] + 1,
[ dim ]( const BVHItem &i0, const BVHItem &i1 ) {
return i0.center[ dim ] < i1.center[ dim ];
} );
break;
}
}
// Build left tree
buildNode( i_method, i_buildItems, i_start, mid );
size_t offset = m_nodes.size();
// Build right tree
buildNode( i_method, i_buildItems, mid, i_end );
// Initialize the interior node
m_nodes[ nodeIndex ].initInterior( bounds, offset, dim );
}
}
//.........这里部分代码省略.........