本文整理汇总了C++中Octree::minX方法的典型用法代码示例。如果您正苦于以下问题:C++ Octree::minX方法的具体用法?C++ Octree::minX怎么用?C++ Octree::minX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Octree
的用法示例。
在下文中一共展示了Octree::minX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RayCast
MeshComponent* OctreeSpatialPartitions::RayCast(Ray ray, float* outDistance)
{
ScopedLock _lock(octree.elementsLock);
if (filterDuplicates)
lastRaycastBucket = nullptr;
Octree* currentLeaf = &octree;
float dist = 0;
Vector<3> point = ray.origin;
MeshComponent* result = nullptr;
float distance = 0;
while (true)
{
if (currentLeaf == nullptr)
break;
point = ray.origin + ray.direction * dist;
while (!currentLeaf->isLeaf())
{
currentLeaf = currentLeaf->child(point[0] > currentLeaf->centerX(), point[1] > currentLeaf->centerY(), point[2] > currentLeaf->centerZ());
}
float xDist = (ray.direction[0] < 0 ? currentLeaf->minX() : currentLeaf->maxX()) - point[0];
float yDist = (ray.direction[1] < 0 ? currentLeaf->minY() : currentLeaf->maxY()) - point[1];
float zDist = (ray.direction[2] < 0 ? currentLeaf->minZ() : currentLeaf->maxZ()) - point[2];
float xNext = dist + xDist / ray.direction[0];
float yNext = dist + yDist / ray.direction[1];
float zNext = dist + zDist / ray.direction[2];
float currentDistance;
MeshComponent* currentResult = RayCastPartition(currentLeaf, ray, ¤tDistance);
if (currentResult != nullptr)
{
if (aggressiveShortCircuit)
{
result = currentResult;
distance = currentDistance;
break;
}
else
{
if (result == nullptr || currentDistance < distance)
{
result = currentResult;
distance = currentDistance;
}
}
}
if (!aggressiveShortCircuit && result != nullptr && distance < xNext && distance < yNext && distance < zNext)
{
break;
}
if (xNext < yNext)
{
if (xNext < zNext)
{
dist = xNext;
currentLeaf = currentLeaf->neighborX(ray.direction[0] > 0);
continue;
}
}
else if (yNext < zNext)
{
dist = yNext;
currentLeaf = currentLeaf->neighborY(ray.direction[1] > 0);
continue;
}
dist = zNext;
currentLeaf = currentLeaf->neighborZ(ray.direction[2] > 0);
}
if (result != nullptr)
*outDistance = distance;
return result;
}