Apress / ray-tracing-gems

Source Code for "Ray Tracing Gems: High-Quality and Real-Time Rendering with DXR and Other APIs" by Eric Haines and Tomas Akenine-Möller

Home Page:https://www.apress.com/us/book/9781484244265

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Minor mistake in code sample

GaryHuan9 opened this issue · comments

In section 16.4.2.3 Hierarchical Transformation (p233), the first code sample is missing a curly braces between line 8 and 9 to close off the else statement:

 1 node = root;
 2 while (!node.isLeaf) {
 3     if (u < node.probLeft) {
 4         u /= node.probLeft;
 5         node = node.left;
 6     } else {
 7         u /= (1.0 - node.probLeft);
 8         node = node.right;
 9 }
10 // Ok. We have found a leaf with the correct probability!

Should be:

 1 node = root;
 2 while (!node.isLeaf) {
 3     if (u < node.probLeft) {
 4         u /= node.probLeft;
 5         node = node.left;
 6     } else {
 7         u /= (1.0 - node.probLeft);
 8         node = node.right;
 9     }                                 <<<<<<<<<<<<<<<<<<<<< Missing this
10 }
11 // Ok. We have found a leaf with the correct probability!