Photon Engine 2.0.0-beta
A physically based renderer.
|
An object in the scene that a ray can intersect with. More...
#include <Intersectable.h>
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. | |
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".
|
virtualdefault |
|
pure virtual |
Calculates Axis-Aligned Bounding Box (AABB) of itself.
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 >.
|
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.
ray | The ray from a hit event. |
probe | The probe from a hit event. The process of detail calculation will destroy the probe. |
out_detail | Stores 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() ). |
Primitive
for more methods that can generate a hit event. 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.
|
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.
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 >.
|
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.
|
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.
|
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.
ray | The ray to test for intersection. |
probe | The probe to record the intersection. |
srcRay | The ray from a previous hit event. |
srcProbe | The probe from a hit event. The process of re-intersect will destroy the probe. |
ray
intersects the object.ray
and probe
). 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.