Photon Engine 2.0.0-beta
A physically based renderer.
|
A physical shape in the scene. More...
#include <Primitive.h>
Public Member Functions | |
bool | isIntersecting (const Ray &ray, HitProbe &probe) const override=0 |
Determine whether a given ray hits the object. | |
void | calcHitDetail (const Ray &ray, HitProbe &probe, HitDetail *out_detail) const override=0 |
Calculates properties of a hit, such as coordinates and normal. | |
bool | reintersect (const Ray &ray, HitProbe &probe, const Ray &srcRay, HitProbe &srcProbe) const override=0 |
Intersect the intersected object again with a different ray. | |
math::AABB3D | calcAABB () const override=0 |
Calculates Axis-Aligned Bounding Box (AABB) of itself. | |
virtual void | genPosSample (PrimitivePosSampleQuery &query, SampleFlow &sampleFlow, HitProbe &probe) const |
Generates a sample point on the surface of this primitive. | |
virtual void | calcPosPdf (PrimitivePosPdfQuery &query) const |
Given a point on the surface of this primitive, calculates the PDF of sampling this point. | |
virtual real | calcExtendedArea () const |
Calculates the area extended by this primitive. The term "extended" implies single-sided, e.g., a triangle's extended area is half the absolute value of the cross product of its two edge vectors. To treat it as double-sided, you need to multiply the result by 2 manually. | |
virtual const PrimitiveMetadata * | getMetadata () const |
Public Member Functions inherited from ph::Intersectable | |
virtual | ~Intersectable ()=default |
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. | |
A physical shape in the scene.
|
overridepure virtual |
Calculates Axis-Aligned Bounding Box (AABB) of itself.
Implements ph::Intersectable.
Implemented in ph::PBasicSphere, ph::PEmpty, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, and ph::TransformedPrimitive.
|
inlinevirtual |
Calculates the area extended by this primitive. The term "extended" implies single-sided, e.g., a triangle's extended area is half the absolute value of the cross product of its two edge vectors. To treat it as double-sided, you need to multiply the result by 2 manually.
Reimplemented in ph::PBasicSphere, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, and ph::TransformedPrimitive.
|
overridepure 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. Implements ph::Intersectable.
Implemented in ph::PBasicSphere, ph::PEmpty, ph::PLatLong01Sphere, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, and ph::TransformedPrimitive.
|
virtual |
Given a point on the surface of this primitive, calculates the PDF of sampling this point.
Reimplemented in ph::PLatLong01Sphere, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, and ph::TransformedPrimitive.
|
virtual |
Generates a sample point on the surface of this primitive.
PrimitivePosSampleOutput::getObservationRay()
and probe
). Reimplemented in ph::PLatLong01Sphere, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, and ph::TransformedPrimitive.
|
inlinevirtual |
nullptr
if not available. Reimplemented in ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, and ph::TransformedPrimitive.
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
). Implements ph::Intersectable.
Implemented in ph::PBasicSphere, ph::PEmpty, ph::PLatLongEnvSphere, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, and ph::TransformedPrimitive.
|
overridepure 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
. Implements ph::Intersectable.
Implemented in ph::PBasicSphere, ph::PEmpty, ph::PTriangle, ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >, ph::TPIndexedKdTreeTriangleMesh< Index >, and ph::TransformedPrimitive.