ppematclassparametercommanddata.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. typedef map<int,ref PPERequestParamDataBase> ActiveParameterRequestsMap; //<request_ID, data>
  2. class PPEMatClassParameterCommandData
  3. {
  4. //default layer constants, complex data like colors PPEMatClassParameterColor are handled separately
  5. const int LAYER_INFO_VALUE = 0;
  6. const int LAYER_INFO_OPERATOR = 1;
  7. ref array<int> m_CommandLayersArray; //for tracking active priorities and sorting them //TODO - could have been 'set'..
  8. protected int m_UpdatedCount;
  9. protected int m_MaterialIndex; //just a helper
  10. protected int m_ParameterIndex;
  11. protected ref ActiveParameterRequestsMap m_RequestMap;//<request_ID, parameter data>
  12. protected PPEClassBase m_Parent;
  13. protected ref Param m_Defaults; // Careful, formating is such, that param1 is ALWAYS string, containing parameter name. Actual values follow.
  14. protected ref Param m_CurrentValues; // Careful, only actual values, WITHOUT string
  15. protected ref map<int,ref array<int>> m_Dependencies;
  16. void PPEMatClassParameterCommandData(int mat_idx, int parameter_idx, PPEClassBase parent)
  17. {
  18. m_MaterialIndex = mat_idx;
  19. m_ParameterIndex = parameter_idx;
  20. m_Parent = parent;
  21. m_CommandLayersArray = new array<int>;
  22. m_UpdatedCount = 0;
  23. m_RequestMap = new ActiveParameterRequestsMap;
  24. }
  25. int GetParameterVarType()
  26. {
  27. return -1;
  28. }
  29. void SetMaterialIndex(int value)
  30. {
  31. m_MaterialIndex = value;
  32. }
  33. void SetParameterIndex(int value)
  34. {
  35. m_ParameterIndex = value;
  36. }
  37. void SetParent(PPEClassBase parent)
  38. {
  39. m_Parent = parent;
  40. }
  41. void InsertRequestData(PPERequestParamDataBase request_data)
  42. {
  43. m_RequestMap.Set(request_data.GetRequesterIDX(),request_data);//<request_ID, data>
  44. }
  45. void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
  46. {
  47. //insert dependencies to another update round
  48. if ( m_Dependencies && m_Dependencies.Count() > 0 && order < PPEConstants.DEPENDENCY_ORDER_HIGHEST )
  49. {
  50. int key_mat = -1;
  51. int element_par = -1;
  52. for (int i = 0; i < m_Dependencies.Count(); i++)
  53. {
  54. key_mat = m_Dependencies.GetKey(i);
  55. for (int j = 0; j < m_Dependencies.GetElement(i).Count(); j++)
  56. {
  57. element_par = m_Dependencies.GetElement(i).Get(j);
  58. PPEManagerStatic.GetPPEManager().SetMaterialParamUpdating(key_mat,element_par,order + 1); // TODO - revise, currently only does one more update
  59. }
  60. }
  61. }
  62. }
  63. //! Modifies values to be used for setter methods later in the manager update. Currently used only on PPEMatClassParameterColor, TODO!!
  64. void ModifyResultValues(inout Param result_values)
  65. {
  66. }
  67. //! Adds 'layers' to be iterated throug
  68. void AddPriorityInfo(int priority)
  69. {
  70. if ( m_CommandLayersArray.Find(priority) == -1 )
  71. {
  72. m_CommandLayersArray.Insert(priority);
  73. m_CommandLayersArray.Sort();
  74. }
  75. else
  76. {
  77. //DbgPrnt("PPEDebug | PPEMatClassParameterCommandData - AddPriorityInfo | Already exists, values have been overwritten!");
  78. }
  79. }
  80. //! Currently unused; layer info gets cleared every update
  81. void RemovePriorityInfo(int priority)
  82. {
  83. }
  84. //! Adds name and default values from material registration, override on children to properly add for each type
  85. void RegisterDefaults(Param p)
  86. {
  87. m_Defaults = p;
  88. InitDefaults();
  89. InitCuttent();
  90. }
  91. protected void InitDefaults() {};
  92. protected void InitCuttent() {};
  93. protected void SetParameterValueDefault(inout Param p_total)
  94. {
  95. }
  96. //! Careful, formating is such, that param1 is ALWAYS string, containing parameter name, should it be needed. Actual values follow.
  97. Param GetDefaultValues()
  98. {
  99. return m_Defaults;
  100. }
  101. //! Careful, only actual values, WITHOUT string
  102. Param GetCurrentValues()
  103. {
  104. return m_CurrentValues;
  105. }
  106. void DbgPrnt(string text)
  107. {
  108. //Debug.Log(""+text);
  109. }
  110. }