A single triangle. This triangle type is for constructing simple shapes such as a quad or box. For more complex shapes, it is better to use a more space efficient primitive type for them.
More...
|
| PTriangle (const math::Vector3R &vA, const math::Vector3R &vB, const math::Vector3R &vC) |
|
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 *out_detail) const override |
| Calculates properties of a hit, such as coordinates and normal.
|
|
bool | mayOverlapVolume (const math::AABB3D &volume) const override |
| Conservatively checks whether this object overlaps a volume.
|
|
math::AABB3D | calcAABB () const override |
| Calculates Axis-Aligned Bounding Box (AABB) of itself.
|
|
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 math::Vector3R & | getNa () const |
|
const math::Vector3R & | getNb () const |
|
const math::Vector3R & | getNc () const |
|
const math::Vector3R & | getUVWa () const |
|
const math::Vector3R & | getUVWb () const |
|
const math::Vector3R & | getUVWc () const |
|
|
void | setNa (const math::Vector3R &nA) |
| Set vertex normals. Vertex normals are set to face normal by default.
|
|
void | setNb (const math::Vector3R &nB) |
|
void | setNc (const math::Vector3R &nC) |
|
|
void | setUVWa (const math::Vector3R &uvwA) |
| Set vertex parametric coordinates. Surface parametric coordinates are set to 0 by default.
|
|
void | setUVWb (const math::Vector3R &uvwB) |
|
void | setUVWc (const math::Vector3R &uvwC) |
|
virtual const PrimitiveMetadata * | getMetadata () const |
|
virtual | ~Intersectable ()=default |
|
virtual bool | isOccluding (const Ray &ray) const |
| Determines whether this object blocks the ray.
|
|
A single triangle. This triangle type is for constructing simple shapes such as a quad or box. For more complex shapes, it is better to use a more space efficient primitive type for them.
void ph::PTriangle::calcHitDetail |
( |
const Ray & | ray, |
|
|
HitProbe & | probe, |
|
|
HitDetail * | out_detail ) const |
|
overridevirtual |
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
-
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() ). |
- Note
- See
Primitive
for more methods that can generate a hit event.
- Warning
- This method will destroy the probe.
Implements ph::Primitive.
bool ph::PTriangle::isIntersecting |
( |
const Ray & | ray, |
|
|
HitProbe & | probe ) const |
|
overridevirtual |
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.
bool ph::PTriangle::mayOverlapVolume |
( |
const math::AABB3D & | volume | ) |
const |
|
overridevirtual |
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.
bool ph::PTriangle::reintersect |
( |
const Ray & | ray, |
|
|
HitProbe & | probe, |
|
|
const Ray & | srcRay, |
|
|
HitProbe & | srcProbe ) const |
|
overridevirtual |
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
-
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. |
- Returns
- Whether
ray
intersects the object.
- Note
- Generates hit event (with
ray
and probe
).
- Warning
- This method will destroy
srcProbe
.
Implements ph::Primitive.