-
Notifications
You must be signed in to change notification settings - Fork 944
Description
In Section 3: Bounding Volume Hierarchies of "Ray Tracing: The Next Week", the first example given of a BVH (3.2) notes that the order of left and right children in a bvh_node
does not matter (emphasis mine):
Note that the blue and red bounding volumes are contained in the purple one, but they might overlap, and they are not ordered — they are just both inside. So the tree shown on the right has no concept of ordering in the left and right children; they are simply inside.
However, in the subsequent code for splitting BVH volumes (3.9), a constraint seems to be imposed where the left child of a bvh_node
always contains the objects which have axis value less than the right child. Specifically, in the code
} else if (object_span == 2) {
if (comparator(objects[start], objects[start+1])) {
left = objects[start];
right = objects[start+1];
} else {
left = objects[start+1];
right = objects[start];
}
} else {
When the current objects
list has only 2 objects, the given code always places the object with the lesser coordinate along the chosen axis in the left child. However, why can't we just always set left = objects[start];
and right = objects[start + 1];
, saving a call to comparator
? Doesn't the ordering of the left and right children not matter, as stated before? If it does, then why does the ordering matter now?