Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
ppematclassparameterfloat.c
Go to the documentation of this file.
2{
3 protected ref map<int,ref array<float,int>> m_LayerInfo; //<priority,<value,operator>>
4
6 protected float m_ValueDefault;
7 protected float m_ValueMin;
8 protected float m_ValueMax;
9
10 void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
11 {
13 }
14
15 override void InitDefaults()
16 {
17 Class.CastTo(m_Float,m_Defaults);
18 //m_Float = PPETemplateDefFloat.Cast(m_Defaults);
19 m_ValueDefault = m_Float.param2;
20 m_ValueMin = m_Float.param3;
21 m_ValueMax = m_Float.param4;
22 }
23
24 override void InitCuttent()
25 {
26 m_CurrentValues = new Param1<float>(m_ValueDefault);
27 }
28
29 override int GetParameterVarType()
30 {
31 return PPEConstants.VAR_TYPE_FLOAT;
32 }
33
34 override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
35 {
36 super.Update(timeslice,p_total,setting_defaults,order);
37
38 int active_request_count = 0;
39
41
42 bool setting_value_zero = false;
43
44 float float_value_temp = 0.0;
45 float float_value_default = 0.0;
46 float float_value_total = 0.0;
47
48 if (p_total == null)
49 {
50 p_total = new Param1<float>(0.0);
51 }
52
53 if (m_RequestMap.Count() > 0)
54 {
55 m_LayerInfo.Clear();
56 }
57 else
58 {
59 //DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
61 m_Parent.ParamUpdateRemove(m_ParameterIndex);
62 return;
63 }
64
65 for ( int i = 0; i < m_RequestMap.Count(); i++ )
66 {
67 req_data = PPERequestParamDataFloat.Cast(m_RequestMap.GetElement(i));
68
69 if (req_data == null)
70 {
71 Error("Debug | PPEMatClassParameterFloat | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
72 continue;
73 }
74
75 setting_value_zero = req_data.IsSettingDefaultValues();
76
77 if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
78 {
79 //DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
80 continue;
81 }
82
83 if (setting_value_zero)
84 {
85 req_data.m_FloatTarget = 0;//min;
86 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | !data.m_DefaultTargetSet | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | req_data.m_FloatTarget: " + req_data.m_FloatTarget);
87 }
88 else
89 {
90 active_request_count++;
91 }
92
93 //evaluation
94 //--------------------------------
95 req_data.m_FloatLast = req_data.m_FloatCurrent;
96
97 if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
98 {
99 float_value_temp = req_data.m_FloatCurrent;
100 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
101 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | !req_data.m_UpdatingData | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | not updating, addaing current value into mix: " + float_value_temp);
102 continue;
103 }
104
105 float_value_temp = req_data.m_FloatTarget;
106
107 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
108 req_data.SetUpdatingDataValues(false);
109 if (setting_value_zero)
110 {
111 req_data.SetDataActive(false);
112 //RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
113 }
114 else
115 {
116 float_value_temp = req_data.m_FloatTarget;
117 PrepareLayerInfo(req_data.GetPriorityLayer(),float_value_temp,req_data.GetInteractionMask());
118 }
119
120 req_data.m_FloatCurrent = float_value_temp;
121 }
122
123 //---------------------------
124 //MASK handling and calculation
125 float value;
126 int operator;
127 bool override_active = false;
128
129 if ( m_ValueMax == 0.0 )
130 float_value_total = m_ValueDefault; //?
131 else
132 float_value_total = m_ValueDefault / m_ValueMax;
133
134 //float_value_total = Math.InverseLerp(m_ValueMin,m_ValueMax,m_ValueDefault);
135 float_value_default = float_value_total;
136
137 for ( i = 0; i < m_LayerInfo.Count(); i++ )
138 {
139 if ( override_active )
140 break;
141
142 value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
143 operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
144
145 switch (operator)
146 {
147 case PPOperators.LOWEST:
148 float_value_total = Math.Min(float_value_total,value);
149 break;
150
151 case PPOperators.HIGHEST:
152 float_value_total = Math.Max(float_value_total,value);
153 break;
154
155 case PPOperators.ADD:
156 //float_value_total = float_value_total + value - float_value_default;
157 float_value_total = float_value_total + value;
158 break;
159
160 case PPOperators.ADD_RELATIVE:
161 float_value_total = (1 - float_value_total) * value + float_value_total;
162 break;
163
164 case PPOperators.SUBSTRACT:
165 //float_value_total = float_value_total - value + float_value_default;
166 float_value_total = float_value_total - value;
167 break;
168
169 case PPOperators.SUBSTRACT_RELATIVE:
170 float_value_total = float_value_total - value * float_value_total;
171 break;
172
173 case PPOperators.SUBSTRACT_REVERSE:
174 //float_value_total = value - float_value_default - float_value_total;
175 float_value_total = value - float_value_total;
176 break;
177
178 case PPOperators.SUBSTRACT_REVERSE_RELATIVE:
179 float_value_total = value * float_value_total - float_value_total;
180 break;
181
182 case PPOperators.MULTIPLICATIVE:
183 //float_value_total = Math.Lerp(float_value_default, float_value_total, value);
184 float_value_total = float_value_total * value;
185 break;
186
187 case PPOperators.OVERRIDE:
188 float_value_total = value;
189 break;
190
191 case PPOperators.SET:
192 float_value_total = value;
193 break;
194 }
195
196 //DbgPrnt("m_LayerInfo | float_value_total pre-clamp: " + float_value_total + " | i: " + i);
197 float_value_total = Math.Clamp(float_value_total,0,1);
198
199 if ( operator == PPOperators.OVERRIDE )
200 {
201 //DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
202 override_active = true;
203 }
204
205 //RemovePriorityInfo(m_CommandLayersArray.Get(i));
206 }
207
208 m_CommandLayersArray.Clear();
209
210 //TODO - consider moving this up, if possible
211 if (active_request_count == 0)
212 {
214 }
215 else
216 {
217 float res = Math.Lerp(m_ValueMin,m_ValueMax,float_value_total);
218 Param1<float>.Cast(p_total).param1 = res; //converts back to absolute values
219 }
220
221 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
222 m_Parent.ParamUpdateRemove(m_ParameterIndex);
223
224 m_CurrentValues = p_total;
225 }
226
227 void PrepareLayerInfo(int layer, float value, int operator)
228 {
229 m_LayerInfo.Set(layer,{value,operator});
230 AddPriorityInfo(layer);
231 }
232
234 override void SetParameterValueDefault(inout Param p_total)
235 {
236 p_total = new Param1<float>(PPETemplateDefFloat.Cast(m_Defaults).param2);
237 m_CurrentValues = p_total;
238 //DbgPrnt("PPEDebug | PPEMatClassParameterFloat - UpdateParameterValues | exit 3 - zero value");
239 }
240}
241
243{
244 void PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
246 m_Dependencies = new map<int,ref array<int>>;
247 m_Dependencies.Set(PostProcessEffectType.Glow,{PPEGlow.PARAM_COLORIZATIONCOLOR, PPEGlow.PARAM_OVERLAYCOLOR});
Super root of all classes in Enforce script.
Definition enscript.c:11
Definition enmath.c:7
Created once, on manager init. Script-side representation of C++ material class, separate handling.
void PrepareLayerInfo(int layer, float value, int operator)
void AddPriorityInfo(int priority)
Adds 'layers' to be iterated throug.
override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
ref map< int, ref array< float, int > > m_LayerInfo
void PrepareLayerInfo(int layer, bool value, int operator)
override void SetParameterValueDefault(inout Param p_total)
No active requests for the mat. parameter value change, sets the value to DEFAULT.
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
PostProcessEffectType
Post-process effect type.
Definition enworld.c:72
void Error(string err)
Messagebox with error message.
Definition endebug.c:90
PPOperators
PP operators, specify operation between subsequent layers.
Param4< string, float, float, float > PPETemplateDefFloat
ref map< int, ref ColorValuesData > m_LayerInfo
class PPEMatClassParameterFloat extends PPEMatClassParameterCommandData PPEMatClassParameterFloatSaturation(int mat_idx, int parameter_idx, PPEClassBase parent)
void PPEMatClassParameterFloat(int mat_idx, int parameter_idx, PPEClassBase parent)
float m_ValueDefault
PPETemplateDefFloat m_Float
void PPERequestParamDataFloat(int requester_idx, int mat_id, int param_id, int data_type=0, int priority=0, int mask=PPOperators.SET, bool relative=false)
Widget m_Parent
Definition sizetochild.c:92