C.4 Adding New Object Implementations

To sum up various details that have been spread across multiple chapters, three main steps are required in order to add a new implementation of one of pbrt’s interface types:

  1. The source files containing its implementation need to be added to the appropriate places in pbrt’s top-level CMakeLists.txt file, or they should be added to an appropriate preexisting source file so that they are compiled into the pbrt binary.
  2. The name of the type should be added to the list of types provided to the TaggedPointer that the corresponding interface type inherits from; this can be done by editing the appropriate header file in the base/ directory.
  3. The interface type’s Create() method should be modified to create an instance of the new type when it has been specified in the scene description.

It is probably a good idea to implement a static Create() method in the new type that takes a ParameterDictionary and such, to specify the object’s parameters in the same way that the existing classes do, but doing so is not a requirement.