aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs')
-rw-r--r--libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs117
1 files changed, 117 insertions, 0 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs
new file mode 100644
index 0000000..fae2557
--- /dev/null
+++ b/libraries/ModifiedBulletX/ModifiedBulletX/Collision/NarrowPhaseCollision/DiscreteCollisionDetectorInterface.cs
@@ -0,0 +1,117 @@
1/*
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
4
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
7 arising from the use of this software.
8
9 Permission is granted to anyone to use this software for any purpose,
10 including commercial applications, and to alter it and redistribute it
11 freely, subject to the following restrictions:
12
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
15 in a product, an acknowledgment in the product documentation would be
16 appreciated but is not required.
17 2. Altered source versions must be plainly marked as such, and must not be
18 misrepresented as being the original software.
19 3. This notice may not be removed or altered from any source distribution.
20*/
21
22using System;
23using System.Collections.Generic;
24using System.Text;
25using MonoXnaCompactMaths;
26
27namespace XnaDevRu.BulletX
28{
29 public abstract class DiscreteCollisionDetectorInterface
30 {
31 public abstract class Result
32 {
33 public abstract void SetShapeIdentifiers(int partIdA, int indexA, int partIdB, int indexB);
34 public abstract void AddContactPoint(Vector3 normalOnBInWorld, Vector3 pointInWorld, float depth);
35 }
36
37 public class ClosestPointInput
38 {
39 private float _maximumDistanceSquared;
40 private Matrix _transformA, _transformB;
41
42 #region Properties
43 public Matrix TransformB
44 {
45 get { return _transformB; }
46 set { _transformB = value; }
47 }
48
49 public Matrix TransformA
50 {
51 get { return _transformA; }
52 set { _transformA = value; }
53 }
54
55 public float MaximumDistanceSquared
56 {
57 get { return _maximumDistanceSquared; }
58 set { _maximumDistanceSquared = value; }
59 }
60 #endregion
61
62 public ClosestPointInput()
63 {
64 _maximumDistanceSquared = 1e30f;
65 }
66 }
67
68 public abstract void GetClosestPoints(ClosestPointInput input, Result output, IDebugDraw debugDraw);
69 }
70
71 public class StorageResult : DiscreteCollisionDetectorInterface.Result
72 {
73 private Vector3 _closestPointInB;
74 private Vector3 _normalOnSurfaceB;
75 private float _distance; //negative means penetration !
76
77 #region Properties
78
79 public float Distance
80 {
81 get { return _distance; }
82 set { _distance = value; }
83 }
84 public Vector3 NormalOnSurfaceB
85 {
86 get { return _normalOnSurfaceB; }
87 set { _normalOnSurfaceB = value; }
88 }
89 public Vector3 ClosestPointInB
90 {
91 get { return _closestPointInB; }
92 set { _closestPointInB = value; }
93 }
94
95 #endregion
96
97 public StorageResult()
98 {
99 _distance = 1e30f;
100 }
101
102 public override void AddContactPoint(Vector3 normalOnBInWorld, Vector3 pointInWorld, float depth)
103 {
104 if (depth < _distance)
105 {
106 _normalOnSurfaceB = normalOnBInWorld;
107 _closestPointInB = pointInWorld;
108 _distance = depth;
109 }
110 }
111
112 public override void SetShapeIdentifiers(int partId0, int index0, int partId1, int index1)
113 {
114 throw new Exception("The method or operation is not implemented.");
115 }
116 }
117}