diff options
author | Sean Dague | 2007-07-16 15:40:11 +0000 |
---|---|---|
committer | Sean Dague | 2007-07-16 15:40:11 +0000 |
commit | 2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6 (patch) | |
tree | e3f80ad51736cf17e856547b1bcf956010927434 /libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs | |
parent | *Trunk compiles now (diff) | |
download | opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.zip opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.gz opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.bz2 opensim-SC_OLD-2a3c79df83e800d5dfe75a1a3b140ed81da2b1d6.tar.xz |
changed to native line ending encoding
Diffstat (limited to 'libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs')
-rw-r--r-- | libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs | 200 |
1 files changed, 100 insertions, 100 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs index 1ca5cfb..00dfaf1 100644 --- a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs +++ b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/CollisionDispatch/SphereTriangleCollisionAlgorithm.cs | |||
@@ -1,100 +1,100 @@ | |||
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 | using MonoXnaCompactMaths; | 25 | using MonoXnaCompactMaths; |
26 | 26 | ||
27 | namespace XnaDevRu.BulletX | 27 | namespace XnaDevRu.BulletX |
28 | { | 28 | { |
29 | /// <summary> | 29 | /// <summary> |
30 | /// SphereSphereCollisionAlgorithm provides sphere-sphere collision detection. | 30 | /// SphereSphereCollisionAlgorithm provides sphere-sphere collision detection. |
31 | /// Other features are frame-coherency (persistent data) and collision response. | 31 | /// Other features are frame-coherency (persistent data) and collision response. |
32 | /// Also provides the most basic sample for custom/user btCollisionAlgorithm | 32 | /// Also provides the most basic sample for custom/user btCollisionAlgorithm |
33 | /// </summary> | 33 | /// </summary> |
34 | public class SphereTriangleCollisionAlgorithm : CollisionAlgorithm, IDisposable | 34 | public class SphereTriangleCollisionAlgorithm : CollisionAlgorithm, IDisposable |
35 | { | 35 | { |
36 | private bool _ownManifold; | 36 | private bool _ownManifold; |
37 | private PersistentManifold _manifold; | 37 | private PersistentManifold _manifold; |
38 | private bool _isSwapped; | 38 | private bool _isSwapped; |
39 | 39 | ||
40 | public SphereTriangleCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, bool isSwapped) | 40 | public SphereTriangleCollisionAlgorithm(PersistentManifold manifold, CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB, bool isSwapped) |
41 | : base(collisionAlgorithmConstructionInfo) | 41 | : base(collisionAlgorithmConstructionInfo) |
42 | { | 42 | { |
43 | _ownManifold = false; | 43 | _ownManifold = false; |
44 | _manifold = manifold; | 44 | _manifold = manifold; |
45 | _isSwapped = isSwapped; | 45 | _isSwapped = isSwapped; |
46 | 46 | ||
47 | if (_manifold == null) | 47 | if (_manifold == null) |
48 | { | 48 | { |
49 | _manifold = Dispatcher.GetNewManifold(bodyA, bodyB); | 49 | _manifold = Dispatcher.GetNewManifold(bodyA, bodyB); |
50 | _ownManifold = true; | 50 | _ownManifold = true; |
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | public SphereTriangleCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo) | 54 | public SphereTriangleCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo) |
55 | : base(collisionAlgorithmConstructionInfo) { } | 55 | : base(collisionAlgorithmConstructionInfo) { } |
56 | 56 | ||
57 | public override void ProcessCollision(CollisionObject bodyA, CollisionObject bodyB, DispatcherInfo dispatchInfo, ManifoldResult resultOut) | 57 | public override void ProcessCollision(CollisionObject bodyA, CollisionObject bodyB, DispatcherInfo dispatchInfo, ManifoldResult resultOut) |
58 | { | 58 | { |
59 | if (_manifold == null) | 59 | if (_manifold == null) |
60 | return; | 60 | return; |
61 | 61 | ||
62 | SphereShape sphere = bodyA.CollisionShape as SphereShape; | 62 | SphereShape sphere = bodyA.CollisionShape as SphereShape; |
63 | TriangleShape triangle = bodyB.CollisionShape as TriangleShape; | 63 | TriangleShape triangle = bodyB.CollisionShape as TriangleShape; |
64 | 64 | ||
65 | /// report a contact. internally this will be kept persistent, and contact reduction is done | 65 | /// report a contact. internally this will be kept persistent, and contact reduction is done |
66 | resultOut.SetPersistentManifold(_manifold); | 66 | resultOut.SetPersistentManifold(_manifold); |
67 | SphereTriangleDetector detector = new SphereTriangleDetector(sphere, triangle); | 67 | SphereTriangleDetector detector = new SphereTriangleDetector(sphere, triangle); |
68 | 68 | ||
69 | DiscreteCollisionDetectorInterface.ClosestPointInput input = new DiscreteCollisionDetectorInterface.ClosestPointInput(); | 69 | DiscreteCollisionDetectorInterface.ClosestPointInput input = new DiscreteCollisionDetectorInterface.ClosestPointInput(); |
70 | input.MaximumDistanceSquared = 1e30f;//todo: tighter bounds | 70 | input.MaximumDistanceSquared = 1e30f;//todo: tighter bounds |
71 | input.TransformA = bodyA.WorldTransform; | 71 | input.TransformA = bodyA.WorldTransform; |
72 | input.TransformB = bodyB.WorldTransform; | 72 | input.TransformB = bodyB.WorldTransform; |
73 | 73 | ||
74 | detector.GetClosestPoints(input, resultOut, null); | 74 | detector.GetClosestPoints(input, resultOut, null); |
75 | } | 75 | } |
76 | 76 | ||
77 | public override float CalculateTimeOfImpact(CollisionObject bodyA, CollisionObject bodyB, DispatcherInfo dispatchInfo, ManifoldResult resultOut) | 77 | public override float CalculateTimeOfImpact(CollisionObject bodyA, CollisionObject bodyB, DispatcherInfo dispatchInfo, ManifoldResult resultOut) |
78 | { | 78 | { |
79 | //not yet | 79 | //not yet |
80 | return 1f; | 80 | return 1f; |
81 | } | 81 | } |
82 | 82 | ||
83 | public class CreateFunc : CollisionAlgorithmCreateFunction | 83 | public class CreateFunc : CollisionAlgorithmCreateFunction |
84 | { | 84 | { |
85 | public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB) | 85 | public override CollisionAlgorithm CreateCollisionAlgorithm(CollisionAlgorithmConstructionInfo collisionAlgorithmConstructionInfo, CollisionObject bodyA, CollisionObject bodyB) |
86 | { | 86 | { |
87 | return new SphereTriangleCollisionAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, IsSwapped); | 87 | return new SphereTriangleCollisionAlgorithm(collisionAlgorithmConstructionInfo.Manifold, collisionAlgorithmConstructionInfo, bodyA, bodyB, IsSwapped); |
88 | } | 88 | } |
89 | } | 89 | } |
90 | 90 | ||
91 | #region IDisposable Members | 91 | #region IDisposable Members |
92 | public void Dispose() | 92 | public void Dispose() |
93 | { | 93 | { |
94 | if (_ownManifold) | 94 | if (_ownManifold) |
95 | if (_manifold != null) | 95 | if (_manifold != null) |
96 | Dispatcher.ReleaseManifold(_manifold); | 96 | Dispatcher.ReleaseManifold(_manifold); |
97 | } | 97 | } |
98 | #endregion | 98 | #endregion |
99 | } | 99 | } |
100 | } | 100 | } |