You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The bvh_node::hit function is designed to be as fast as possible.
We expect (and want) the BVH to be filled as evenly as possible.
A node with only a single object_span should either be a scene hittable_list with a single object, or a leaf of a much bigger tree.
Optimizing a bvh with 1 node, or the leaves of a BVH, is an O(1) optimization.
We would make the O(1) case faster.
We would unfortunately be adding more checks to every other node. So we would have a O(LogN) loss.
This is a bad trade off.
Furthermore, checking the same node twice in a row won't actually be twice as long. With caching it'll take meaningfully less than that, maybe ~1.5-1.7x
If you're familiar with profiling code, I strongly suggest profiling your own code and getting an intuition for where the optimization and bottlenecks are in the code.
This was an awesome catch.
It's just not necessarily a performance bug.
During the construction of the BVH tree, the following case will create a leaf's parent node whose left and right pointers being equal:
Which will result in the leaf object's
hit()
function getting invoked twice inbvh_node::hit()
:This can be remedied by checking if
right
is not equal toleft
before executingright->hit(...)
.The text was updated successfully, but these errors were encountered: