forked from jbruening/PNet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathslimmath_patch.patch
More file actions
249 lines (233 loc) · 8.68 KB
/
slimmath_patch.patch
File metadata and controls
249 lines (233 loc) · 8.68 KB
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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
Index: BoundingFrustum.cs
===================================================================
--- BoundingFrustum.cs (revision 47)
+++ BoundingFrustum.cs (working copy)
@@ -33,14 +33,43 @@
[Serializable]
public class BoundingFrustum
{
- Plane near;
- Plane far;
- Plane top;
- Plane bottom;
- Plane left;
- Plane right;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Near;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Far;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Top;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Bottom;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Left;
+ /// <summary>
+ ///
+ /// </summary>
+ public Plane Right;
- Matrix matrix;
+ Matrix _matrix;
+ /// <summary>
+ /// the matrix that represents the planes. Setting it will update the planes
+ /// </summary>
+ public Matrix Matrix
+ {
+ get { return _matrix; }
+ set
+ {
+ SetMatrix(ref value);
+ }
+ }
Gjk gjk = new Gjk();
/// <summary>
@@ -58,43 +87,77 @@
/// <param name="value">The <see cref="SlimMath.Matrix"/> to extract the planes from.</param>
public void SetMatrix(ref Matrix value)
{
- this.matrix = value;
+ this._matrix = value;
//Near
- near.Normal.X = value.M13;
- near.Normal.Y = value.M23;
- near.Normal.Z = value.M33;
- near.D = value.M43;
+ Near.Normal.X = value.M13;
+ Near.Normal.Y = value.M23;
+ Near.Normal.Z = value.M33;
+ Near.D = value.M43;
//Far
- far.Normal.X = value.M14 - value.M13;
- far.Normal.Y = value.M24 - value.M23;
- far.Normal.Z = value.M34 - value.M33;
- far.D = value.M44 - value.M43;
+ Far.Normal.X = value.M14 - value.M13;
+ Far.Normal.Y = value.M24 - value.M23;
+ Far.Normal.Z = value.M34 - value.M33;
+ Far.D = value.M44 - value.M43;
//Top
- top.Normal.X = value.M14 - value.M12;
- top.Normal.Y = value.M24 - value.M22;
- top.Normal.Z = value.M34 - value.M32;
- top.D = value.M44 - value.M42;
+ Top.Normal.X = value.M14 - value.M12;
+ Top.Normal.Y = value.M24 - value.M22;
+ Top.Normal.Z = value.M34 - value.M32;
+ Top.D = value.M44 - value.M42;
//Bottom
- bottom.Normal.X = value.M14 + value.M12;
- bottom.Normal.Y = value.M24 + value.M22;
- bottom.Normal.Z = value.M34 + value.M32;
- bottom.D = value.M44 + value.M42;
+ Bottom.Normal.X = value.M14 + value.M12;
+ Bottom.Normal.Y = value.M24 + value.M22;
+ Bottom.Normal.Z = value.M34 + value.M32;
+ Bottom.D = value.M44 + value.M42;
//Left
- left.Normal.X = value.M14 + value.M11;
- left.Normal.Y = value.M24 + value.M21;
- left.Normal.Z = value.M34 + value.M31;
- left.D = value.M44 + value.M41;
+ Left.Normal.X = value.M14 + value.M11;
+ Left.Normal.Y = value.M24 + value.M21;
+ Left.Normal.Z = value.M34 + value.M31;
+ Left.D = value.M44 + value.M41;
//Right
- right.Normal.X = value.M14 - value.M11;
- right.Normal.Y = value.M24 - value.M21;
- right.Normal.Z = value.M34 - value.M31;
- right.D = value.M44 - value.M41;
+ Right.Normal.X = value.M14 - value.M11;
+ Right.Normal.Y = value.M24 - value.M21;
+ Right.Normal.Z = value.M34 - value.M31;
+ Right.D = value.M44 - value.M41;
}
+
+ /// <summary>
+ /// Causes Matrix to be updated with any changes to the Planes
+ /// </summary>
+ public void UpdateMatrix()
+ {
+ var matrix = new Matrix();
+
+ //Near
+ matrix.M13 = Near.Normal.X;
+ matrix.M23 = Near.Normal.Z;
+ matrix.M33 = Near.Normal.Z;
+ matrix.M43 = Near.D;
+
+ //Far
+ matrix.M14 = matrix.M13 + Far.Normal.X;
+ matrix.M24 = matrix.M23 + Far.Normal.Y;
+ matrix.M34 = matrix.M33 + Far.Normal.Z;
+ matrix.M44 = matrix.M43 + Far.D;
+
+ //Top
+ matrix.M12 = matrix.M14 - Top.Normal.X;
+ matrix.M22 = matrix.M24 - Top.Normal.Y;
+ matrix.M32 = matrix.M34 - Top.Normal.Z;
+ matrix.M42 = matrix.M44 - Top.D;
+
+ //Left
+ matrix.M11 = Left.Normal.X - matrix.M14;
+ matrix.M21 = Left.Normal.Y - matrix.M24;
+ matrix.M31 = Left.Normal.Z - matrix.M34;
+ matrix.M41 = Left.D - matrix.M44;
+
+ _matrix = matrix;
+ }
}
}
Index: BoundingSphere.cs
===================================================================
--- BoundingSphere.cs (revision 47)
+++ BoundingSphere.cs (working copy)
@@ -45,7 +45,7 @@
public float Radius;
/// <summary>
- /// Initializes a new instance of the <see cref="SlimMath.BoundingBox"/> struct.
+ /// Initializes a new instance of the <see cref="SlimMath.BoundingSphere"/> struct.
/// </summary>
/// <param name="center">The center of the sphere.</param>
/// <param name="radius">The radius of the sphere.</param>
Index: Color3.cs
===================================================================
--- Color3.cs (revision 47)
+++ Color3.cs (working copy)
@@ -754,7 +754,7 @@
/// </returns>
public override string ToString()
{
- return string.Format(CultureInfo.CurrentCulture, "Red:{1} Green:{2} Blue:{3}", Red, Green, Blue);
+ return string.Format(CultureInfo.CurrentCulture, "Red:{0} Green:{1} Blue:{2}", Red, Green, Blue);
}
/// <summary>
@@ -769,7 +769,7 @@
if (format == null)
return ToString();
- return string.Format(CultureInfo.CurrentCulture, "Red:{1} Green:{2} Blue:{3}", Red.ToString(format, CultureInfo.CurrentCulture),
+ return string.Format(CultureInfo.CurrentCulture, "Red:{0} Green:{1} Blue:{2}", Red.ToString(format, CultureInfo.CurrentCulture),
Green.ToString(format, CultureInfo.CurrentCulture), Blue.ToString(format, CultureInfo.CurrentCulture));
}
@@ -782,7 +782,7 @@
/// </returns>
public string ToString(IFormatProvider formatProvider)
{
- return string.Format(formatProvider, "Red:{1} Green:{2} Blue:{3}", Red, Green, Blue);
+ return string.Format(formatProvider, "Red:{0} Green:{1} Blue:{2}", Red, Green, Blue);
}
/// <summary>
Index: Design/FieldPropertyDescriptor.cs
===================================================================
--- Design/FieldPropertyDescriptor.cs (revision 47)
+++ Design/FieldPropertyDescriptor.cs (working copy)
@@ -46,7 +46,7 @@
}
public FieldPropertyDescriptor(FieldInfo fieldInfo)
- : base(fieldInfo.Name, (Attribute[])fieldInfo.GetCustomAttributes(true))
+ : base(fieldInfo.Name, Array.ConvertAll(fieldInfo.GetCustomAttributes(true), item=> item as Attribute))
{
this.fieldInfo = fieldInfo;
}
Index: Design/Vector3Converter.cs
===================================================================
--- Design/Vector3Converter.cs (revision 47)
+++ Design/Vector3Converter.cs (working copy)
@@ -100,8 +100,15 @@
/// </exception>
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
- var values = ConvertToValues<float>(context, culture, value);
- return values != null ? new Vector3(values) : base.ConvertFrom(context, culture, value);
+ try
+ {
+ var values = ConvertToValues<float>(context, culture, value);
+ return values != null ? new Vector3(values) : base.ConvertFrom(context, culture, value);
+ }
+ catch(Exception e)
+ {
+ throw e;
+ }
}
/// <summary>
Index: Half.cs
===================================================================
--- Half.cs (revision 47)
+++ Half.cs (working copy)
@@ -122,6 +122,7 @@
public ushort RawValue
{
get { return value; }
+ set { this.value = value; }
}
/// <summary>