| | |
| | class PPEManagerStatic |
| | { |
| | static ref PPEManager m_Manager; |
| | |
| | static void CreateManagerStatic() |
| | { |
| | if (m_Manager) |
| | { |
| | Debug.Log("PPEManagerStatic | CreateManagerStatic - PPEManager already exists"); |
| | return; |
| | } |
| | |
| | m_Manager = new PPEManager; |
| | } |
| | |
| | static void DestroyManagerStatic() |
| | { |
| | if (m_Manager) |
| | { |
| | m_Manager.Cleanup(); |
| | delete m_Manager; |
| | } |
| | } |
| | |
| | |
| | static PPEManager GetPPEManager() |
| | { |
| | return m_Manager; |
| | } |
| | } |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | class PPEManager extends Managed |
| | { |
| | const int CAMERA_ID = 0; |
| | |
| | protected bool m_ManagerInitialized; |
| | protected ref map<int, ref PPEClassBase> m_PPEClassMap; |
| | protected ref map<int, ref array<int>> m_PPEMaterialUpdateQueueMap; |
| | protected ref array<int> m_UpdatedMaterials; |
| | protected ref array<ref PPERequesterBase> m_ExistingPostprocessRequests; |
| | protected ref array<ref PPERequesterBase> m_UpdatingRequests; |
| | |
| | void PPEManager() |
| | { |
| | m_ManagerInitialized = false; |
| | PPERequesterBank.Init(); |
| | } |
| | |
| | void Cleanup() |
| | { |
| | PPERequesterBank.Cleanup(); |
| | |
| | if (m_ManagerInitialized) |
| | { |
| | m_PPEMaterialUpdateQueueMap.Clear(); |
| | m_ExistingPostprocessRequests.Clear(); |
| | m_UpdatingRequests.Clear(); |
| | m_PPEClassMap.Clear(); |
| | } |
| | } |
| | |
| | |
| | void Init() |
| | { |
| | |
| | if (!m_ManagerInitialized) |
| | { |
| | m_PPEMaterialUpdateQueueMap = new map<int, ref array<int>>; |
| | m_UpdatedMaterials = new array<int>; |
| | m_ExistingPostprocessRequests = new array<ref PPERequesterBase>; |
| | m_UpdatingRequests = new array<ref PPERequesterBase>; |
| | InitPPEManagerClassMap(); |
| | |
| | GetGame().GetUpdateQueue(CALL_CATEGORY_GUI).Insert(this.Update); |
| | m_ManagerInitialized = true; |
| | } |
| | } |
| | |
| | |
| | protected void InitPPEManagerClassMap() |
| | { |
| | if (m_PPEClassMap) |
| | { |
| | delete m_PPEClassMap; |
| | } |
| | m_PPEClassMap = new map<int, ref PPEClassBase>; |
| | |
| | RegisterPPEClass(new PPENone()); |
| | RegisterPPEClass(new PPEUnderWater()); |
| | RegisterPPEClass(new PPESSAO()); |
| | RegisterPPEClass(new PPEDepthOfField()); |
| | RegisterPPEClass(new PPEHBAO()); |
| | RegisterPPEClass(new PPERotBlur()); |
| | RegisterPPEClass(new PPEGodRays()); |
| | RegisterPPEClass(new PPERain()); |
| | RegisterPPEClass(new PPEFilmGrain()); |
| | RegisterPPEClass(new PPERadialBlur()); |
| | RegisterPPEClass(new PPEChromAber()); |
| | RegisterPPEClass(new PPEWetDistort()); |
| | RegisterPPEClass(new PPEDynamicBlur()); |
| | RegisterPPEClass(new PPEColorGrading()); |
| | RegisterPPEClass(new PPEColors()); |
| | RegisterPPEClass(new PPEGlow()); |
| | RegisterPPEClass(new PPESMAA()); |
| | RegisterPPEClass(new PPEFXAA()); |
| | RegisterPPEClass(new PPEMedian()); |
| | RegisterPPEClass(new PPESunMask()); |
| | RegisterPPEClass(new PPEGaussFilter()); |
| | RegisterPPEClass(new PPEExposureNative()); |
| | RegisterPPEClass(new PPEEyeAccomodationNative()); |
| | RegisterPPEClass(new PPEDOF()); |
| | RegisterPPEClass(new PPELightIntensityParamsNative()); |
| | } |
| | |
| | |
| | protected void RegisterPPEClass(PPEClassBase material_class) |
| | { |
| | m_PPEClassMap.Set(material_class.GetPostProcessEffectID(), material_class); |
| | } |
| | |
| | void SendMaterialValueData(PPERequestParamDataBase data) |
| | { |
| | |
| | PPEClassBase mat_class = m_PPEClassMap.Get(data.GetMaterialID()); |
| | mat_class.InsertParamValueData(data); |
| | SetMaterialParamUpdating(data.GetMaterialID(),data.GetParameterID(),PPEConstants.DEPENDENCY_ORDER_BASE); |
| | } |
| | |
| | |
| | void SetMaterialParamUpdating(int material_id, int parameter_id, int order) |
| | { |
| | if ( order > PPEConstants.DEPENDENCY_ORDER_HIGHEST ) |
| | { |
| | |
| | return; |
| | } |
| | |
| | PPEClassBase mat_class = m_PPEClassMap.Get(material_id); |
| | |
| | |
| | |
| | if ( !m_PPEMaterialUpdateQueueMap.Contains(order) ) |
| | m_PPEMaterialUpdateQueueMap.Set(order,new array<int>); |
| | |
| | int found = m_PPEMaterialUpdateQueueMap.Get(order).Find(material_id); |
| | if ( found == -1 ) |
| | { |
| | m_PPEMaterialUpdateQueueMap.Get(order).Insert(material_id); |
| | } |
| | |
| | mat_class.SetParameterUpdating(order,parameter_id); |
| | } |
| | |
| | |
| | void RemoveMaterialUpdating(int material_id, int order = 0) |
| | { |
| | if ( m_PPEMaterialUpdateQueueMap.Contains(order) ) |
| | { |
| | m_PPEMaterialUpdateQueueMap.Get(order).RemoveItem(material_id); |
| | |
| | if ( m_PPEMaterialUpdateQueueMap.Get(order).Count() == 0) |
| | m_PPEMaterialUpdateQueueMap.Remove(order); |
| | } |
| | } |
| | |
| | protected void ClearMaterialUpdating() |
| | { |
| | m_PPEMaterialUpdateQueueMap.Clear(); |
| | } |
| | |
| | |
| | void SetRequestActive(PPERequesterBase request, bool active) |
| | { |
| | int found = m_ExistingPostprocessRequests.Find(request); |
| | if ( active && found == -1 ) |
| | { |
| | m_ExistingPostprocessRequests.Insert(request); |
| | } |
| | else if ( !active && found > -1 ) |
| | { |
| | |
| | |
| | m_ExistingPostprocessRequests.Remove(found); |
| | } |
| | } |
| | |
| | |
| | void SetRequestUpdating(PPERequesterBase request, bool active) |
| | { |
| | if (!m_UpdatingRequests) |
| | { |
| | Debug.Log("PPEManager | SetRequestUpdating | !m_UpdatingRequests"); |
| | return; |
| | } |
| | |
| | int idx = m_UpdatingRequests.Find(request); |
| | |
| | if ( active && idx == -1 ) |
| | { |
| | m_UpdatingRequests.Insert(request); |
| | } |
| | else if ( !active && idx > -1 ) |
| | { |
| | m_UpdatingRequests.Remove(idx); |
| | } |
| | } |
| | |
| | |
| | bool GetExistingRequester(typename req, out PPERequesterBase ret) |
| | { |
| | int idx = m_ExistingPostprocessRequests.Find(PPERequesterBank.GetRequester(req)); |
| | if (idx > -1) |
| | { |
| | ret = m_ExistingPostprocessRequests.Get(idx); |
| | return true; |
| | } |
| | return false; |
| | } |
| | |
| | bool IsAnyRequesterRunning(array<typename> requesters) |
| | { |
| | foreach (typename requesterType : requesters) |
| | { |
| | PPERequesterBase ppeRequester; |
| | GetExistingRequester(requesterType, ppeRequester); |
| | if (ppeRequester && ppeRequester.IsRequesterRunning()) |
| | return true; |
| | } |
| | |
| | return false; |
| | } |
| | |
| | |
| | |
| | |
| | |
| | protected void RemoveActiveRequestFromMaterials(PPERequesterBase req) |
| | { |
| | int count = req.GetActiveRequestStructure().Count(); |
| | int mat_id; |
| | for (int i = 0; i < count; i++) |
| | { |
| | mat_id = req.GetActiveRequestStructure().GetKey(i); |
| | PPEClassBase mat_class = m_PPEClassMap.Get(mat_id); |
| | mat_class.RemoveRequest(req.GetRequesterIDX()); |
| | } |
| | } |
| | |
| | |
| | protected void RequestsCleanup() |
| | { |
| | } |
| | |
| | |
| | void InsertUpdatedMaterial(int mat_id) |
| | { |
| | if ( m_UpdatedMaterials.Find(mat_id) == -1 ) |
| | m_UpdatedMaterials.Insert(mat_id); |
| | } |
| | |
| | |
| | |
| | |
| | protected void ProcessRequesterUpdates(float timeslice) |
| | { |
| | PPERequesterBase req; |
| | for (int i = 0; i < m_UpdatingRequests.Count(); i++) |
| | { |
| | |
| | req = m_UpdatingRequests.Get(i); |
| | if (req) |
| | req.OnUpdate(timeslice); |
| | } |
| | } |
| | |
| | protected void ProcessMaterialUpdates(float timeslice) |
| | { |
| | for (int i = 0; i < m_PPEMaterialUpdateQueueMap.Count(); i++) |
| | { |
| | |
| | |
| | |
| | for (int j = 0; j < m_PPEMaterialUpdateQueueMap.GetElement(i).Count(); j++) |
| | { |
| | PPEClassBase mat_class = m_PPEClassMap.Get(m_PPEMaterialUpdateQueueMap.GetElement(i).Get(j)); |
| | mat_class.OnUpdate(timeslice,i); |
| | } |
| | } |
| | } |
| | |
| | protected void ProcessApplyValueChanges() |
| | { |
| | int material_id; |
| | for (int i = 0; i < m_UpdatedMaterials.Count(); i++) |
| | { |
| | material_id = m_UpdatedMaterials.Get(i); |
| | PPEClassBase mat_class = m_PPEClassMap.Get(material_id); |
| | mat_class.ApplyValueChanges(); |
| | } |
| | |
| | m_UpdatedMaterials.Clear(); |
| | ClearMaterialUpdating(); |
| | } |
| | |
| | void Update(float timeslice) |
| | { |
| | if (!m_ManagerInitialized) |
| | return; |
| | |
| | ProcessRequesterUpdates(timeslice); |
| | ProcessMaterialUpdates(timeslice); |
| | ProcessApplyValueChanges(); |
| | RequestsCleanup(); |
| | } |
| | |
| | |
| | Param GetPostProcessDefaultValues(int material, int parameter) |
| | { |
| | PPEClassBase mat_class = m_PPEClassMap.Get(material); |
| | return mat_class.GetParameterCommandData(parameter).GetDefaultValues(); |
| | } |
| | |
| | |
| | Param GetPostProcessCurrentValues(int material, int parameter) |
| | { |
| | PPEClassBase mat_class = m_PPEClassMap.Get(material); |
| | return mat_class.GetParameterCommandData(parameter).GetCurrentValues(); |
| | } |
| | |
| | |
| | |
| | |
| | void ChangePPEMaterial(PostProcessPrioritiesCamera priority, PostProcessEffectType type, string path, bool scriptside_only) |
| | { |
| | if (m_PPEClassMap.Contains(type)) |
| | { |
| | PPEClassBase mat_class = m_PPEClassMap.Get(type); |
| | typename name = mat_class.Type(); |
| | PPEClassBase postprocess_capsule = PPEClassBase.Cast(name.Spawn()); |
| | postprocess_capsule.ChangeMaterialPathUsed(path); |
| | |
| | if (postprocess_capsule.GetMaterial() == 0x0) |
| | { |
| | Debug.Log("PPEManager | Invalid material path " + path + " used for " + name ); |
| | return; |
| | } |
| | |
| | |
| | m_PPEClassMap.Set(type,postprocess_capsule); |
| | } |
| | |
| | |
| | if (!scriptside_only) |
| | SetCameraPostProcessEffect(CAMERA_ID,priority,type,path); |
| | } |
| | |
| | |
| | void StopAllEffects(int mask = 0) |
| | { |
| | if (m_ExistingPostprocessRequests) |
| | { |
| | foreach (PPERequesterBase requester : m_ExistingPostprocessRequests) |
| | { |
| | if (requester.GetCategoryMask() & mask) |
| | { |
| | requester.Stop(); |
| | } |
| | } |
| | } |
| | } |
| | |
| | void DbgPrnt(string text) |
| | { |
| | |
| | } |
| | }; |
| |
|