Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PrimitivePosPdfQuery.h
Go to the documentation of this file.
1#pragma once
2
3#include "Math/TVector3.h"
4#include "Core/Ray.h"
5#include "Core/HitDetail.h"
6#include "Core/SurfaceHit.h"
7#include "Core/LTA/PDF.h"
8
9#include <Common/primitive_type.h>
10#include <Common/assertion.h>
11
12#include <optional>
13
14namespace ph { class HitDetail; }
15namespace ph { class PrimitivePosSampleInput; }
16namespace ph { class DirectEnergyPdfInput; }
17
18namespace ph
19{
20
24{
25public:
26 void set(const PrimitivePosSampleInput& posInput, const SurfaceHit& X);
27
28 void set(
29 const DirectEnergyPdfInput& pdfInput,
30 const lta::PDF& uvwPdf = {});
31
32 void set(
33 const SurfaceHit& X,
34 const std::optional<math::Vector3R>& observationPos = std::nullopt,
35 const lta::PDF& uvwPdf = {});
36
40 const SurfaceHit& getX() const;
41
44 math::Vector3R getPos() const;
45
48 math::Vector3R getUvw() const;
49
52 const lta::PDF& getUvwPdf() const;
53
56 const std::optional<math::Vector3R>& getObservationPos() const;
57
58private:
62 static std::optional<math::Vector3R> inferObservationPos(const SurfaceHit& X);
63
64 SurfaceHit m_X;
65 std::optional<math::Vector3R> m_observationPos;
66 lta::PDF m_uvwPdf{};
67#if PH_DEBUG
68 bool m_hasSet{false};
69#endif
70};
71
75{
76public:
77 void setPdf(const lta::PDF& pdf);
78
79 real getPdfA() const;
80 const lta::PDF& getPdf() const;
81
82 operator bool () const;
83
84private:
85 lta::PDF m_pdf{};
86};
87
101
102// In-header Implementations:
103
105 const SurfaceHit& X,
106 const std::optional<math::Vector3R>& observationPos,
107 const lta::PDF& uvwPdf)
108{
109 m_X = X;
110 m_observationPos = observationPos;
111 m_uvwPdf = uvwPdf;
112
113#if PH_DEBUG
114 m_hasSet = true;
115#endif
116}
117
119{
120 return m_X;
121}
122
124{
125 return getX().getPos();
126}
127
129{
130 return getX().getDetail().getUVW();
131}
132
134{
135 return m_uvwPdf;
136}
137
138inline const std::optional<math::Vector3R>& PrimitivePosPdfInput::getObservationPos() const
139{
140 return m_observationPos;
141}
142
144{
145 m_pdf = pdf;
146}
147
149{
150 return getPdf().getPdfA();
151}
152
154{
155 PH_ASSERT(*this);
156
157 return m_pdf;
158}
159
160inline PrimitivePosPdfOutput::operator bool () const
161{
162 return m_pdf;
163}
164
165}// end namespace ph
Input for DirectEnergyPdfQuery.
Definition DirectEnergyPdfQuery.h:19
math::Vector3R getUVW() const
Definition HitDetail.h:168
Input for PrimitivePosPdfOutput.
Definition PrimitivePosPdfQuery.h:24
math::Vector3R getPos() const
Get the sampled position.
Definition PrimitivePosPdfQuery.h:123
const lta::PDF & getUvwPdf() const
Definition PrimitivePosPdfQuery.h:133
const std::optional< math::Vector3R > & getObservationPos() const
Definition PrimitivePosPdfQuery.h:138
const SurfaceHit & getX() const
Definition PrimitivePosPdfQuery.h:118
void set(const PrimitivePosSampleInput &posInput, const SurfaceHit &X)
Definition PrimitivePosPdfQuery.cpp:8
math::Vector3R getUvw() const
Definition PrimitivePosPdfQuery.h:128
Output for PrimitivePosPdfOutput.
Definition PrimitivePosPdfQuery.h:75
real getPdfA() const
Definition PrimitivePosPdfQuery.h:148
void setPdf(const lta::PDF &pdf)
Definition PrimitivePosPdfQuery.h:143
const lta::PDF & getPdf() const
Definition PrimitivePosPdfQuery.h:153
Information for the probability of generating a specific sample point on a primitive.
Definition PrimitivePosPdfQuery.h:91
Input inputs
Definition PrimitivePosPdfQuery.h:96
Output outputs
Definition PrimitivePosPdfQuery.h:97
Input for PrimitivePosSampleQuery.
Definition PrimitivePosSampleQuery.h:22
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
const HitDetail & getDetail() const
Definition SurfaceHit.h:159
math::Vector3R getPos() const
Definition SurfaceHit.h:186
A sample from a Probability Density Function (PDF).
Definition PDF.h:14
real getPdfA() const
Definition PDF.h:93
The root for all renderer implementations.
Definition EEngineProject.h:6