Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::Intersectable Class Referenceabstract

An object in the scene that a ray can intersect with. More...

#include <Intersectable.h>

Inheritance diagram for ph::Intersectable:
ph::Intersector ph::MaskedIntersectable ph::Primitive ph::TransformedIntersectable ph::BruteForceIntersector ph::KdtreeIntersector ph::TBinaryBvhIntersector< Index > ph::TIndexedKdtreeIntersector< Index > ph::TWideBvhIntersector< N, Index > ph::PBasicSphere ph::PEmpty ph::PTriangle ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter > ph::TPIndexedKdTreeTriangleMesh< Index > ph::TransformedPrimitive

Public Member Functions

virtual ~Intersectable ()=default
 
virtual bool isIntersecting (const Ray &ray, HitProbe &probe) const =0
 Determine whether a given ray hits the object.
 
virtual bool reintersect (const Ray &ray, HitProbe &probe, const Ray &srcRay, HitProbe &srcProbe) const =0
 Intersect the intersected object again with a different ray.
 
virtual void calcHitDetail (const Ray &ray, HitProbe &probe, HitDetail *out_detail) const =0
 Calculates properties of a hit, such as coordinates and normal.
 
virtual math::AABB3D calcAABB () const =0
 Calculates Axis-Aligned Bounding Box (AABB) of itself.
 
virtual bool isOccluding (const Ray &ray) const
 Determines whether this object blocks the ray.
 
virtual bool mayOverlapVolume (const math::AABB3D &volume) const
 Conservatively checks whether this object overlaps a volume.
 

Detailed Description

An object in the scene that a ray can intersect with.

To construct a scene, we must populate it with some objects. Imagining you are beside a table with a mug on it, how would you describe the shape of those two objects? Specifically, how to represent them digitally in a computer? One way to do this is to model them using many triangles or quads. Take a triangle for example, in a renderer like Photon, simply store the three vertices of it is not enough: we need to support opearations on the stored data for it to be useful, this is what intersectables are meant for.

The most common operation is ray intersection test. We need to know whether a given ray is intersecting something, such as a triangle, for the rest of the system to work. Remember that we can also model the table and mug using other shapes such as quads, they should support the same operation set as triangles. Photon supports many kinds of object that can be intersected by rays, such as just-mentioned triangles and quads, and these objects are named after their capability: "intersectable".

Constructor & Destructor Documentation

◆ ~Intersectable()

virtual ph::Intersectable::~Intersectable ( )
virtualdefault

Member Function Documentation

◆ calcAABB()

◆ calcHitDetail()

virtual void ph::Intersectable::calcHitDetail ( const Ray & ray,
HitProbe & probe,
HitDetail * out_detail ) const
pure virtual

Calculates properties of a hit, such as coordinates and normal.

This method calculates a detailed description of a hit from the ray and probe involved in a hit event. For example, the ray and probe used for calling isIntersecting() can be the inputs of this method (if an intersection is found). The process of calculating intersection detail will destroy the input probe.

Parameters
rayThe ray from a hit event.
probeThe probe from a hit event. The process of detail calculation will destroy the probe.
out_detailStores the calculated details. This method calculates the essential details only. Some information such as coordinate bases will only be available if specifically requested afterwards (for an example, see HitDetail::computeBases()).
Note
See Primitive for more methods that can generate a hit event.
Warning
This method will destroy the probe.

Implemented in ph::Intersector, ph::MaskedIntersectable, ph::PBasicSphere, ph::PEmpty, ph::PLatLong01Sphere, ph::PLatLongEnvSphere, ph::Primitive, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, ph::TransformedIntersectable, and ph::TransformedPrimitive.

◆ isIntersecting()

virtual bool ph::Intersectable::isIntersecting ( const Ray & ray,
HitProbe & probe ) const
pure virtual

Determine whether a given ray hits the object.

Checks whether the specified ray intersects this intersectable. If there is an intersection, true is returned and a brief hit report is stored inside the probe. If there is no intersection, false is returned and the state of the probe is undefined. ray and probe can be used for obtaining hit detail if an intersection is found.

Note
Generates hit event (with ray and probe).

Implemented in ph::BruteForceIntersector, ph::Intersector, ph::KdtreeIntersector, ph::MaskedIntersectable, ph::PBasicSphere, ph::PEmpty, ph::PLatLongEnvSphere, ph::Primitive, ph::PTriangle, ph::TBinaryBvhIntersector< Index >, ph::TIndexedKdtreeIntersector< Index >, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, ph::TransformedIntersectable, ph::TransformedPrimitive, and ph::TWideBvhIntersector< N, Index >.

◆ isOccluding()

bool ph::Intersectable::isOccluding ( const Ray & ray) const
virtual

Determines whether this object blocks the ray.

If greater performance is desired, you can override the default implementation which simply calls isIntersecting(const Ray&, HitProbe&) const to do the job. The test generally considers the underlying shape as hollow (for closed shape), e.g., a sphere is not occluding a line segment inside the sphere.

This method does not provide any means to retrieve HitDetail. Focusing on testing occlusion can improve performance for some cases.

Reimplemented in ph::BruteForceIntersector, ph::PEmpty, ph::PLatLongEnvSphere, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TransformedIntersectable, and ph::TransformedPrimitive.

◆ mayOverlapVolume()

bool ph::Intersectable::mayOverlapVolume ( const math::AABB3D & volume) const
virtual

Conservatively checks whether this object overlaps a volume.

By conservative, it means true can be returned even though the object does not overlap the volume; but if it actually does, true must be returned. The default implementation performs conservative intersecting test using the AABB calculated by calcAABB(). Although false-positives are allowed for this method, providing an implementation with higher accuracy is benefitial for many algorithms used by the renderer. The test generally considers the underlying shape as hollow (for closed shape), while the volume is solid.

Reimplemented in ph::PBasicSphere, ph::PEmpty, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TransformedIntersectable, and ph::TransformedPrimitive.

◆ reintersect()

virtual bool ph::Intersectable::reintersect ( const Ray & ray,
HitProbe & probe,
const Ray & srcRay,
HitProbe & srcProbe ) const
pure virtual

Intersect the intersected object again with a different ray.

This method is different to isIntersecting(const Ray, HitProbe&) const. Given srcRay and srcProbe, this method performs an intersection test against the chain of intersectables recorded in srcProbe (so it is impossible to "discover" new intersectables with this method). Taking BVH as an example, the implementation may only record the intersected object in the probe so this method can bypass the entire BVH traversal.

Parameters
rayThe ray to test for intersection.
probeThe probe to record the intersection.
srcRayThe ray from a previous hit event.
srcProbeThe probe from a hit event. The process of re-intersect will destroy the probe.
Returns
Whether ray intersects the object.
Note
Generates hit event (with ray and probe).
Warning
This method will destroy srcProbe.

Implemented in ph::Intersector, ph::MaskedIntersectable, ph::PBasicSphere, ph::PEmpty, ph::Primitive, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, ph::TransformedIntersectable, and ph::TransformedPrimitive.


The documentation for this class was generated from the following files: