diff options
Diffstat (limited to 'libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs')
-rw-r--r-- | libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs | 226 |
1 files changed, 113 insertions, 113 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs index 2b9e114..eec77ac 100644 --- a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs +++ b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/BroadphaseCollision/BroadphasePair.cs | |||
@@ -1,113 +1,113 @@ | |||
1 | /* | 1 | /* |
2 | Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru | 2 | Bullet for XNA Copyright (c) 2003-2007 Vsevolod Klementjev http://www.codeplex.com/xnadevru |
3 | Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com | 3 | Bullet original C++ version Copyright (c) 2003-2007 Erwin Coumans http://bulletphysics.com |
4 | 4 | ||
5 | This software is provided 'as-is', without any express or implied | 5 | This software is provided 'as-is', without any express or implied |
6 | warranty. In no event will the authors be held liable for any damages | 6 | warranty. In no event will the authors be held liable for any damages |
7 | arising from the use of this software. | 7 | arising from the use of this software. |
8 | 8 | ||
9 | Permission is granted to anyone to use this software for any purpose, | 9 | Permission is granted to anyone to use this software for any purpose, |
10 | including commercial applications, and to alter it and redistribute it | 10 | including commercial applications, and to alter it and redistribute it |
11 | freely, subject to the following restrictions: | 11 | freely, subject to the following restrictions: |
12 | 12 | ||
13 | 1. The origin of this software must not be misrepresented; you must not | 13 | 1. The origin of this software must not be misrepresented; you must not |
14 | claim that you wrote the original software. If you use this software | 14 | claim that you wrote the original software. If you use this software |
15 | in a product, an acknowledgment in the product documentation would be | 15 | in a product, an acknowledgment in the product documentation would be |
16 | appreciated but is not required. | 16 | appreciated but is not required. |
17 | 2. Altered source versions must be plainly marked as such, and must not be | 17 | 2. Altered source versions must be plainly marked as such, and must not be |
18 | misrepresented as being the original software. | 18 | misrepresented as being the original software. |
19 | 3. This notice may not be removed or altered from any source distribution. | 19 | 3. This notice may not be removed or altered from any source distribution. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | using System; | 22 | using System; |
23 | using System.Collections.Generic; | 23 | using System.Collections.Generic; |
24 | using System.Text; | 24 | using System.Text; |
25 | 25 | ||
26 | namespace XnaDevRu.BulletX | 26 | namespace XnaDevRu.BulletX |
27 | { | 27 | { |
28 | public class BroadphasePair | 28 | public class BroadphasePair |
29 | { | 29 | { |
30 | private BroadphaseProxy _proxyA; | 30 | private BroadphaseProxy _proxyA; |
31 | private BroadphaseProxy _proxyB; | 31 | private BroadphaseProxy _proxyB; |
32 | 32 | ||
33 | private CollisionAlgorithm _algorithm; | 33 | private CollisionAlgorithm _algorithm; |
34 | private object _userInfo; | 34 | private object _userInfo; |
35 | 35 | ||
36 | public BroadphasePair() | 36 | public BroadphasePair() |
37 | { | 37 | { |
38 | } | 38 | } |
39 | 39 | ||
40 | public BroadphasePair(BroadphasePair other) | 40 | public BroadphasePair(BroadphasePair other) |
41 | { | 41 | { |
42 | _proxyA = other._proxyA; | 42 | _proxyA = other._proxyA; |
43 | _proxyB = other._proxyB; | 43 | _proxyB = other._proxyB; |
44 | 44 | ||
45 | _algorithm = other._algorithm; | 45 | _algorithm = other._algorithm; |
46 | _userInfo = null; | 46 | _userInfo = null; |
47 | } | 47 | } |
48 | 48 | ||
49 | public BroadphasePair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) | 49 | public BroadphasePair(BroadphaseProxy proxyA, BroadphaseProxy proxyB) |
50 | { | 50 | { |
51 | _proxyA = proxyA; | 51 | _proxyA = proxyA; |
52 | _proxyB = proxyB; | 52 | _proxyB = proxyB; |
53 | 53 | ||
54 | _algorithm = null; | 54 | _algorithm = null; |
55 | _userInfo = null; | 55 | _userInfo = null; |
56 | } | 56 | } |
57 | 57 | ||
58 | public BroadphaseProxy ProxyA { get { return _proxyA; } set { _proxyA = value; } } | 58 | public BroadphaseProxy ProxyA { get { return _proxyA; } set { _proxyA = value; } } |
59 | public BroadphaseProxy ProxyB { get { return _proxyB; } set { _proxyB = value; } } | 59 | public BroadphaseProxy ProxyB { get { return _proxyB; } set { _proxyB = value; } } |
60 | 60 | ||
61 | public CollisionAlgorithm CollisionAlgorithm { get { return _algorithm; } set { _algorithm = value; } } | 61 | public CollisionAlgorithm CollisionAlgorithm { get { return _algorithm; } set { _algorithm = value; } } |
62 | public object UserInfo { get { return _userInfo; } set { _userInfo = value; } } | 62 | public object UserInfo { get { return _userInfo; } set { _userInfo = value; } } |
63 | 63 | ||
64 | public override int GetHashCode() | 64 | public override int GetHashCode() |
65 | { | 65 | { |
66 | return _proxyA.GetHashCode() ^ _proxyB.GetHashCode(); | 66 | return _proxyA.GetHashCode() ^ _proxyB.GetHashCode(); |
67 | } | 67 | } |
68 | 68 | ||
69 | public override bool Equals(object obj) | 69 | public override bool Equals(object obj) |
70 | { | 70 | { |
71 | if (obj is BroadphasePair) | 71 | if (obj is BroadphasePair) |
72 | return this == (BroadphasePair)obj; | 72 | return this == (BroadphasePair)obj; |
73 | return false; | 73 | return false; |
74 | } | 74 | } |
75 | 75 | ||
76 | public static int ComparisonSort(BroadphasePair a, BroadphasePair b) | 76 | public static int ComparisonSort(BroadphasePair a, BroadphasePair b) |
77 | { | 77 | { |
78 | int aAId = a.ProxyA != null ? a.ProxyA.ComparisonID : -1; | 78 | int aAId = a.ProxyA != null ? a.ProxyA.ComparisonID : -1; |
79 | int aBId = a.ProxyB != null ? a.ProxyB.ComparisonID : -1; | 79 | int aBId = a.ProxyB != null ? a.ProxyB.ComparisonID : -1; |
80 | int aCId = a.CollisionAlgorithm != null ? a.CollisionAlgorithm.ComparisonID : -1; | 80 | int aCId = a.CollisionAlgorithm != null ? a.CollisionAlgorithm.ComparisonID : -1; |
81 | int bAId = b.ProxyA != null ? b.ProxyA.ComparisonID : -1; | 81 | int bAId = b.ProxyA != null ? b.ProxyA.ComparisonID : -1; |
82 | int bBId = b.ProxyB != null ? b.ProxyB.ComparisonID : -1; | 82 | int bBId = b.ProxyB != null ? b.ProxyB.ComparisonID : -1; |
83 | int bCId = b.CollisionAlgorithm != null ? b.CollisionAlgorithm.ComparisonID : -1; | 83 | int bCId = b.CollisionAlgorithm != null ? b.CollisionAlgorithm.ComparisonID : -1; |
84 | 84 | ||
85 | if (aAId > bAId || | 85 | if (aAId > bAId || |
86 | (a.ProxyA == b.ProxyA && aBId > bBId) || | 86 | (a.ProxyA == b.ProxyA && aBId > bBId) || |
87 | (a.ProxyA == b.ProxyA && a.ProxyB == b.ProxyB && aCId > bCId)) | 87 | (a.ProxyA == b.ProxyA && a.ProxyB == b.ProxyB && aCId > bCId)) |
88 | return -1; | 88 | return -1; |
89 | else | 89 | else |
90 | return 1; | 90 | return 1; |
91 | } | 91 | } |
92 | 92 | ||
93 | public static bool operator ==(BroadphasePair a, BroadphasePair b) | 93 | public static bool operator ==(BroadphasePair a, BroadphasePair b) |
94 | { | 94 | { |
95 | if (object.Equals(a, null) && object.Equals(b, null)) | 95 | if (object.Equals(a, null) && object.Equals(b, null)) |
96 | return true; | 96 | return true; |
97 | if (object.Equals(a, null) || object.Equals(b, null)) | 97 | if (object.Equals(a, null) || object.Equals(b, null)) |
98 | return false; | 98 | return false; |
99 | 99 | ||
100 | return (a.ProxyA == b.ProxyA) && (a.ProxyB == b.ProxyB); | 100 | return (a.ProxyA == b.ProxyA) && (a.ProxyB == b.ProxyB); |
101 | } | 101 | } |
102 | 102 | ||
103 | public static bool operator !=(BroadphasePair a, BroadphasePair b) | 103 | public static bool operator !=(BroadphasePair a, BroadphasePair b) |
104 | { | 104 | { |
105 | if (object.Equals(a, null) && object.Equals(b, null)) | 105 | if (object.Equals(a, null) && object.Equals(b, null)) |
106 | return true; | 106 | return true; |
107 | if (object.Equals(a, null) || object.Equals(b, null)) | 107 | if (object.Equals(a, null) || object.Equals(b, null)) |
108 | return false; | 108 | return false; |
109 | 109 | ||
110 | return (a.ProxyA != b.ProxyA) || (a.ProxyB != b.ProxyB); | 110 | return (a.ProxyA != b.ProxyA) || (a.ProxyB != b.ProxyB); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | } | 113 | } |