File size: 3,773 Bytes
24b81cb
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
129
130
131
132
typedef map<int,ref PPERequestParamDataBase> ActiveParameterRequestsMap; //<request_ID, data>

class PPEMatClassParameterCommandData
{
	//default layer constants, complex data like colors PPEMatClassParameterColor are handled separately
	const int LAYER_INFO_VALUE = 0;
	const int LAYER_INFO_OPERATOR = 1;
	
	ref array<int> 									m_CommandLayersArray; //for tracking active priorities and sorting them //TODO - could have been 'set'..
	protected int 									m_UpdatedCount;
	protected int 									m_MaterialIndex; //just a helper
	protected int 									m_ParameterIndex;
	protected ref ActiveParameterRequestsMap 		m_RequestMap;//<request_ID, parameter data>
	protected PPEClassBase 							m_Parent;
	protected ref Param 							m_Defaults; // Careful, formating is such, that param1 is ALWAYS string, containing parameter name. Actual values follow.
	protected ref Param 							m_CurrentValues; // Careful, only actual values, WITHOUT string
	
	protected ref map<int,ref array<int>> 			m_Dependencies;
	
	void PPEMatClassParameterCommandData(int mat_idx, int parameter_idx, PPEClassBase parent)
	{
		m_MaterialIndex = mat_idx;
		m_ParameterIndex = parameter_idx;
		m_Parent = parent;
		
		m_CommandLayersArray = new array<int>;
		m_UpdatedCount = 0;
		m_RequestMap = new ActiveParameterRequestsMap;
	}
	
	int GetParameterVarType()
	{
		return -1;
	}
	
	void SetMaterialIndex(int value)
	{
		m_MaterialIndex = value;
	}
	
	void SetParameterIndex(int value)
	{
		m_ParameterIndex = value;
	}
	
	void SetParent(PPEClassBase parent)
	{
		m_Parent = parent;
	}
	
	void InsertRequestData(PPERequestParamDataBase request_data)
	{
		m_RequestMap.Set(request_data.GetRequesterIDX(),request_data);//<request_ID, data>
	}
	
	void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
	{
		//insert dependencies to another update round
		if ( m_Dependencies && m_Dependencies.Count() > 0 && order < PPEConstants.DEPENDENCY_ORDER_HIGHEST )
		{
			int key_mat = -1;
			int element_par = -1;
			for (int i = 0; i < m_Dependencies.Count(); i++)
			{
				key_mat = m_Dependencies.GetKey(i);
				for (int j = 0; j < m_Dependencies.GetElement(i).Count(); j++)
				{
					element_par = m_Dependencies.GetElement(i).Get(j);
					PPEManagerStatic.GetPPEManager().SetMaterialParamUpdating(key_mat,element_par,order + 1); // TODO - revise, currently only does one more update
				}
			}
		}
	}
	
	//! Modifies values to be used for setter methods later in the manager update. Currently used only on PPEMatClassParameterColor, TODO!!
	void ModifyResultValues(inout Param result_values)
	{
	}
	
	//! Adds 'layers' to be iterated throug
	void AddPriorityInfo(int priority)
	{
		if ( m_CommandLayersArray.Find(priority) == -1 )
		{
			m_CommandLayersArray.Insert(priority);
			m_CommandLayersArray.Sort();
		}
		else
		{
			//DbgPrnt("PPEDebug | PPEMatClassParameterCommandData - AddPriorityInfo | Already exists, values have been overwritten!");
		}
	}
	
	//! Currently unused; layer info gets cleared every update
	void RemovePriorityInfo(int priority)
	{
	}
	
	//! Adds name and default values from material registration, override on children to properly add for each type
	void RegisterDefaults(Param p)
	{
		m_Defaults = p;
		InitDefaults();
		InitCuttent();
	}
	
	protected void InitDefaults() {};
	
	protected void InitCuttent() {};
	
	protected void SetParameterValueDefault(inout Param p_total)
	{
	}
	
	//! Careful, formating is such, that param1 is ALWAYS string, containing parameter name, should it be needed. Actual values follow.
	Param GetDefaultValues()
	{
		return m_Defaults;
	}
	
	//! Careful, only actual values, WITHOUT string
	Param GetCurrentValues()
	{
		return m_CurrentValues;
	}
	
	void DbgPrnt(string text)
	{
		//Debug.Log(""+text);
	}
}