You are viewing the course site for a past offering of this course. The current offering may be found here.
Lecture 9: Raytracing (74)
RichardChen9

Shouldn't the first base case return some sort of sentinel or maybe a large value since it will be compared in the caller?

Staffjrk

Great observation—yes! A real implementation probably would return something like either a special NULL hit, or a hit with t=FLOAT_MAX or similar, depending on how exactly you implemented the routine overall.

Caozongkai

Why do we still test both of the child? It would still cost linear time if we do this. (If the BVH acts like a BST, why it does not compare the left and right child then decide go one of the direction? This would only take log time)

amandaawan

you make an excellent point @caozongkai. But if you run through this recursive traversal, you will see that this basic check is done at the first step wherein we check whether the ray misses the node.bbox. For example, if we were at the root node, if the root's bounding box is missed, we won't recurse into the left and right children. If it isn't missed, and it turns out the relevant child is the right, when we call intersect on the left child, it would return false pretty quickly because of the bounding box check. This shows that we in fact do this check. However, since we choose the axis that we divide on in a node, it is entirely possible that the ray would hit more than 1 leaf node. In this case, we would still need to compare to find the nearest one.

You must be enrolled in the course to comment