本文整理汇总了C++中AxisAlignedBox::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::clear方法的具体用法?C++ AxisAlignedBox::clear怎么用?C++ AxisAlignedBox::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox::clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createNode
void
KDTree::splitNode(int nodeIndex, const KDTriList& sourceTri, int level)
{
AxisAlignedBox triBox;
KDTriList myTriangles;
for(KDTriList::const_iterator iTriangle = sourceTri.begin(); iTriangle != sourceTri.end(); ++iTriangle) {
KDTriangle triangle = *iTriangle;
triBox.clear();
triBox.addPoint(triangle.vert0);
triBox.addPoint(triangle.vert0 + triangle.edge1);
triBox.addPoint(triangle.vert0 + triangle.edge2);
if(mNodes[nodeIndex].mBounds.intersect(triBox))
myTriangles.push_back(triangle);
}
// Split ends here
if(myTriangles.size() < MIN_KDTREE_TRIANGLES || level == MAX_KDTREE_LEVEL) {
for(int iChild = 0; iChild < KDTREE_CHILDREN; ++iChild)
mNodes[nodeIndex].mChildren[iChild] = 0;
mNodes[nodeIndex].mTriStart = mTriangles.size();
mNodes[nodeIndex].mTriNum = myTriangles.size();
mTriangles.resize(mTriangles.size() + myTriangles.size());
mTriangles.insert(mTriangles.begin() + mNodes[nodeIndex].mTriStart, myTriangles.begin(), myTriangles.end());
}
// No triangles stored, split children instead
else {
for(int iChild = 0; iChild < KDTREE_CHILDREN; ++iChild) {
AxisAlignedBox childBounds;
int splitDimension = level % 3;
for(int iDimension = 0; iDimension < 3; ++iDimension) {
if(iDimension == splitDimension) {
if(iChild & 0x1) {
childBounds.minPoint[iDimension] = mNodes[nodeIndex].mBounds.minPoint[iDimension];
childBounds.maxPoint[iDimension] = (mNodes[nodeIndex].mBounds.minPoint[iDimension] + mNodes[nodeIndex].mBounds.maxPoint[iDimension]) * 0.5f;
}
else {
childBounds.minPoint[iDimension] = (mNodes[nodeIndex].mBounds.minPoint[iDimension] + mNodes[nodeIndex].mBounds.maxPoint[iDimension]) * 0.5f;
childBounds.maxPoint[iDimension] = mNodes[nodeIndex].mBounds.maxPoint[iDimension];
}
}
else {
childBounds.minPoint[iDimension] = mNodes[nodeIndex].mBounds.minPoint[iDimension];
childBounds.maxPoint[iDimension] = mNodes[nodeIndex].mBounds.maxPoint[iDimension];
}
}
mNodes[nodeIndex].mChildren[iChild] = createNode(childBounds);
splitNode(mNodes[nodeIndex].mChildren[iChild], myTriangles, level + 1);
}
}
}