DayZ 1.24
Loading...
Searching...
No Matches
PPEManager.c
Go to the documentation of this file.
1
3{
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 GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update); //can be safely and easily 'disabled' here
96 m_ManagerInitialized = true;
97 }
98 }
99
133
136 {
137 m_PPEClassMap.Set(material_class.GetPostProcessEffectID(), material_class);
138 }
139
141 {
142 //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]);
143 PPEClassBase mat_class = m_PPEClassMap.Get(data.GetMaterialID());
144 mat_class.InsertParamValueData(data);
145 SetMaterialParamUpdating(data.GetMaterialID(), data.GetParameterID(), PPEConstants.DEPENDENCY_ORDER_BASE);
146 }
147
150 {
151 if (order > PPEConstants.DEPENDENCY_ORDER_HIGHEST)
152 {
153 //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | Order higher than max, ignoring! | mat/par/ord: " + material_id + "/" + parameter_id + "/" + order);
154 return;
155 }
156
158
159 //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | mat/par: " + material_id + "/" + parameter_id);
160 //insert material into queue
161 if (!m_PPEMaterialUpdateQueueMap.Contains(order))
163
165 if (found == -1)
167
168 mat_class.SetParameterUpdating(order, parameter_id);
169 }
170
173 {
175 {
177
178 if (m_PPEMaterialUpdateQueueMap.Get(order).Count() == 0)
180 }
181 }
182
183 protected void ClearMaterialUpdating()
184 {
186 }
187
190 {
192 if (active && found == -1)
194 else if (!active && found > -1) //should always be found in this case, redundant?
195 {
196 //RemoveActiveRequestFromMaterials(request);
197
199 }
200 }
201
204 {
206 {
207 Debug.Log("PPEManager | SetRequestUpdating | !m_UpdatingRequests");
208 return;
209 }
210
211 int idx = m_UpdatingRequests.Find(request);
212
213 if (active && idx == -1)
215 else if (!active && idx > -1)
216 m_UpdatingRequests.Remove(idx);
217 }
218
219 // Just a getter
221 {
222 int idx = m_ExistingPostprocessRequests.Find(PPERequesterBank.GetRequester(req));
223 if (idx > -1)
224 {
226 return true;
227 }
228 return false;
229 }
230
232 {
233 foreach (typename requesterType : requesters)
234 {
237 if (ppeRequester && ppeRequester.IsRequesterRunning())
238 return true;
239 }
240
241 return false;
242 }
243
249 {
250 int count = req.GetActiveRequestStructure().Count();
251 int mat_id;
252 for (int i = 0; i < count; i++)
253 {
254 mat_id = req.GetActiveRequestStructure().GetKey(i);
256 mat_class.RemoveRequest(req.GetRequesterIDX());
257 }
258 }
259
261 protected void RequestsCleanup()
262 {
263 }
264
267 {
268 if (m_UpdatedMaterials.Find(mat_id) == -1)
270 }
271
272 //---------//
273 //PROCESSING
274 //---------//
275 protected void ProcessRequesterUpdates(float timeslice)
276 {
278 for (int i = 0; i < m_UpdatingRequests.Count(); i++)
279 {
280 //DbgPrnt("PPEDebug | ProcessRequesterUpdates | m_UpdatingRequests[i]: " + m_UpdatingRequests[i]);
281 req = m_UpdatingRequests.Get(i);
282 if (req)
283 req.OnUpdate(timeslice);
284 }
285 }
286
287 protected void ProcessMaterialUpdates(float timeslice)
288 {
289 for (int i = 0; i < m_PPEMaterialUpdateQueueMap.Count(); i++) //orders (levels?)
290 {
291 //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetKey " + i + ": " + m_PPEMaterialUpdateQueueMap.GetKey(i));
292 //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetElement - count " + i + ": " + m_PPEMaterialUpdateQueueMap.GetElement(i).Count());
293
294 for (int j = 0; j < m_PPEMaterialUpdateQueueMap.GetElement(i).Count(); j++)
295 {
297 mat_class.OnUpdate(timeslice, i);
298 }
299 }
300 }
301
303 {
304 int material_id;
305 for (int i = 0; i < m_UpdatedMaterials.Count(); i++)
306 {
309 mat_class.ApplyValueChanges();
310 }
311
312 m_UpdatedMaterials.Clear();
314 }
315
316 void Update(float timeslice)
317 {
319 return;
320
324 RequestsCleanup(); //unused
325 }
326
329 {
331 return mat_class.GetParameterCommandData(parameter).GetDefaultValues();
332 }
333
336 {
338 return mat_class.GetParameterCommandData(parameter).GetCurrentValues();
339 }
340
341 //TODO - certain C++ events may change the actual material path with a graphics option changes. Reflect this on script-side!
342 //Currently only SSAY/HBAO affected...welp.
345 {
346 if (m_PPEClassMap.Contains(type))
347 {
349 typename name = mat_class.Type();
351 postprocess_capsule.ChangeMaterialPathUsed(path);
352
353 if (postprocess_capsule.GetMaterial() == 0x0)
354 {
355 Debug.Log("PPEManager | Invalid material path " + path + " used for " + name);
356 return;
357 }
358
359 //m_PPEClassMap.Remove(type);
361 }
362
363 //can be sent script-side only to adapt to c++ options changes
364 if (!scriptside_only)
366 }
367
369 void StopAllEffects(int mask = 0)
370 {
372 {
374 {
375 if (requester.GetCategoryMask() & mask)
376 requester.Stop();
377 }
378 }
379 }
380
381 void DbgPrnt(string text)
382 {
383 //Debug.Log(""+text);
384 }
385};
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
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:381
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:189
void InsertUpdatedMaterial(int mat_id)
Marks material class as updated and values to be set in the course of update - 'ProcessApplyValueChan...
Definition PPEManager.c:266
class PPEManagerStatic CAMERA_ID
void RequestsCleanup()
Unused cleanup method, should it be ever needed.
Definition PPEManager.c:261
bool IsAnyRequesterRunning(array< typename > requesters)
Definition PPEManager.c:231
void ProcessRequesterUpdates(float timeslice)
Definition PPEManager.c:275
void ProcessApplyValueChanges()
Definition PPEManager.c:302
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:328
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:344
void RegisterPPEClass(PPEClassBase material_class)
Registeres material class and creates data structure within.
Definition PPEManager.c:135
void RemoveActiveRequestFromMaterials(PPERequesterBase req)
Definition PPEManager.c:248
void SetMaterialParamUpdating(int material_id, int parameter_id, int order)
Queues material/parameter to update (once)
Definition PPEManager.c:149
void SendMaterialValueData(PPERequestParamDataBase data)
Definition PPEManager.c:140
void ClearMaterialUpdating()
Definition PPEManager.c:183
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:172
void SetRequestUpdating(PPERequesterBase request, bool active)
Marks requester as 'updating' and to be processed on manager update.
Definition PPEManager.c:203
void ProcessMaterialUpdates(float timeslice)
Definition PPEManager.c:287
bool GetExistingRequester(typename req, out PPERequesterBase ret)
Definition PPEManager.c:220
Param GetPostProcessCurrentValues(int material, int parameter)
Returns current values as Param. See 'PPEConstants' file for various typedefs used.
Definition PPEManager.c:335
Definition Debug.c:14
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:133
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.
ColorGrading - PostProcessEffectType.ColorGrading.
Colors - PostProcessEffectType.Colors.
Definition PPEColors.c:4
DOF postprocess, does not directly use materials.
Definition PPEDOF.c:6
DepthOfField - PostProcessEffectType.DepthOfField.
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.
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 void CreateManagerStatic()
Definition PPEManager.c:6
static PPEManager GetPPEManager()
Returns the manager instance singleton.
Definition PPEManager.c:27
static void DestroyManagerStatic()
Definition PPEManager.c:17
static ref PPEManager m_Manager
Definition PPEManager.c:4
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.
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. Used as general purpose parameter overloaded with Param1 to Para...
Definition param.c:12
proto native CGame GetGame()
PostProcessEffectType
Post-process effect type.
Definition EnWorld.c:72
proto native void SetCameraPostProcessEffect(int cam, int priority, PostProcessEffectType type, string materialPath)
const int CALL_CATEGORY_GUI
Definition tools.c:9
proto native volatile void Update()