Assignment 2 Discussion and FAQ

Question 1. Dealing with 'const'

Pbrt's Primitive interface defines the Insersect and IntersectP methods as const methods. However, your lazy K-D tree needs to modify internal structures as it builds out the tree as part of the implementation of these methods. The easiest solution to this problem is to declare all members of your lazy K-D tree class that get updated in these methods as mutable structures. In C++, mutable class members can be modified by const methods. For example, if you wanted a mutable integer foo, you'd declare it as:

mutable int foo;