本文整理汇总了C++中AxisAlignedBox::OctantSplit方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBox::OctantSplit方法的具体用法?C++ AxisAlignedBox::OctantSplit怎么用?C++ AxisAlignedBox::OctantSplit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBox
的用法示例。
在下文中一共展示了AxisAlignedBox::OctantSplit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: box
Octree::Node::Node(const std::unordered_map<std::size_t, Triangle3D_t>& triangles, const AxisAlignedBox& box, std::size_t leafTriangles, std::size_t currentDepth, std::size_t maxDepth)
: box(box), isLeaf(false)
{
std::size_t numContainedTriangles = triangles.size();
if (numContainedTriangles > 0)
{
containedTriangles.reserve(numContainedTriangles);
for (const std::unordered_map<std::size_t, Triangle3D_t>::value_type& containedTriangle : triangles)
{
containedTriangles.push_back(containedTriangle.first);
}
if ((numContainedTriangles > leafTriangles) && (currentDepth < maxDepth))
{
std::array<AxisAlignedBox, 8> octants;
box.OctantSplit(octants);
for (int octantIndex = 0; octantIndex < 8; ++octantIndex)
{
std::unordered_map<std::size_t, Triangle3D_t> octantTriangles;
for (const std::unordered_map<std::size_t, Triangle3D_t>::value_type& containedTriangle : triangles)
{
if (octants[octantIndex].Intersects(containedTriangle.second))
{
octantTriangles[containedTriangle.first] = containedTriangle.second;
}
}
children[octantIndex] = std::make_unique<Node>(octantTriangles, octants[octantIndex], leafTriangles, currentDepth + 1, maxDepth);
}
}
else
{
isLeaf = true;
}
}
else
{
isLeaf = true;
}
}