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.

Base classes

class Surface
This is the abstract superclass for all surfaces.

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 and empty naive accelerator.

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 bounds() const -> Box3f override
Return the surface's world-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.

Returns true If an intersection was found

Detailed information about the intersection, if any, will be stored in the provided hit data record.