First, we are going to modify the
Scene class to hold an Octree. This means dealing with some dynamic memory, so we also need to add a destructor. The copy constructor and assignment operator will be disabled. If an acceleration structure is present, we should forward operations such as raycasting to the accelerator. Of course, the original code needs to stay in place as the acceleration structure is optional.
Follow these steps to integrate the octree into the scene:
Sceneclass declared in
Scene.h. Add an
OctreeNodepointer to serve as the root node of the Octree. Set this pointer to
nullin the default constructor. The destructor should free this memory if it is allocated. Also, we need to declare the