本文整理汇总了C++中Plane3::TestPoly方法的典型用法代码示例。如果您正苦于以下问题:C++ Plane3::TestPoly方法的具体用法?C++ Plane3::TestPoly怎么用?C++ Plane3::TestPoly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Plane3
的用法示例。
在下文中一共展示了Plane3::TestPoly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
// TODO: 最优分割面选择需要考虑到二叉树的平衡性
// weight = fabs(左数目-右数目)+分割数目
// 越小越优先考虑
int BspTree::BspNode::BestIndex( std::vector< BspTriangle >& polyList )
{
/**
* The current hueristic is blind least-split
*/
// run through the list, searching for the best one.
// the highest BspTriangle we'll bother testing (10% of total)
int maxCheck;
maxCheck = (int)(polyList.size() * percentageToCheck);
if( !maxCheck ) maxCheck = 1;
int bestSplits = 100000;
int bestIndex = -1;
int currSplits; // 这个平面总共分割了多少平面
int frontCount, backCount;
Plane3 currPlane;
for(int i=0; i<maxCheck; i++ )
{
currSplits = 0;
frontCount = backCount = 0;
currPlane = Plane3( polyList[i] );
PointListLoc res;
for(unsigned int i2=0; i2< polyList.size(); i2++ )
{
if( i == i2 ) continue;
res = currPlane.TestPoly( polyList[i2] );
switch(res)
{
case plistSplit:
currSplits++;
break;
case plistFront:
frontCount++;
break;
case plistBack:
backCount++;
break;
}
}
int weight = abs(frontCount - backCount) + currSplits;
//int weight = currSplits;
if( weight < bestSplits )
{
bestSplits = weight;
bestIndex = i;
}
}
assert( bestIndex >= 0 );
return bestIndex;
}