本文整理汇总了C++中AxisAlignedBoundingBox::getLowerCorner方法的典型用法代码示例。如果您正苦于以下问题:C++ AxisAlignedBoundingBox::getLowerCorner方法的具体用法?C++ AxisAlignedBoundingBox::getLowerCorner怎么用?C++ AxisAlignedBoundingBox::getLowerCorner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AxisAlignedBoundingBox
的用法示例。
在下文中一共展示了AxisAlignedBoundingBox::getLowerCorner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: build
//------------------------------------------------------------------------
void KdTreeNode::build(KdTree* tree, const AxisAlignedBoundingBox& aabb, unsigned int depth)
{
if (hasToStopBuilding(depth))
{
return;
}
float subcost = std::numeric_limits<float>::max();
float distance = std::numeric_limits<float>::max();
Vector3::AXIS axis = aabb.getDirection();
float lowerDistance = aabb.getLowerCorner().get(axis);
float greaterDistance = aabb.getGreaterCorner().get(axis);
// m_Spheres are sorted along axis to simplify the splitplane research
std::sort(m_Spheres->begin(), m_Spheres->end(), [&](const Sphere* s1, const Sphere* s2) {
return s1->getCenter().get(axis) < s2->getCenter().get(axis);
});
unsigned int greaterCount = unsigned int(m_Spheres->size());
unsigned int lowerCount = 0;
///////////////////////////
// Find best split plane //
///////////////////////////
for (auto it = m_Spheres->begin(); it != m_Spheres->end(); it++)
{
const Sphere* pSphere = *it;
const AxisAlignedBoundingBox& sphereAABB = pSphere->getAABB();
float newDistance;
float newSubcost;
newDistance = sphereAABB.getLowerCorner().get(axis);
if (lowerDistance < newDistance && newDistance < greaterDistance)
{
newSubcost = cost(aabb, lowerCount, greaterCount, newDistance, axis);
if (newSubcost < subcost)
{
distance = newDistance;
subcost = newSubcost;
}
}
greaterCount--;
lowerCount++;
newDistance = sphereAABB.getGreaterCorner().get(axis);
if (lowerDistance < newDistance && newDistance < greaterDistance)
{
newSubcost = cost(aabb, lowerCount, greaterCount, newDistance, axis);
if (newSubcost < subcost)
{
distance = newDistance;
subcost = newSubcost;
}
}
}
// if there is no interesting split
if (distance <= lowerDistance || greaterDistance <= distance)
{
return;
}
////////////////////
// Split the Node //
////////////////////
m_Axis = axis;
m_SplitDistance = distance;
AxisAlignedBoundingBox boxA = aabb.getLowerSubAABB(distance, axis);
AxisAlignedBoundingBox boxB = aabb.getGreaterSubAABB(distance, axis);
m_Nodes = tree->getNextNode();
tree->getNextNode(); // we allocate a pair, they are next to each other in memory
for (auto it = m_Spheres->begin(); it != m_Spheres->end(); it++)
{
const Sphere* pSphere = *it;
if (boxA.intersect(*pSphere))
{
getA()->add(pSphere);
}
if (boxB.intersect(*pSphere))
{
getB()->add(pSphere);
}
}
getA()->build(tree, boxA, depth + 1);
getB()->build(tree, boxB, depth + 1);
//.........这里部分代码省略.........