当前位置: 首页>>代码示例>>C++>>正文


C++ AxisAlignedBox::addPoint方法代码示例

本文整理汇总了C++中AxisAlignedBox::addPoint方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::addPoint方法的具体用法?C++ AxisAlignedBox::addPoint怎么用?C++ AxisAlignedBox::addPoint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AxisAlignedBox的用法示例。


在下文中一共展示了AxisAlignedBox::addPoint方法的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);
        }
    }
}
开发者ID:neilsh,项目名称:ShortHike,代码行数:49,代码来源:KDTree.cpp


注:本文中的AxisAlignedBox::addPoint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。