blob: e72ee243ed3075a082ad6d4ff672dd8617a1a31b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#pragma once
#include "drape/glsl_types.hpp"
#include "base/assert.hpp"
#include <type_traits>
#include <utility>
namespace df
{
#define DECLARE_SETTER(name, field) \
template<typename T> struct Check##name \
{ \
private: \
static void Detect(...); \
template<typename U> static decltype(std::declval<U>().field) Detect(U const &); \
public: \
static constexpr bool Value = !std::is_same<void, decltype(Detect(std::declval<T>()))>::value; \
}; \
template <typename ParamsType> \
std::enable_if_t<Check##name<ParamsType>::Value> \
name(ParamsType & params) const \
{ \
params.field = field; \
} \
template <typename ParamsType> \
std::enable_if_t<!Check##name<ParamsType>::Value> \
name(ParamsType & params) const {}
struct FrameValues
{
glsl::mat4 m_projection;
glsl::mat4 m_pivotTransform;
float m_zScale = 1.0f;
template <typename ParamsType>
void SetTo(ParamsType & params) const
{
SetProjection(params);
SetPivotTransform(params);
SetZScale(params);
}
private:
DECLARE_SETTER(SetProjection, m_projection)
DECLARE_SETTER(SetPivotTransform, m_pivotTransform)
DECLARE_SETTER(SetZScale, m_zScale)
};
} // namespace df
|