Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ SetValue() [2/18]

unsafe void Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue ( bool[] value)
inline

Definition at line 1055 of file EffectParameter.cs.

1056 {
1057 EffectParameterClass paramClass = _paramClass;
1058 if (paramClass != 0 && paramClass != EffectParameterClass.Vector && paramClass != EffectParameterClass.Matrix)
1059 {
1060 throw new InvalidCastException();
1061 }
1062 if (value != null)
1063 {
1064 int num = value.Length;
1065 if (num > 0)
1066 {
1067 if (paramClass == EffectParameterClass.Matrix)
1068 {
1069 int columns = _columns;
1070 int val = _rows * columns;
1072 if (count == 0)
1073 {
1074 Matrix valueMatrix = GetValueMatrix();
1075 int num2 = Math.Min(value.Length, val);
1076 fixed (float* ptr = &System.Runtime.CompilerServices.Unsafe.AsRef<float>(&valueMatrix.M11))
1077 {
1078 try
1079 {
1080 int num3 = 0;
1081 int num4 = 0;
1082 int rows = _rows;
1083 if (0 < rows)
1084 {
1085 while (num3 < num2)
1086 {
1087 int num5 = 0;
1088 int columns2 = _columns;
1089 if (0 < columns2)
1090 {
1091 while (num3 < num2)
1092 {
1093 bool flag = value[num3];
1094 num3++;
1095 float num6 = ((!flag) ? 0f : 1f);
1096 *(float*)((ref *(_003F*)((num4 * 4 + num5) * 4)) + (ref *(_003F*)ptr)) = num6;
1097 num5++;
1098 columns2 = _columns;
1099 if (num5 >= columns2)
1100 {
1101 break;
1102 }
1103 }
1104 }
1105 num4++;
1106 rows = _rows;
1107 if (num4 >= rows)
1108 {
1109 break;
1110 }
1111 }
1112 }
1113 SetValue(valueMatrix);
1114 }
1115 catch
1116 {
1117 //try-fault
1118 ptr = null;
1119 throw;
1120 }
1121 }
1122 }
1123 else
1124 {
1125 Matrix[] valueMatrixArray = GetValueMatrixArray(count);
1126 int num7 = Math.Min(value.Length, count * 16);
1127 fixed (float* ptr2 = &valueMatrixArray[0].M11)
1128 {
1129 try
1130 {
1131 int num8 = 0;
1132 int num9 = 0;
1133 if (0 < count)
1134 {
1135 while (num8 < num7)
1136 {
1137 int num10 = 0;
1138 int rows2 = _rows;
1139 if (0 < rows2)
1140 {
1141 while (num8 < num7)
1142 {
1143 int num11 = 0;
1144 int columns3 = _columns;
1145 if (0 < columns3)
1146 {
1147 while (num8 < num7)
1148 {
1149 bool flag2 = value[num8];
1150 num8++;
1151 float num12 = ((!flag2) ? 0f : 1f);
1152 *(float*)((ref *(_003F*)(((num9 * 4 + num10) * 4 + num11) * 4)) + (ref *(_003F*)ptr2)) = num12;
1153 num11++;
1154 columns3 = _columns;
1155 if (num11 >= columns3)
1156 {
1157 break;
1158 }
1159 }
1160 }
1161 num10++;
1162 rows2 = _rows;
1163 if (num10 >= rows2)
1164 {
1165 break;
1166 }
1167 }
1168 }
1169 num9++;
1170 if (num9 >= count)
1171 {
1172 break;
1173 }
1174 }
1175 }
1176 SetValue(valueMatrixArray);
1177 }
1178 catch
1179 {
1180 //try-fault
1181 ptr2 = null;
1182 throw;
1183 }
1184 }
1185 }
1186 }
1187 else
1188 {
1189 int[] array = new int[num];
1190 int num13 = 0;
1191 if (0 < (nint)array.LongLength)
1192 {
1193 do
1194 {
1195 int num14 = (value[num13] ? 1 : 0);
1196 array[num13] = num14;
1197 num13++;
1198 }
1199 while (num13 < (nint)array.LongLength);
1200 }
1201 fixed (void* ptr3 = &System.Runtime.CompilerServices.Unsafe.As<int, void>(ref array[0]))
1202 {
1203 try
1204 {
1205 int num15 = *(int*)pEffect + 96;
1206 int num16 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, int*, uint, int>)(int)(*(uint*)num15))((nint)pEffect, _handle, (int*)ptr3, (uint)value.Length);
1207 if (num16 < 0)
1208 {
1209 throw GraphicsHelpers.GetExceptionFromResult((uint)num16);
1210 }
1211 }
1212 catch
1213 {
1214 //try-fault
1215 ptr3 = null;
1216 throw;
1217 }
1218 }
1219 }
1220 goto IL_0296;
1221 }
1222 }
1223 ID3DXBaseEffect* ptr4 = pEffect;
1224 int num17 = ((delegate* unmanaged[Stdcall, Stdcall]<IntPtr, sbyte*, int*, uint, int>)(int)(*(uint*)(*(int*)ptr4 + 96)))((nint)ptr4, _handle, null, 0u);
1225 if (num17 < 0)
1226 {
1227 throw GraphicsHelpers.GetExceptionFromResult((uint)num17);
1228 }
1229 goto IL_0296;
1230 IL_0296:
1231 try
1232 {
1233 return;
1234 }
1235 catch
1236 {
1237 //try-fault
1238 throw;
1239 }
1240 }
static byte Min(byte val1, byte val2)
Definition Math.cs:912

References Microsoft.Xna.Framework.Graphics.EffectParameter._columns, Microsoft.Xna.Framework.Graphics.EffectParameter._handle, Microsoft.Xna.Framework.Graphics.EffectParameter._paramClass, Microsoft.Xna.Framework.Graphics.EffectParameter._rows, System.array, Microsoft.Xna.Framework.Graphics.EffectParameterCollection.Count, System.count, Microsoft.Xna.Framework.Graphics.GraphicsHelpers.GetExceptionFromResult(), Microsoft.Xna.Framework.Graphics.EffectParameter.GetValueMatrix(), Microsoft.Xna.Framework.Graphics.EffectParameter.GetValueMatrixArray(), Microsoft.Xna.Framework.Matrix.M11, System.Math.Min(), Microsoft.Xna.Framework.Graphics.EffectParameter.pEffect, Microsoft.Xna.Framework.Graphics.EffectParameter.pElementCollection, Microsoft.Xna.Framework.Graphics.EffectParameter.SetValue(), and System.value.