Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
ppemanager.c
Go to the documentation of this file.
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 
14  m_Manager = new PPEManager;
15  }
16 
17  static void DestroyManagerStatic()
18  {
19  if (m_Manager)
20  {
21  m_Manager.Cleanup();
22  delete m_Manager;
23  }
24  }
25 
27  static PPEManager GetPPEManager()
28  {
29  return m_Manager;
30  }
31 }
32 
53 class 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 
64  void PPEManager()
65  {
66  m_ManagerInitialized = false;
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 
101  protected void InitPPEManagerClassMap()
102  {
103  if (m_PPEClassMap)
104  {
105  delete m_PPEClassMap;
106  }
108 
109  RegisterPPEClass(new PPENone()); //dummy
111  RegisterPPEClass(new PPESSAO());
113  RegisterPPEClass(new PPEHBAO());
116  RegisterPPEClass(new PPERain());
124  RegisterPPEClass(new PPEGlow());
125  RegisterPPEClass(new PPESMAA());
126  RegisterPPEClass(new PPEFXAA());
132  RegisterPPEClass(new PPEDOF());
134  }
135 
137  protected void RegisterPPEClass(PPEClassBase material_class)
138  {
139  m_PPEClassMap.Set(material_class.GetPostProcessEffectID(), material_class);
140  }
141 
143  {
144  //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]);
145  PPEClassBase mat_class = m_PPEClassMap.Get(data.GetMaterialID());
146  mat_class.InsertParamValueData(data);
147  SetMaterialParamUpdating(data.GetMaterialID(),data.GetParameterID(),PPEConstants.DEPENDENCY_ORDER_BASE);
148  }
149 
151  void SetMaterialParamUpdating(int material_id, int parameter_id, int order)
152  {
153  if ( order > PPEConstants.DEPENDENCY_ORDER_HIGHEST )
154  {
155  //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | Order higher than max, ignoring! | mat/par/ord: " + material_id + "/" + parameter_id + "/" + order);
156  return;
157  }
158 
159  PPEClassBase mat_class = m_PPEClassMap.Get(material_id);
160 
161  //DbgPrnt("PPEDebug | PPEManager - SetMaterialParamUpdating | mat/par: " + material_id + "/" + parameter_id);
162  //insert material into queue
163  if ( !m_PPEMaterialUpdateQueueMap.Contains(order) )
165 
166  int found = m_PPEMaterialUpdateQueueMap.Get(order).Find(material_id);
167  if ( found == -1 )
168  {
169  m_PPEMaterialUpdateQueueMap.Get(order).Insert(material_id);
170  }
171 
172  mat_class.SetParameterUpdating(order,parameter_id);
173  }
174 
176  void RemoveMaterialUpdating(int material_id, int order = 0)
177  {
178  if ( m_PPEMaterialUpdateQueueMap.Contains(order) )
179  {
180  m_PPEMaterialUpdateQueueMap.Get(order).RemoveItem(material_id);
181 
182  if ( m_PPEMaterialUpdateQueueMap.Get(order).Count() == 0)
183  m_PPEMaterialUpdateQueueMap.Remove(order);
184  }
185  }
186 
187  protected void ClearMaterialUpdating()
188  {
190  }
191 
193  void SetRequestActive(PPERequesterBase request, bool active)
194  {
195  int found = m_ExistingPostprocessRequests.Find(request);
196  if ( active && found == -1 )
197  {
198  m_ExistingPostprocessRequests.Insert(request);
199  }
200  else if ( !active && found > -1 ) //should always be found in this case, redundant?
201  {
202  //RemoveActiveRequestFromMaterials(request);
203 
204  m_ExistingPostprocessRequests.Remove(found);
205  }
206  }
207 
209  void SetRequestUpdating(PPERequesterBase request, bool active)
210  {
211  if (!m_UpdatingRequests)
212  {
213  Debug.Log("PPEManager | SetRequestUpdating | !m_UpdatingRequests");
214  return;
215  }
216 
217  int idx = m_UpdatingRequests.Find(request);
218 
219  if ( active && idx == -1 )
220  {
221  m_UpdatingRequests.Insert(request);
222  }
223  else if ( !active && idx > -1 )
224  {
225  m_UpdatingRequests.Remove(idx);
226  }
227  }
228 
229  // Just a getter
230  bool GetExistingRequester(typename req, out PPERequesterBase ret)
231  {
232  int idx = m_ExistingPostprocessRequests.Find(PPERequesterBank.GetRequester(req));
233  if (idx > -1)
234  {
235  ret = m_ExistingPostprocessRequests.Get(idx);
236  return true;
237  }
238  return false;
239  }
240 
242  {
243  foreach (typename requesterType : requesters)
244  {
245  PPERequesterBase ppeRequester;
246  GetExistingRequester(requesterType, ppeRequester);
247  if (ppeRequester && ppeRequester.IsRequesterRunning())
248  return true;
249  }
250 
251  return false;
252  }
253 
259  {
260  int count = req.GetActiveRequestStructure().Count();
261  int mat_id;
262  for (int i = 0; i < count; i++)
263  {
264  mat_id = req.GetActiveRequestStructure().GetKey(i);
265  PPEClassBase mat_class = m_PPEClassMap.Get(mat_id);
266  mat_class.RemoveRequest(req.GetRequesterIDX());
267  }
268  }
269 
271  protected void RequestsCleanup()
272  {
273  }
274 
276  void InsertUpdatedMaterial(int mat_id)
277  {
278  if ( m_UpdatedMaterials.Find(mat_id) == -1 )
279  m_UpdatedMaterials.Insert(mat_id);
280  }
281 
282  //---------//
283  //PROCESSING
284  //---------//
285  protected void ProcessRequesterUpdates(float timeslice)
286  {
287  PPERequesterBase req;
288  for (int i = 0; i < m_UpdatingRequests.Count(); i++)
289  {
290  //DbgPrnt("PPEDebug | ProcessRequesterUpdates | m_UpdatingRequests[i]: " + m_UpdatingRequests[i]);
291  req = m_UpdatingRequests.Get(i);
292  if (req)
293  req.OnUpdate(timeslice);
294  }
295  }
296 
297  protected void ProcessMaterialUpdates(float timeslice)
298  {
299  for (int i = 0; i < m_PPEMaterialUpdateQueueMap.Count(); i++) //orders (levels?)
300  {
301  //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetKey " + i + ": " + m_PPEMaterialUpdateQueueMap.GetKey(i));
302  //DbgPrnt("PPEDebug | ProcessMaterialUpdates | GetElement - count " + i + ": " + m_PPEMaterialUpdateQueueMap.GetElement(i).Count());
303 
304  for (int j = 0; j < m_PPEMaterialUpdateQueueMap.GetElement(i).Count(); j++)
305  {
306  PPEClassBase mat_class = m_PPEClassMap.Get(m_PPEMaterialUpdateQueueMap.GetElement(i).Get(j));
307  mat_class.OnUpdate(timeslice,i);
308  }
309  }
310  }
311 
312  protected void ProcessApplyValueChanges()
313  {
314  int material_id;
315  for (int i = 0; i < m_UpdatedMaterials.Count(); i++)
316  {
317  material_id = m_UpdatedMaterials.Get(i);
318  PPEClassBase mat_class = m_PPEClassMap.Get(material_id);
319  mat_class.ApplyValueChanges();
320  }
321 
322  m_UpdatedMaterials.Clear();
324  }
325 
326  void Update(float timeslice)
327  {
329  return;
330 
331  ProcessRequesterUpdates(timeslice);
332  ProcessMaterialUpdates(timeslice);
334  RequestsCleanup(); //unused
335  }
336 
338  Param GetPostProcessDefaultValues(int material, int parameter)
339  {
340  PPEClassBase mat_class = m_PPEClassMap.Get(material);
341  return mat_class.GetParameterCommandData(parameter).GetDefaultValues();
342  }
343 
345  Param GetPostProcessCurrentValues(int material, int parameter)
346  {
347  PPEClassBase mat_class = m_PPEClassMap.Get(material);
348  return mat_class.GetParameterCommandData(parameter).GetCurrentValues();
349  }
350 
351  //TODO - certain C++ events may change the actual material path with a graphics option changes. Reflect this on script-side!
352  //Currently only SSAY/HBAO affected...welp.
354  void ChangePPEMaterial(PostProcessPrioritiesCamera priority, PostProcessEffectType type, string path, bool scriptside_only)
355  {
356  if (m_PPEClassMap.Contains(type))
357  {
358  PPEClassBase mat_class = m_PPEClassMap.Get(type);
359  typename name = mat_class.Type();
360  PPEClassBase postprocess_capsule = PPEClassBase.Cast(name.Spawn());
361  postprocess_capsule.ChangeMaterialPathUsed(path);
362 
363  if (postprocess_capsule.GetMaterial() == 0x0)
364  {
365  Debug.Log("PPEManager | Invalid material path " + path + " used for " + name );
366  return;
367  }
368 
369  //m_PPEClassMap.Remove(type);
370  m_PPEClassMap.Set(type,postprocess_capsule);
371  }
372 
373  //can be sent script-side only to adapt to c++ options changes
374  if (!scriptside_only)
376  }
377 
379  void StopAllEffects(int mask = 0)
380  {
382  {
383  foreach (PPERequesterBase requester : m_ExistingPostprocessRequests)
384  {
385  if (requester.GetCategoryMask() & mask)
386  {
387  requester.Stop();
388  }
389  }
390  }
391  }
392 
393  void DbgPrnt(string text)
394  {
395  //Debug.Log(""+text);
396  }
397 };
PostProcessEffectType
PostProcessEffectType
Post-process effect type.
Definition: enworld.c:71
SetRequestActive
void SetRequestActive(PPERequesterBase request, bool active)
Marks requester as 'active'. Currently indistinguiishable from 'updating' requester,...
Definition: ppemanager.c:193
GetGame
proto native CGame GetGame()
PPEClassBase
Created once, on manager init. Script-side representation of C++ material class, separate handling.
Definition: ppematclassesbase.c:2
InsertUpdatedMaterial
void InsertUpdatedMaterial(int mat_id)
Marks material class as updated and values to be set in the course of update - 'ProcessApplyValueChan...
Definition: ppemanager.c:276
PPEExposureNative
EV postprocess, does not directly use materials.
Definition: ppeexposurenative.c:5
m_UpdatedMaterials
protected ref array< int > m_UpdatedMaterials
Definition: ppemanager.c:60
PPEFXAA
FXAA - PostProcessEffectType.FXAA.
Definition: ppefxaa.c:2
Param
Base Param Class with no parameters. Used as general purpose parameter overloaded with Param1 to Para...
Definition: param.c:11
PPENone
Dummy class - PostProcessEffectType.None.
Definition: ppenone.c:2
InitPPEManagerClassMap
protected void InitPPEManagerClassMap()
Ordered by 'PostProcessEffectType' for easy access through the same enum; ID saved all the same.
Definition: ppemanager.c:101
ProcessApplyValueChanges
protected void ProcessApplyValueChanges()
Definition: ppemanager.c:312
m_Manager
ModifiersManager m_Manager
Definition: modifierbase.c:12
PPEMedian
Median - PostProcessEffectType.Median.
Definition: ppemedian.c:3
m_UpdatingRequests
protected ref array< ref PPERequesterBase > m_UpdatingRequests
Definition: ppemanager.c:62
PPESSAO
SSAO - PostProcessEffectType.SSAO.
Definition: ppessao.c:2
ProcessRequesterUpdates
protected void ProcessRequesterUpdates(float timeslice)
Definition: ppemanager.c:285
Managed
TODO doc.
Definition: enscript.c:117
PPEGodRays
GodRays - PostProcessEffectType.GodRays.
Definition: ppegodrays.c:2
SetRequestUpdating
void SetRequestUpdating(PPERequesterBase request, bool active)
Marks requester as 'updating' and to be processed on manager update.
Definition: ppemanager.c:209
SetMaterialParamUpdating
void SetMaterialParamUpdating(int material_id, int parameter_id, int order)
Queues material/parameter to update (once)
Definition: ppemanager.c:151
CAMERA_ID
class PPEManagerStatic CAMERA_ID
RegisterPPEClass
protected void RegisterPPEClass(PPEClassBase material_class)
Registeres material class and creates data structure within.
Definition: ppemanager.c:137
PPEManager
void PPEManager()
Definition: ppemanager.c:64
PPEGaussFilter
GaussFilter - PostProcessEffectType.GaussFilter.
Definition: ppegaussfilter.c:2
CALL_CATEGORY_GUI
const int CALL_CATEGORY_GUI
Definition: tools.c:9
Init
void Init()
Launched from 'DayZGame.DeferredInit' to make earlier access, use, and updates impossible (downside o...
Definition: ppemanager.c:84
m_ExistingPostprocessRequests
protected ref array< ref PPERequesterBase > m_ExistingPostprocessRequests
Definition: ppemanager.c:61
GetPostProcessDefaultValues
Param GetPostProcessDefaultValues(int material, int parameter)
Returns default values as Param. See 'PPEConstants' file for various typedefs used.
Definition: ppemanager.c:338
m_ManagerInitialized
protected bool m_ManagerInitialized
Definition: ppemanager.c:57
RemoveActiveRequestFromMaterials
protected void RemoveActiveRequestFromMaterials(PPERequesterBase req)
Definition: ppemanager.c:258
PPEManagerStatic
Static component of PPE manager, used to hold the instance.
Definition: ppemanager.c:2
GetPostProcessCurrentValues
Param GetPostProcessCurrentValues(int material, int parameter)
Returns current values as Param. See 'PPEConstants' file for various typedefs used.
Definition: ppemanager.c:345
SendMaterialValueData
void SendMaterialValueData(PPERequestParamDataBase data)
Definition: ppemanager.c:142
map
map
Definition: controlsxboxnew.c:3
PPELightIntensityParamsNative
g_Game.NightVissionLightParams, does not directly use materials. Controls light multiplication and fi...
Definition: ppelightintensityparamsnative.c:5
PPERain
Rain - PostProcessEffectType.Rain.
Definition: pperain.c:2
PPESunMask
SunMask - PostProcessEffectType.SunMask.
Definition: ppesunmask.c:3
PPEHBAO
HBAO - PostProcessEffectType.HBAO.
Definition: ppehbao.c:3
PPEGlow
Glow - PostProcessEffectType.Glow.
Definition: ppeglow.c:7
PPEUnderWater
UnderWater - PostProcessEffectType.UnderWater.
Definition: ppeunderwater.c:2
PPERequesterBase
Definition: pperequestplatformsbase.c:2
ClearMaterialUpdating
protected void ClearMaterialUpdating()
Definition: ppemanager.c:187
RemoveMaterialUpdating
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:176
PPERequestParamDataBase
Data for one material parameter, requester side.
Definition: pperequestdata.c:2
PPEWetDistort
WetDistort - PostProcessEffectType.WetDistort.
Definition: ppewetdistort.c:2
SetCameraPostProcessEffect
proto native void SetCameraPostProcessEffect(int cam, int priority, PostProcessEffectType type, string materialPath)
PPEChromAber
ChromAber - PostProcessEffectType.ChromAber.
Definition: ppechromaber.c:2
array
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
Definition: isboxcollidinggeometryproxyclasses.c:27
name
PlayerSpawnPresetDiscreteItemSetSlotData name
one set for cargo
Cleanup
void Cleanup()
Definition: ppemanager.c:70
m_PPEClassMap
protected ref map< int, ref PPEClassBase > m_PPEClassMap
Definition: ppemanager.c:58
IsAnyRequesterRunning
bool IsAnyRequesterRunning(array< typename > requesters)
Definition: ppemanager.c:241
PPEDynamicBlur
DynamicBlur - PostProcessEffectType.DynamicBlur.
Definition: ppedynamicblur.c:2
PostProcessPrioritiesCamera
PostProcessPrioritiesCamera
PPE type priorities, C++ based. DO NOT CHANGE ORDER! Used only when calling 'SetCameraPostProcessEffe...
Definition: ppeconstants.c:2
GetExistingRequester
bool GetExistingRequester(typename req, out PPERequesterBase ret)
Definition: ppemanager.c:230
PPEFilmGrain
FilmGrain - PostProcessEffectType.FilmGrain.
Definition: ppefilmgrain.c:6
PPEDepthOfField
DepthOfField - PostProcessEffectType.DepthOfField.
Definition: ppedepthoffield.c:3
Debug
Definition: debug.c:13
PPEColors
Colors - PostProcessEffectType.Colors.
Definition: ppecolors.c:3
PPEEyeAccomodationNative
Eye Accomodation postprocess, does not directly use materials.
Definition: ppeeyeaccomodationnative.c:5
PPESMAA
SMAA - PostProcessEffectType.SMAA.
Definition: ppesmaa.c:2
StopAllEffects
void StopAllEffects(int mask=0)
stops all effects of a certain kind
Definition: ppemanager.c:379
PPERotBlur
Rotation Blur.
Definition: pperotblur.c:2
m_PPEMaterialUpdateQueueMap
protected ref map< int, ref array< int > > m_PPEMaterialUpdateQueueMap
Definition: ppemanager.c:59
RequestsCleanup
protected void RequestsCleanup()
Unused cleanup method, should it be ever needed.
Definition: ppemanager.c:271
PPEDOF
DOF postprocess, does not directly use materials.
Definition: ppedof.c:5
DbgPrnt
void DbgPrnt(string text)
Definition: ppemanager.c:393
Update
void Update(float timeslice)
Definition: ppemanager.c:326
PPEColorGrading
ColorGrading - PostProcessEffectType.ColorGrading.
Definition: ppecolorgrading.c:3
PPERadialBlur
RadialBlur - PostProcessEffectType.RadialBlur.
Definition: pperadialblur.c:2
ProcessMaterialUpdates
protected void ProcessMaterialUpdates(float timeslice)
Definition: ppemanager.c:297
Count
@ Count
Definition: randomgeneratorsyncmanager.c:7
ChangePPEMaterial
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:354
path
string path
Definition: optionselectormultistate.c:135