Dayz Build 1.29.163047, Scripts Rev. 123548
Dayz Code Explorer by Zeroy
Loading...
Searching...
No Matches
ppemanager.c
Go to the documentation of this file.
1
3{
4 static ref PPEManager m_Manager;
5
6 static void CreateManagerStatic()
7 {
8 if (m_Manager)
9 {
10 Debug.Log("PPEManagerStatic | CreateManagerStatic - PPEManager already exists");
11 return;
12 }
13
15 }
16
18 {
19 if (m_Manager)
20 {
21 m_Manager.Cleanup();
22 delete m_Manager;
23 }
24 }
25
28 {
29 return m_Manager;
30 }
31}
32
53class PPEManager extends Managed
54{
55 const int CAMERA_ID = 0;
56
57 protected bool m_ManagerInitialized;
58 protected ref map<int, ref PPEClassBase> m_PPEClassMap; //contains sorted postprocess classes, IDs in 'PostProcessEffectType' // <MaterialID,<material_class>>
59 protected ref map<int, ref array<int>> m_PPEMaterialUpdateQueueMap; //multiple levels of update queues, to allow for multiple dependent updates during same frame (greedy?)
61 protected ref array<ref PPERequesterBase> m_ExistingPostprocessRequests; //which requests are active overall. Does not have to be updating ATM!
62 protected ref array<ref PPERequesterBase> m_UpdatingRequests; //which requests are currently updating and processing
63
65 {
67 PPERequesterBank.Init();
68 }
69
70 void Cleanup()
71 {
72 PPERequesterBank.Cleanup();
73
75 {
78 m_UpdatingRequests.Clear();
79 m_PPEClassMap.Clear();
80 }
81 }
82
84 void Init()
85 {
86 //DbgPrnt("PPEDebug | PPEManager | m_ManagerInitialized: " + m_ManagerInitialized);
88 {
94
95 g_Game.GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update); //can be safely and easily 'disabled' here
97 }
98 }
99
137
139 protected void RegisterPPEClass(PPEClassBase material_class)
140 {
141 m_PPEClassMap.Set(material_class.GetPostProcessEffectID(), material_class);
142 }
143
145 {
146 //DbgPrnt("DataVerification | m_ColorTarget | SendMaterialValueData: " + PPERequestParamDataColor.Cast(data).m_ColorTarget[0] + "/" + PPERequestParamDataColor.Cast(data).m_ColorTarget[1] + "/" + PPERequestParamDataColor.Cast(data).m_ColorTarget[2] + "/" + PPERequestParamDataColor.Cast(data).m_ColorTarget[3]);
147 PPEClassBase mat_class = m_PPEClassMap.Get(data.GetMaterialID());
148 mat_class.InsertParamValueData(data);
149 SetMaterialParamUpdating(data.GetMaterialID(),data.GetParameterID(),PPEConstants.DEPENDENCY_ORDER_BASE);
150 }
151
153 void SetMaterialParamUpdating(int material_id, int parameter_id, int order)
154 {
155 if ( order > PPEConstants.DEPENDENCY_ORDER_HIGHEST )
156 {
157 //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | Order higher than max, ignoring! | mat/par/ord: " + material_id + "/" + parameter_id + "/" + order);
158 return;
159 }
160
161 PPEClassBase mat_class = m_PPEClassMap.Get(material_id);
162
163 //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | mat/par: " + material_id + "/" + parameter_id);
164 //insert material into queue
165 if ( !m_PPEMaterialUpdateQueueMap.Contains(order) )
167
168 int found = m_PPEMaterialUpdateQueueMap.Get(order).Find(material_id);
169 if ( found == -1 )
170 {
171 m_PPEMaterialUpdateQueueMap.Get(order).Insert(material_id);
172 }
173
174 mat_class.SetParameterUpdating(order,parameter_id);
175 }
176
178 void RemoveMaterialUpdating(int material_id, int order = 0)
179 {
180 if ( m_PPEMaterialUpdateQueueMap.Contains(order) )
181 {
182 m_PPEMaterialUpdateQueueMap.Get(order).RemoveItem(material_id);
183
184 if ( m_PPEMaterialUpdateQueueMap.Get(order).Count() == 0)
185 m_PPEMaterialUpdateQueueMap.Remove(order);
186 }
187 }
188
189 protected void ClearMaterialUpdating()
190 {
192 }
193
195 void SetRequestActive(PPERequesterBase request, bool active)
196 {
197 int found = m_ExistingPostprocessRequests.Find(request);
198 if ( active && found == -1 )
199 {
200 m_ExistingPostprocessRequests.Insert(request);
201 }
202 else if ( !active && found > -1 ) //should always be found in this case, redundant?
203 {
204 //RemoveActiveRequestFromMaterials(request);
205
206 m_ExistingPostprocessRequests.Remove(found);
207 }
208 }
209
211 void SetRequestUpdating(PPERequesterBase request, bool active)
212 {
214 {
215 Debug.Log("PPEManager | SetRequestUpdating | !m_UpdatingRequests");
216 return;
217 }
218
219 int idx = m_UpdatingRequests.Find(request);
220
221 if ( active && idx == -1 )
222 {
223 m_UpdatingRequests.Insert(request);
224 }
225 else if ( !active && idx > -1 )
226 {
227 m_UpdatingRequests.Remove(idx);
228 }
229 }
230
231 // Just a getter
232 bool GetExistingRequester(typename req, out PPERequesterBase ret)
233 {
234 int idx = m_ExistingPostprocessRequests.Find(PPERequesterBank.GetRequester(req));
235 if (idx > -1)
236 {
237 ret = m_ExistingPostprocessRequests.Get(idx);
238 return true;
239 }
240 return false;
241 }
242
244 {
245 foreach (typename requesterType : requesters)
246 {
247 PPERequesterBase ppeRequester;
248 GetExistingRequester(requesterType, ppeRequester);
249 if (ppeRequester && ppeRequester.IsRequesterRunning())
250 return true;
251 }
252
253 return false;
254 }
255
261 {
262 int count = req.GetActiveRequestStructure().Count();
263 int mat_id;
264 for (int i = 0; i < count; i++)
265 {
266 mat_id = req.GetActiveRequestStructure().GetKey(i);
267 PPEClassBase mat_class = m_PPEClassMap.Get(mat_id);
268 mat_class.RemoveRequest(req.GetRequesterIDX());
269 }
270 }
271
273 protected void RequestsCleanup()
274 {
275 }
276
278 void InsertUpdatedMaterial(int mat_id)
279 {
280 if ( m_UpdatedMaterials.Find(mat_id) == -1 )
281 m_UpdatedMaterials.Insert(mat_id);
282 }
283
284 //---------//
285 //PROCESSING
286 //---------//
287 protected void ProcessRequesterUpdates(float timeslice)
288 {
290 for (int i = 0; i < m_UpdatingRequests.Count(); i++)
291 {
292 //DbgPrnt("PPEDebug | ProcessRequesterUpdates | m_UpdatingRequests[i]: " + m_UpdatingRequests[i]);
293 req = m_UpdatingRequests.Get(i);
294 if (req)
295 req.OnUpdate(timeslice);
296 }
297 }
298
299 protected void ProcessMaterialUpdates(float timeslice)
300 {
301 for (int i = 0; i < m_PPEMaterialUpdateQueueMap.Count(); i++) //orders (levels?)
302 {
303 //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetKey " + i + ": " + m_PPEMaterialUpdateQueueMap.GetKey(i));
304 //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetElement - count " + i + ": " + m_PPEMaterialUpdateQueueMap.GetElement(i).Count());
305
306 for (int j = 0; j < m_PPEMaterialUpdateQueueMap.GetElement(i).Count(); j++)
307 {
308 PPEClassBase mat_class = m_PPEClassMap.Get(m_PPEMaterialUpdateQueueMap.GetElement(i).Get(j));
309 mat_class.OnUpdate(timeslice,i);
310 }
311 }
312 }
313
315 {
316 int material_id;
317 for (int i = 0; i < m_UpdatedMaterials.Count(); i++)
318 {
319 material_id = m_UpdatedMaterials.Get(i);
320 PPEClassBase mat_class = m_PPEClassMap.Get(material_id);
321 mat_class.ApplyValueChanges();
322 }
323
324 m_UpdatedMaterials.Clear();
326 }
327
328 void Update(float timeslice)
329 {
331 return;
332
333 ProcessRequesterUpdates(timeslice);
334 ProcessMaterialUpdates(timeslice);
336 RequestsCleanup(); //unused
337 }
338
340 Param GetPostProcessDefaultValues(int material, int parameter)
341 {
342 PPEClassBase mat_class = m_PPEClassMap.Get(material);
343 return mat_class.GetParameterCommandData(parameter).GetDefaultValues();
344 }
345
347 Param GetPostProcessCurrentValues(int material, int parameter)
348 {
349 PPEClassBase mat_class = m_PPEClassMap.Get(material);
350 return mat_class.GetParameterCommandData(parameter).GetCurrentValues();
351 }
352
353 //TODO - certain C++ events may change the actual material path with a graphics option changes. Reflect this on script-side!
354 //Currently only SSAY/HBAO affected...welp.
356 void ChangePPEMaterial(PostProcessPrioritiesCamera priority, PostProcessEffectType type, string path, bool scriptside_only)
357 {
358 if (m_PPEClassMap.Contains(type))
359 {
360 PPEClassBase mat_class = m_PPEClassMap.Get(type);
361 typename name = mat_class.Type();
362 PPEClassBase postprocess_capsule = PPEClassBase.Cast(name.Spawn());
363 postprocess_capsule.ChangeMaterialPathUsed(path);
364
365 if (postprocess_capsule.GetMaterial() == 0x0)
366 {
367 Debug.Log("PPEManager | Invalid material path " + path + " used for " + name );
368 return;
369 }
370
371 //m_PPEClassMap.Remove(type);
372 m_PPEClassMap.Set(type,postprocess_capsule);
373 }
374
375 //can be sent script-side only to adapt to c++ options changes
376 if (!scriptside_only)
378 }
379
381 void StopAllEffects(int mask = 0)
382 {
384 {
386 {
387 if (requester.GetCategoryMask() & mask)
388 {
389 requester.Stop();
390 }
391 }
392 }
393 }
394
395 void DbgPrnt(string text)
396 {
397 //Debug.Log(""+text);
398 }
399};
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Definition debug.c:2
static void Log(string message=LOG_DEFAULT, string plugin=LOG_DEFAULT, string author=LOG_DEFAULT, string label=LOG_DEFAULT, string entity=LOG_DEFAULT)
Prints debug message with normal prio.
Definition debug.c:182
TODO doc.
Definition enscript.c:118
static void Init()
static void Cleanup()
ChromAber - PostProcessEffectType.ChromAber.
Definition ppechromaber.c:3
Created once, on manager init. Script-side representation of C++ material class, separate handling.
Material GetMaterial()
int GetPostProcessEffectID()
Overriden in all material classes!
void InsertParamValueData(PPERequestParamDataBase request_data)
Distributes requester data to the material class structure and links them to appropriate parameter.
void SetParameterUpdating(int order, int parameter_id)
Queue specific parameter of this material to update.
void ChangeMaterialPathUsed(string path)
PPEMatClassParameterCommandData GetParameterCommandData(int parameter_idx)
Some PP effects are handled as hard-coded exceptions, outside of material system. Default == PPEExcep...
void RemoveRequest(int req_idx)
unused, see 'RemoveActiveRequestFromMaterials' for more info
void OnUpdate(float timeslice, int order)
generic update method, take care when overriding!
ColorGrading - PostProcessEffectType.ColorGrading.
Colors - PostProcessEffectType.Colors.
Definition ppecolors.c:4
DOF postprocess, does not directly use materials.
Definition ppedof.c:6
DepthOfField - PostProcessEffectType.DepthOfField.
Distort - PostProcessEffectType.Distort.
Definition ppedistort.c:3
DynamicBlur - PostProcessEffectType.DynamicBlur.
EV postprocess, does not directly use materials.
Eye Accomodation postprocess, does not directly use materials.
FXAA - PostProcessEffectType.FXAA.
Definition ppefxaa.c:3
FilmGrain - PostProcessEffectType.FilmGrain.
Definition ppefilmgrain.c:7
GaussFilter - PostProcessEffectType.GaussFilter.
Ghost - PostProcessEffectType.Ghost.
Definition ppeghost.c:3
Glow - PostProcessEffectType.Glow.
Definition ppeglow.c:8
GodRays - PostProcessEffectType.GodRays.
Definition ppegodrays.c:3
HBAO - PostProcessEffectType.HBAO.
Definition ppehbao.c:4
g_Game.NightVissionLightParams, does not directly use materials. Controls light multiplication and fi...
Static component of PPE manager, used to hold the instance.
Definition ppemanager.c:3
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition ppemanager.c:27
static ref PPEManager m_Manager
Definition ppemanager.c:4
static void CreateManagerStatic()
Definition ppemanager.c:6
static void DestroyManagerStatic()
Definition ppemanager.c:17
Param GetCurrentValues()
Careful, only actual values, WITHOUT string.
Param GetDefaultValues()
Careful, formating is such, that param1 is ALWAYS string, containing parameter name,...
Median - PostProcessEffectType.Median.
Definition ppemedian.c:4
Dummy class - PostProcessEffectType.None.
Definition ppenone.c:3
RadialBlur - PostProcessEffectType.RadialBlur.
Rain - PostProcessEffectType.Rain.
Definition pperain.c:3
Data for one material parameter, requester side.
map< int, ref map< int, ref PPERequestParamDataBase > > GetActiveRequestStructure()
void OnUpdate(float delta)
int GetRequesterIDX()
Returns requester index.
Rotation Blur.
Definition pperotblur.c:3
SMAA - PostProcessEffectType.SMAA.
Definition ppesmaa.c:3
SSAO - PostProcessEffectType.SSAO.
Definition ppessao.c:3
SunMask - PostProcessEffectType.SunMask.
Definition ppesunmask.c:4
UnderWater - PostProcessEffectType.UnderWater.
WetDistort - PostProcessEffectType.WetDistort.
Base Param Class with no parameters.
Definition param.c:12
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZGame g_Game
Definition dayzgame.c:3942
PostProcessEffectType
Post-process effect type.
Definition enworld.c:72
proto native void SetCameraPostProcessEffect(int cam, int priority, PostProcessEffectType type, string materialPath)
set postprocess effect to camera To disable effect in some prioroty ppEffect, just set effectName or ...
const int CALL_CATEGORY_GUI
Definition tools.c:9
proto native volatile void Update()
PostProcessPrioritiesCamera
PPE type priorities, C++ based. DO NOT CHANGE ORDER! Used only when calling 'SetCameraPostProcessEffe...
Definition ppeconstants.c:3
void DbgPrnt(string text)
Definition ppemanager.c:395
ref map< int, ref array< int > > m_PPEMaterialUpdateQueueMap
Definition ppemanager.c:59
bool m_ManagerInitialized
Definition ppemanager.c:57
ref array< ref PPERequesterBase > m_ExistingPostprocessRequests
Definition ppemanager.c:61
void PPEManager()
Definition ppemanager.c:64
void SetRequestActive(PPERequesterBase request, bool active)
Marks requester as 'active'. Currently indistinguiishable from 'updating' requester,...
Definition ppemanager.c:195
void InsertUpdatedMaterial(int mat_id)
Marks material class as updated and values to be set in the course of update - 'ProcessApplyValueChan...
Definition ppemanager.c:278
class PPEManagerStatic CAMERA_ID
/brief Postprocess manager, responsible for updates, receiving, and re-distributing requester data to...
void RequestsCleanup()
Unused cleanup method, should it be ever needed.
Definition ppemanager.c:273
bool IsAnyRequesterRunning(array< typename > requesters)
Definition ppemanager.c:243
void ProcessRequesterUpdates(float timeslice)
Definition ppemanager.c:287
void ProcessApplyValueChanges()
Definition ppemanager.c:314
ref array< int > m_UpdatedMaterials
Definition ppemanager.c:60
ref map< int, ref PPEClassBase > m_PPEClassMap
Definition ppemanager.c:58
void InitPPEManagerClassMap()
Ordered by 'PostProcessEffectType' for easy access through the same enum; ID saved all the same.
Definition ppemanager.c:101
ref array< ref PPERequesterBase > m_UpdatingRequests
Definition ppemanager.c:62
Param GetPostProcessDefaultValues(int material, int parameter)
Returns default values as Param. See 'PPEConstants' file for various typedefs used.
Definition ppemanager.c:340
void ChangePPEMaterial(PostProcessPrioritiesCamera priority, PostProcessEffectType type, string path, bool scriptside_only)
Changes material file associated with the script material class. Will be used very rarely,...
Definition ppemanager.c:356
void RegisterPPEClass(PPEClassBase material_class)
Registeres material class and creates data structure within.
Definition ppemanager.c:139
void RemoveActiveRequestFromMaterials(PPERequesterBase req)
/brief Originally designed to rip the requester data from all relevant mat/params,...
Definition ppemanager.c:260
void SetMaterialParamUpdating(int material_id, int parameter_id, int order)
Queues material/parameter to update (once).
Definition ppemanager.c:153
void SendMaterialValueData(PPERequestParamDataBase data)
Definition ppemanager.c:144
void ClearMaterialUpdating()
Definition ppemanager.c:189
void RemoveMaterialUpdating(int material_id, int order=0)
Currently unused, requests remain in the hierarchy and are used when needed (slightly faster than con...
Definition ppemanager.c:178
void SetRequestUpdating(PPERequesterBase request, bool active)
Marks requester as 'updating' and to be processed on manager update.
Definition ppemanager.c:211
void ProcessMaterialUpdates(float timeslice)
Definition ppemanager.c:299
bool GetExistingRequester(typename req, out PPERequesterBase ret)
Definition ppemanager.c:232
Param GetPostProcessCurrentValues(int material, int parameter)
Returns current values as Param. See 'PPEConstants' file for various typedefs used.
Definition ppemanager.c:347