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