File size: 5,762 Bytes
24b81cb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
class PPEMatClassParameterInt extends PPEMatClassParameterCommandData
{
protected ref map<int,ref array<int,int>> m_LayerInfo; //<priority,<value,operator>>
protected PPETemplateDefInt m_Int;
protected int m_ValueDefault;
void PPEMatClassParameterInt(int mat_idx, int parameter_idx, PPEClassBase parent)
{
m_LayerInfo = new map<int,ref array<int,int>>;
}
override void InitDefaults()
{
Class.CastTo(m_Int,m_Defaults);
m_ValueDefault = m_Int.param2;
}
override void InitCuttent()
{
m_CurrentValues = new Param1<int>(m_ValueDefault);
}
override int GetParameterVarType()
{
return PPEConstants.VAR_TYPE_INT;
}
override void Update(float timeslice, out Param p_total, out bool setting_defaults, int order)
{
super.Update(timeslice,p_total,setting_defaults,order);
int active_request_count = 0;
PPERequestParamDataInt req_data;
bool setting_value_zero = false;
bool int_value_temp = false;
bool int_value_total = m_ValueDefault;
if (p_total == null)
{
p_total = new Param1<int>(0);
}
if (m_RequestMap.Count() > 0)
{
m_LayerInfo.Clear();
}
else
{
//DbgPrnt("m_RequestMap.Count() is zero! Using default values. | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
SetParameterValueDefault(p_total);
m_Parent.ParamUpdateRemove(m_ParameterIndex);
return;
}
for ( int i = 0; i < m_RequestMap.Count(); i++ )
{
req_data = PPERequestParamDataInt.Cast(m_RequestMap.GetElement(i));
if (req_data == null)
{
Error("Debug | PPEMatClassParameterInt | req_data not found! | " + this + " | mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
continue;
}
setting_value_zero = req_data.IsSettingDefaultValues();
if (setting_value_zero && !req_data.GetUpdatingDataValues() && !req_data.IsDataActive())
{
//DbgPrnt("Is Default, not updating | idx: " + i + " | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
continue;
}
if (setting_value_zero)
{
req_data.m_IntTarget = false;
//DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | !data.m_DefaultTargetSet | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | req_data.m_IntTarget: " + req_data.m_IntTarget);
}
else
{
active_request_count++;
}
//evaluation
//--------------------------------
req_data.m_IntLast = req_data.m_IntCurrent;
if (!req_data.GetUpdatingDataValues() && req_data.IsDataActive()) //set to exact value, not updating anymore
{
int_value_temp = req_data.m_IntCurrent;
PrepareLayerInfo(req_data.GetPriorityLayer(),int_value_temp,req_data.GetInteractionMask());
//DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | !req_data.m_UpdatingData | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | not updating, addaing current value into mix: " + int_value_temp);
continue;
}
int_value_temp = req_data.m_IntTarget;
//DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX());
req_data.SetUpdatingDataValues(false);
if (setting_value_zero)
{
req_data.SetDataActive(false);
//RemovePriorityInfo(req_data.GetPriorityLayer()); //redundant?
}
else
{
int_value_temp = req_data.m_IntTarget;
PrepareLayerInfo(req_data.GetPriorityLayer(),int_value_temp,req_data.GetInteractionMask());
}
req_data.m_IntCurrent = int_value_temp;
}
if (active_request_count == 0)
{
SetParameterValueDefault(p_total);
}
else
{
//---------------------------
//MASK handling and calculation
int value;
int operator;
bool override_active = false;
for ( i = 0; i < m_LayerInfo.Count(); i++ )
{
if ( override_active )
break;
value = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_VALUE);
operator = m_LayerInfo.Get(m_CommandLayersArray.Get(i)).Get(LAYER_INFO_OPERATOR);
switch (operator)
{
case PPOperators.LOWEST:
int_value_total = Math.Min(int_value_total,value);
break;
case PPOperators.HIGHEST:
int_value_total = Math.Max(int_value_total,value);
break;
case PPOperators.OVERRIDE:
int_value_total = value;
break;
case PPOperators.SET:
int_value_total = value;
break;
default:
Error("PPEMatClassParameterInt | Invalid operator " + operator + " in mat/par: " + m_MaterialIndex + "/" + m_ParameterIndex);
break;
}
if ( operator == PPOperators.OVERRIDE )
{
//DbgPrnt("m_LayerInfo | PPOperators.OVERRIDE at: " + i);
override_active = true;
}
}
m_CommandLayersArray.Clear();
Param1<int>.Cast(p_total).param1 = int_value_total;
}
//DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | mat/par/req: " + m_MaterialIndex + "/" + m_ParameterIndex + "/" + req_data.GetRequesterIDX() + " | parameter update end, removing from queue");
m_Parent.ParamUpdateRemove(m_ParameterIndex);
m_CurrentValues = p_total;
}
void PrepareLayerInfo(int layer, int value, int operator)
{
m_LayerInfo.Set(layer,{value,operator});
AddPriorityInfo(layer);
}
//! No active requests for the mat. parameter value change, sets the value to DEFAULT
override void SetParameterValueDefault(inout Param p_total)
{
p_total = new Param1<int>(PPETemplateDefInt.Cast(m_Defaults).param2);
m_CurrentValues = p_total;
//DbgPrnt("PPEDebug | PPEMatClassParameterInt - UpdateParameterValues | exit 3 - zero value");
}
}
|