/
ShaderParms.h
46 lines (32 loc) · 1.07 KB
/
ShaderParms.h
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
#pragma once
#include <vector>
#include "KeyObserverDelegate.h"
namespace entity
{
class ColourKey;
class KeyObserverMap;
/**
* @brief Helper class observing the "shaderParmNN" spawnargs and caching their values.
*
* Since the parm0..parm2 values are hardwired to the entity colour components as defined in the
* "_color" spawnarg this class needs a reference to the corresponding ColourKey class.
*/
class ShaderParms: public sigc::trackable
{
// The key observer map this class is adding the observers to
KeyObserverMap& _keyObserverMap;
ColourKey& _colourKey;
static const std::size_t MAX_ENTITY_SHADERPARMS = 12;
// We don't observer shaderParm0..shaderParm2 spawnargs
static const std::size_t MIN_SHADERPARM_NUM_TO_OBSERVE = 3;
// The cached values
std::vector<float> _parmValues;
public:
ShaderParms(KeyObserverMap& keyObserverMap, ColourKey& colourKey);
// Return the parm0..parm11 value
float getParmValue(int parmNum) const;
void addKeyObservers();
private:
void onShaderParmKeyValueChanged(std::size_t parm, const std::string& value);
};
} // namespace