SurfaceGroup class

A collection of Surfaces grouped together.

Provides an interface for treating a collection of Surfaces as a single Surface. This base class implements a naive linear-time intersection routine which simply intersects each ray with every child Surface.

This class also serves as the superclass for acceleration structures (such as BVHs, KD-Trees) which are responsible for performing ray-surface intersection tests against a collection of Surfaces.

We derive SurfaceGroup from XformedSurface so that nested SurfaceGroups can be individually positioned/oriented with respect to their parent.

Base classes

class XformedSurface
A convenience subclass of Surface for surfaces with a Transform.

Derived classes

struct BBH
An axis-aligned bounding box hierarchy acceleration structure.

Constructors, destructors, conversion operators

SurfaceGroup(const json& j = json::object())
Create a new naive accelerator, add children if they are specified in j.

Public functions

void add_child(shared_ptr<Surface> surface) override
Add a child surface.
auto intersect(const Ray3f& ray, HitInfo& hit) const -> bool override
Intersect a ray against all surfaces registered with the Accelerator.
auto local_bounds() const -> Box3f override
Return the surface's local-space AABB.

Protected variables

vector<shared_ptr<Surface>> m_surfaces
All children.

Function documentation

void SurfaceGroup::add_child(shared_ptr<Surface> surface) override

Add a child surface.

This function will become useful once we create groups of objects. The base class implementation just throws an error.

This function should only be used before build() is called.

bool SurfaceGroup::intersect(const Ray3f& ray, HitInfo& hit) const override

Intersect a ray against all surfaces registered with the Accelerator.

Parameters
ray in A 3-dimensional ray data structure with minimum/maximum extent information
hit out A detailed intersection record, which will be filled by the intersection query
Returns True if an intersection was found

Intersect a ray against this surface and return detailed intersection information.