Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter > Class Template Reference

#include <TMetaInjectionPrimitive.h>

Inheritance diagram for ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >:
ph::Primitive ph::Intersectable

Public Member Functions

 TMetaInjectionPrimitive (PrimitiveMetaGetter metaGetter, PrimitiveGetter primitiveGetter)
 
bool isIntersecting (const Ray &ray, HitProbe &probe) const override
 Determine whether a given ray hits the object.
 
bool reintersect (const Ray &ray, HitProbe &probe, const Ray &srcRay, HitProbe &srcProbe) const override
 Intersect the intersected object again with a different ray.
 
void calcHitDetail (const Ray &ray, HitProbe &probe, HitDetail *const out_detail) const override
 Calculates properties of a hit, such as coordinates and normal.
 
math::AABB3D calcAABB () const override
 Calculates Axis-Aligned Bounding Box (AABB) of itself.
 
bool isOccluding (const Ray &ray) const override
 Determines whether this object blocks the ray.
 
bool mayOverlapVolume (const math::AABB3D &volume) const override
 Conservatively checks whether this object overlaps a volume.
 
void genPosSample (PrimitivePosSampleQuery &query, SampleFlow &sampleFlow, HitProbe &probe) const override
 Generates a sample point on the surface of this primitive.
 
void calcPosPdf (PrimitivePosPdfQuery &query) const override
 Given a point on the surface of this primitive, calculates the PDF of sampling this point.
 
real calcExtendedArea () const override
 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.
 
const PrimitiveMetadatagetMetadata () const override
 
const auto * getInjectee () const
 Gets the primitive that has got metadata injected.
 
- Public Member Functions inherited from ph::Intersectable
virtual ~Intersectable ()=default
 

Constructor & Destructor Documentation

◆ TMetaInjectionPrimitive()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::TMetaInjectionPrimitive ( PrimitiveMetaGetter metaGetter,
PrimitiveGetter primitiveGetter )
inline

Member Function Documentation

◆ calcAABB()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
math::AABB3D ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::calcAABB ( ) const
inlineoverridevirtual

Calculates Axis-Aligned Bounding Box (AABB) of itself.

Implements ph::Primitive.

◆ calcExtendedArea()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
real ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::calcExtendedArea ( ) const
inlineoverridevirtual

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.

Returns
The extended area of this primitive. A zero return value means the concept of extended area does not apply to this primitive.

Reimplemented from ph::Primitive.

◆ calcHitDetail()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
void ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::calcHitDetail ( const Ray & ray,
HitProbe & probe,
HitDetail *const out_detail ) const
inlineoverridevirtual

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.

Implements ph::Primitive.

◆ calcPosPdf()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
void ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::calcPosPdf ( PrimitivePosPdfQuery & query) const
inlineoverridevirtual

Given a point on the surface of this primitive, calculates the PDF of sampling this point.

Reimplemented from ph::Primitive.

◆ genPosSample()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
void ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::genPosSample ( PrimitivePosSampleQuery & query,
SampleFlow & sampleFlow,
HitProbe & probe ) const
inlineoverridevirtual

Generates a sample point on the surface of this primitive.

Note
Generates hit event (with PrimitivePosSampleOutput::getObservationRay() and probe).

Reimplemented from ph::Primitive.

◆ getInjectee()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
const auto * ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::getInjectee ( ) const
inline

Gets the primitive that has got metadata injected.

Returns
Pointer to the primitive carried by PrimitiveGetter.

◆ getMetadata()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
const PrimitiveMetadata * ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::getMetadata ( ) const
inlineoverridevirtual
Returns
The metadata associated to this primitive. nullptr if not available.

Reimplemented from ph::Primitive.

◆ isIntersecting()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
bool ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::isIntersecting ( const Ray & ray,
HitProbe & probe ) const
inlineoverridevirtual

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).

Implements ph::Primitive.

◆ isOccluding()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
bool ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::isOccluding ( const Ray & ray) const
inlineoverridevirtual

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 from ph::Intersectable.

◆ mayOverlapVolume()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
bool ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::mayOverlapVolume ( const math::AABB3D & volume) const
inlineoverridevirtual

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 from ph::Intersectable.

◆ reintersect()

template<detail::CPrimitiveMetaGetter PrimitiveMetaGetter, detail::CPrimitiveGetter PrimitiveGetter>
bool ph::TMetaInjectionPrimitive< PrimitiveMetaGetter, PrimitiveGetter >::reintersect ( const Ray & ray,
HitProbe & probe,
const Ray & srcRay,
HitProbe & srcProbe ) const
inlineoverridevirtual

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.

Implements ph::Primitive.


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