Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
FullViewpoint.h
Go to the documentation of this file.
1#pragma once
2
4#include "Core/SurfaceHit.h"
5#include "Math/TVector2.h"
8
9#include <Common/assertion.h>
10#include <Common/primitive_type.h>
11
12#include <cstddef>
13
14namespace ph
15{
16
20class FullViewpoint : public TViewpoint<FullViewpoint>
21{
22public:
23 FullViewpoint() = default;
24
25 template<EViewpointData TYPE>
26 static constexpr bool impl_has();
27
28 template<EViewpointData TYPE>
29 decltype(auto) impl_get() const;
30
31 template<EViewpointData TYPE, typename T>
32 void impl_set(const T& value);
33
34private:
35 SurfaceHit m_surfaceHit;
36 math::Vector2R m_rasterCoord;
37 real m_radius;
38 real m_numPhotons;
39 math::Spectrum m_tau;
40 math::Spectrum m_viewThroughput;
41 math::Vector3R m_viewDir;
42 math::Spectrum m_viewRadiance;
43};
44
45// In-header Implementations:
46
47template<EViewpointData TYPE>
48inline constexpr bool FullViewpoint::impl_has()
49{
50 if constexpr(
53 TYPE == EViewpointData::Radius ||
55 TYPE == EViewpointData::Tau ||
57 TYPE == EViewpointData::ViewDir ||
59 {
60 return true;
61 }
62 else
63 {
64 return false;
65 }
66}
67
68template<EViewpointData TYPE>
69inline decltype(auto) FullViewpoint::impl_get() const
70{
71 if constexpr(TYPE == EViewpointData::SurfaceHit)
72 {
73 return m_surfaceHit;
74 }
75 else if constexpr(TYPE == EViewpointData::RasterCoord)
76 {
77 return math::Vector2D(m_rasterCoord);
78 }
79 else if constexpr(TYPE == EViewpointData::Radius)
80 {
81 return m_radius;
82 }
83 else if constexpr(TYPE == EViewpointData::NumPhotons)
84 {
85 return m_numPhotons;
86 }
87 else if constexpr(TYPE == EViewpointData::Tau)
88 {
89 return m_tau;
90 }
91 else if constexpr(TYPE == EViewpointData::ViewThroughput)
92 {
93 return m_viewThroughput;
94 }
95 else if constexpr(TYPE == EViewpointData::ViewDir)
96 {
97 return m_viewDir;
98 }
99 else if constexpr(TYPE == EViewpointData::ViewRadiance)
100 {
101 return m_viewRadiance;
102 }
103 else
104 {
105 PH_ASSERT_UNREACHABLE_SECTION();
106 return false;
107 }
108}
109
110template<EViewpointData TYPE, typename T>
111inline void FullViewpoint::impl_set(const T& value)
112{
113 if constexpr(TYPE == EViewpointData::SurfaceHit)
114 {
115 m_surfaceHit = value;
116 }
117 else if constexpr(TYPE == EViewpointData::RasterCoord)
118 {
119 m_rasterCoord = math::Vector2R(value);
120 }
121 else if constexpr(TYPE == EViewpointData::Radius)
122 {
123 m_radius = value;
124 }
125 else if constexpr(TYPE == EViewpointData::NumPhotons)
126 {
127 m_numPhotons = value;
128 }
129 else if constexpr(TYPE == EViewpointData::Tau)
130 {
131 m_tau = value;
132 }
133 else if constexpr(TYPE == EViewpointData::ViewThroughput)
134 {
135 m_viewThroughput = value;
136 }
137 else if constexpr(TYPE == EViewpointData::ViewDir)
138 {
139 m_viewDir = value;
140 }
141 else if constexpr(TYPE == EViewpointData::ViewRadiance)
142 {
143 m_viewRadiance = value;
144 }
145 else
146 {
147 PH_ASSERT_UNREACHABLE_SECTION();
148 }
149}
150
151}// end namespace ph
This viewpoint type stores all possible viewpoint data without any loss of information....
Definition FullViewpoint.h:21
void impl_set(const T &value)
Definition FullViewpoint.h:111
static constexpr bool impl_has()
Definition FullViewpoint.h:48
FullViewpoint()=default
decltype(auto) impl_get() const
Definition FullViewpoint.h:69
General information about a ray-surface intersection event.
Definition SurfaceHit.h:59
Definition TViewpoint.h:32
Definition TTristimulusSpectrum.h:11
TVector2< float64 > Vector2D
Definition math_fwd.h:47
TVector2< real > Vector2R
Definition math_fwd.h:45
The root for all renderer implementations.
Definition EEngineProject.h:6