aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs')
-rw-r--r--libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs176
1 files changed, 88 insertions, 88 deletions
diff --git a/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs b/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs
index abd10f1..8131463 100644
--- a/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs
+++ b/libraries/ModifiedBulletX/ModifiedBulletX/Dynamics/ConstraintSolver/TypedConstraint.cs
@@ -1,88 +1,88 @@
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
22using System; 22using System;
23using System.Collections.Generic; 23using System.Collections.Generic;
24using System.Text; 24using System.Text;
25using MonoXnaCompactMaths; 25using MonoXnaCompactMaths;
26 26
27namespace XnaDevRu.BulletX.Dynamics 27namespace XnaDevRu.BulletX.Dynamics
28{ 28{
29 public abstract class TypedConstraint 29 public abstract class TypedConstraint
30 { 30 {
31 private static RigidBody _fixed = new RigidBody(0, null, null, new Vector3(), 0, 0, 0.5f, 0); 31 private static RigidBody _fixed = new RigidBody(0, null, null, new Vector3(), 0, 0, 0.5f, 0);
32 private int _userConstraintType; 32 private int _userConstraintType;
33 private int _userConstraintId; 33 private int _userConstraintId;
34 34
35 private RigidBody _rbA; 35 private RigidBody _rbA;
36 private RigidBody _rbB; 36 private RigidBody _rbB;
37 private float _appliedImpulse; 37 private float _appliedImpulse;
38 38
39 public TypedConstraint() 39 public TypedConstraint()
40 : this(_fixed, _fixed) { } 40 : this(_fixed, _fixed) { }
41 41
42 public TypedConstraint(RigidBody rbA) 42 public TypedConstraint(RigidBody rbA)
43 : this(rbA, _fixed) { } 43 : this(rbA, _fixed) { }
44 44
45 public TypedConstraint(RigidBody rbA, RigidBody rbB) 45 public TypedConstraint(RigidBody rbA, RigidBody rbB)
46 { 46 {
47 _userConstraintType = -1; 47 _userConstraintType = -1;
48 _userConstraintId = -1; 48 _userConstraintId = -1;
49 _rbA = rbA; 49 _rbA = rbA;
50 _rbB = rbB; 50 _rbB = rbB;
51 _appliedImpulse = 0; 51 _appliedImpulse = 0;
52 52
53 _fixed.SetMassProps(0, new Vector3()); 53 _fixed.SetMassProps(0, new Vector3());
54 } 54 }
55 55
56 public virtual RigidBody RigidBodyA { get { return _rbA; } protected set { _rbA = value; } } 56 public virtual RigidBody RigidBodyA { get { return _rbA; } protected set { _rbA = value; } }
57 public virtual RigidBody RigidBodyB { get { return _rbB; } protected set { _rbB = value; } } 57 public virtual RigidBody RigidBodyB { get { return _rbB; } protected set { _rbB = value; } }
58 58
59 public float AppliedImpulse { get { return _appliedImpulse; } protected set { _appliedImpulse = value; } } 59 public float AppliedImpulse { get { return _appliedImpulse; } protected set { _appliedImpulse = value; } }
60 public int UserConstraintId { get { return _userConstraintId; } set { _userConstraintId = value; } } 60 public int UserConstraintId { get { return _userConstraintId; } set { _userConstraintId = value; } }
61 public int UserConstraintType { get { return _userConstraintType; } set { _userConstraintType = value; } } 61 public int UserConstraintType { get { return _userConstraintType; } set { _userConstraintType = value; } }
62 62
63 public abstract void BuildJacobian(); 63 public abstract void BuildJacobian();
64 public abstract void SolveConstraint(float timeStep); 64 public abstract void SolveConstraint(float timeStep);
65 65
66 public static int SortConstraintOnIslandPredicate(TypedConstraint left, TypedConstraint right) 66 public static int SortConstraintOnIslandPredicate(TypedConstraint left, TypedConstraint right)
67 { 67 {
68 int rightIslandID, leftIslandID; 68 int rightIslandID, leftIslandID;
69 rightIslandID = GetConstraintIslandId(right); 69 rightIslandID = GetConstraintIslandId(right);
70 leftIslandID = GetConstraintIslandId(left); 70 leftIslandID = GetConstraintIslandId(left);
71 if (leftIslandID < rightIslandID) 71 if (leftIslandID < rightIslandID)
72 return -1; 72 return -1;
73 else 73 else
74 return 1; 74 return 1;
75 return 0; 75 return 0;
76 } 76 }
77 77
78 internal static int GetConstraintIslandId(TypedConstraint lhs) 78 internal static int GetConstraintIslandId(TypedConstraint lhs)
79 { 79 {
80 int islandId; 80 int islandId;
81 81
82 CollisionObject colObjA = lhs.RigidBodyA; 82 CollisionObject colObjA = lhs.RigidBodyA;
83 CollisionObject colObjB = lhs.RigidBodyB; 83 CollisionObject colObjB = lhs.RigidBodyB;
84 islandId = colObjA.IslandTag >= 0 ? colObjA.IslandTag : colObjB.IslandTag; 84 islandId = colObjA.IslandTag >= 0 ? colObjA.IslandTag : colObjB.IslandTag;
85 return islandId; 85 return islandId;
86 } 86 }
87 } 87 }
88} 88}