Photon Engine
2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TPhoton.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Utility/utility.h
"
4
#include "
Utility/traits.h
"
5
#include "
Math/TVector3.h
"
6
#include "
Core/LTA/SidednessAgreement.h
"
7
8
#include <utility>
9
#include <type_traits>
10
11
namespace
ph
12
{
13
14
enum class
EPhotonData
15
{
16
ThroughputRadiance
,
17
Pos
,
18
FromDir
,
19
GeometryNormal
,
20
PathLength
21
};
22
23
template
<
typename
T>
24
concept
CPhoton
= std::is_trivially_copyable_v<T> &&
requires
25
{
26
typename
T::PMPhotonTag;
27
};
28
29
template
<
typename
Derived>
30
class
TPhoton
31
{
32
public
:
33
using
PMPhotonTag
= void;
34
35
template
<EPhotonData TYPE>
36
static
constexpr
bool
has
();
37
38
template
<EPhotonData TYPE>
39
decltype
(
auto
)
get
()
const
;
40
41
template
<EPhotonData TYPE,
typename
T>
42
void
set
(
const
T& value);
43
44
// Hide special members as this class is not intended to be used polymorphically.
45
// It is derived class's choice to expose them (by defining them in public) or not.
46
protected
:
47
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS
(
TPhoton
);
48
};
49
50
template
<
typename
Derived>
51
template
<EPhotonData TYPE>
52
inline
constexpr
bool
TPhoton<Derived>::has
()
53
{
54
static_assert
(
requires
55
{
56
{ Derived::template impl_has<TYPE>() } ->
CSame<bool>
;
57
},
58
"A photon mapping photon type must implement a static method callable as "
59
"`impl_has<EPhotonData{}>() -> bool`."
);
60
61
return
Derived::template impl_has<TYPE>();
62
}
63
64
template
<
typename
Derived>
65
template
<EPhotonData TYPE>
66
inline
decltype
(
auto
)
TPhoton<Derived>::get
()
const
67
{
68
static_assert
(
requires
(
const
Derived derived)
69
{
70
{ derived.template impl_get<TYPE>() } ->
CNotSame<void>
;
71
},
72
"A photon mapping photon type must implement a method callable as "
73
"`impl_get<EPhotonData{}>() const -> (any type)`."
);
74
75
return
static_cast<
const
Derived&
>
(*this).template impl_get<TYPE>();
76
}
77
78
template
<
typename
Derived>
79
template
<EPhotonData TYPE,
typename
T>
80
inline
void
TPhoton<Derived>::set
(
const
T& value)
81
{
82
static_assert
(
requires
(Derived derived, T value)
83
{
84
{ derived.template impl_set<TYPE>(value) } ->
CSame<void>
;
85
},
86
"A photon mapping photon type must implement a method callable as "
87
"`impl_set<EPhotonData{}, T{}>(T{}) -> void`."
);
88
89
static_cast<
Derived&
>
(*this).template impl_set<TYPE>(value);
90
}
91
92
}
// end namespace ph
SidednessAgreement.h
TVector3.h
ph::TPhoton
Definition
TPhoton.h:31
ph::TPhoton::has
static constexpr bool has()
Definition
TPhoton.h:52
ph::TPhoton::get
decltype(auto) get() const
Definition
TPhoton.h:66
ph::TPhoton::set
void set(const T &value)
Definition
TPhoton.h:80
ph::TPhoton::PH_DEFINE_INLINE_RULE_OF_5_MEMBERS
PH_DEFINE_INLINE_RULE_OF_5_MEMBERS(TPhoton)
ph::TPhoton::PMPhotonTag
void PMPhotonTag
Definition
TPhoton.h:33
ph::CNotSame
Definition
traits.h:116
ph::CPhoton
Definition
TPhoton.h:24
ph::CSame
Definition
traits.h:113
ph
The root for all renderer implementations.
Definition
EEngineProject.h:6
ph::EPhotonData
EPhotonData
Definition
TPhoton.h:15
ph::EPhotonData::PathLength
@ PathLength
ph::EPhotonData::ThroughputRadiance
@ ThroughputRadiance
ph::EPhotonData::GeometryNormal
@ GeometryNormal
ph::EPhotonData::FromDir
@ FromDir
ph::EPhotonData::Pos
@ Pos
traits.h
utility.h
Source
Core
Renderer
PM
TPhoton.h
Generated by
1.11.0