本文整理汇总了C++中BVHNode::getNObjs方法的典型用法代码示例。如果您正苦于以下问题:C++ BVHNode::getNObjs方法的具体用法?C++ BVHNode::getNObjs怎么用?C++ BVHNode::getNObjs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVHNode
的用法示例。
在下文中一共展示了BVHNode::getNObjs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: accumulate
void PhotonAccelerator::accumulate(const Intersection& is, Color flux)
{
BVHNode* currentNode = &nodes[0];
AABB& box = currentNode->getAABB();
Point3D point = is.mPosition;
if (!box.inside(point))
return;
std::stack<BVHNode> intersect_stack;
while (true) {
if (currentNode->isLeaf()) {
Vector3D v(point);
for (unsigned int i = currentNode->getIndex(); i < currentNode->getIndex() + currentNode->getNObjs(); ++i) {
Hitpoint& hp = *hps[i];
if ((v - hp.is.mPosition).length() <= hp.radius && hp.is.mNormal * is.mNormal >= 0) {
hp.newPhotonCount += 1;
hp.totalFlux += flux * hp.is.mMaterial->evalBRDF(hp.is, -is.mRay.dir);
}
}
} else {
BVHNode& left_node = nodes[currentNode->getIndex()];
BVHNode& right_node = nodes[currentNode->getIndex() + 1];
AABB& left_box = left_node.getAABB();
AABB& right_box = right_node.getAABB();
bool leftHit, rightHit;
leftHit = left_box.inside(point);
rightHit = right_box.inside(point);
if (leftHit && rightHit) {
currentNode = &left_node;
intersect_stack.push(right_node);
continue;
} else if (leftHit) {
currentNode = &left_node;
continue;
} else if (rightHit) {
currentNode = &right_node;
continue;
}
}
if (intersect_stack.empty())
return;
currentNode = &intersect_stack.top();
intersect_stack.pop();
}
}