forked from mapsme/omim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuniform_values_storage.cpp
128 lines (106 loc) · 3.11 KB
/
uniform_values_storage.cpp
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#include "drape/uniform_values_storage.hpp"
#include "base/assert.hpp"
#include "std/algorithm.hpp"
#include "std/bind.hpp"
namespace dp
{
void UniformValuesStorage::SetIntValue(string const & name, int32_t v)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetIntValue(v);
else
m_uniforms.push_back(UniformValue(name, v));
}
void UniformValuesStorage::SetIntValue(string const & name, int32_t v1, int32_t v2)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetIntValue(v1, v2);
else
m_uniforms.push_back(UniformValue(name, v1, v2));
}
void UniformValuesStorage::SetIntValue(string const & name, int32_t v1, int32_t v2, int32_t v3)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetIntValue(v1, v2, v3);
else
m_uniforms.push_back(UniformValue(name, v1, v2, v3));
}
void UniformValuesStorage::SetIntValue(string const & name, int32_t v1, int32_t v2, int32_t v3, int32_t v4)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetIntValue(v1, v2, v3, v4);
else
m_uniforms.push_back(UniformValue(name, v1, v2, v3, v4));
}
void UniformValuesStorage::SetFloatValue(string const & name, float v)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetFloatValue(v);
else
m_uniforms.push_back(UniformValue(name, v));
}
void UniformValuesStorage::SetFloatValue(string const & name, float v1, float v2)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetFloatValue(v1, v2);
else
m_uniforms.push_back(UniformValue(name, v1, v2));
}
void UniformValuesStorage::SetFloatValue(string const & name, float v1, float v2, float v3)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetFloatValue(v1, v2, v3);
else
m_uniforms.push_back(UniformValue(name, v1, v2, v3));
}
void UniformValuesStorage::SetFloatValue(string const & name, float v1, float v2, float v3, float v4)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetFloatValue(v1, v2, v3, v4);
else
m_uniforms.push_back(UniformValue(name, v1, v2, v3, v4));
}
void UniformValuesStorage::SetMatrix4x4Value(string const & name, float const * matrixValue)
{
UniformValue * uniform = findByName(name);
if (uniform)
uniform->SetMatrix4x4Value(matrixValue);
else
m_uniforms.emplace_back(name, matrixValue);
}
bool UniformValuesStorage::operator< (UniformValuesStorage const & other) const
{
if (m_uniforms.size() < other.m_uniforms.size())
return true;
if (m_uniforms.size() > other.m_uniforms.size())
return false;
for (size_t i = 0; i < m_uniforms.size(); ++i)
{
if (m_uniforms[i] < other.m_uniforms[i])
return true;
}
return false;
}
namespace
{
bool isNameEqual(string const & name, UniformValue const & value)
{
return name == value.GetName();
}
} // namespace
UniformValue * UniformValuesStorage::findByName(string const & name)
{
uniforms_t::iterator it = find_if(m_uniforms.begin(), m_uniforms.end(), bind(&isNameEqual, name, _1));
if (it == m_uniforms.end())
return NULL;
return &(*it);
}
} // namespace dp