Note: This website is archived. For up-to-date information about D projects and development, please visit wiki.dlang.org.

Tracing a ray is subdivided into two phases: setup and next.

The setup method, as defined in the SceneObject base class, configures the ThreadLocalSlab for a specific ray and performs precalculations, then returns a delegate that's usually taken from the "next" method on the ThreadLocalSlab. The "next" method takes a ref Hit parameter and updates it to the next point where the ray pierced the object.

For instance, tracing a ray that hits a sphere, setup will return a delegate that generates the first hit point, then on the next call generates the _second_ hit point on the backside of the sphere.

This makes CSG cheaper because rays don't have to be restarted on the inside of the object.