BVH 树 - 确定子节点相交顺序的方法?

BVH trees - ways to determine child nodes intersection order?

只是提一下,我的数学能力不是很好,我需要在这里寻求一点帮助!

我现在正在尝试使用这篇论文实现一个无栈BVH遍历函数: https://graphics.cg.uni-saarland.de/fileadmin/cguds/papers/2011/hapala_sccg2011/hapala_sccg2011.pdf

我正在让它工作,除了我可能没有正确的两个子遍历顺序导致图像错误。

在点(3 算法大纲)中,他们提到了几种确定正确顺序的方法:

For the traversal order there are various different alternatives. One often-used option is to store, for each node, the coordinate axis along which the builder split the parent node, and to use the ray’s direction sign in this dimension to determine the two nodes’ traversal order.

假设我将 X、Y、Z 和射线方向的拆分轴索引设为 0、1、2...它可以通过计算两个节点质心的最大分离轴来确定拆分轴我也有苍蝇...

所以,问题是通过使用射线方向和分割轴来确定节点遍历顺序的方式(数学)是什么?

use the ray’s direction sign in this dimension to determine the two nodes’ traversal order.

假设你的光线有方向(0.707, 0, -0.707)

对于那条射线:

如果你确定 parent 的分裂轴是 X (即两个 children 在 YZ 平面上共享一个边界),那么你的光线的X中方向符号为正(0.707),应先遍历质心坐标较高X的child

如果你确定parent的分裂轴为Y(即两个children在XZ平面上共享一个边界),那么你的射线Y 中的方向是无符号的 (0),您必须决定要做什么。在这种情况下你做什么的细节取决于你(选择一个方向,移动到下一个坐标等)但始终如一地行动是关键。

如果你确定 parent 的分裂轴是 Z(即 children 在 XY 平面上共享一个边界),那么你的光线的Z中的方向为负(-.707),应先遍历质心Z坐标较低的child。