diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs')
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | 51 |
1 files changed, 14 insertions, 37 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index 65fac00..25084d8 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -34,20 +34,12 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
34 | 34 | ||
35 | public abstract class BSConstraint : IDisposable | 35 | public abstract class BSConstraint : IDisposable |
36 | { | 36 | { |
37 | private static string LogHeader = "[BULLETSIM CONSTRAINT]"; | ||
38 | |||
39 | protected BulletSim m_world; | 37 | protected BulletSim m_world; |
40 | protected BulletBody m_body1; | 38 | protected BulletBody m_body1; |
41 | protected BulletBody m_body2; | 39 | protected BulletBody m_body2; |
42 | protected BulletConstraint m_constraint; | 40 | protected BulletConstraint m_constraint; |
43 | protected bool m_enabled = false; | 41 | protected bool m_enabled = false; |
44 | 42 | ||
45 | public BulletBody Body1 { get { return m_body1; } } | ||
46 | public BulletBody Body2 { get { return m_body2; } } | ||
47 | public BulletConstraint Constraint { get { return m_constraint; } } | ||
48 | public abstract ConstraintType Type { get; } | ||
49 | public bool IsEnabled { get { return m_enabled; } } | ||
50 | |||
51 | public BSConstraint() | 43 | public BSConstraint() |
52 | { | 44 | { |
53 | } | 45 | } |
@@ -56,25 +48,22 @@ public abstract class BSConstraint : IDisposable | |||
56 | { | 48 | { |
57 | if (m_enabled) | 49 | if (m_enabled) |
58 | { | 50 | { |
51 | // BulletSimAPI.RemoveConstraint(m_world.ID, m_body1.ID, m_body2.ID); | ||
52 | bool success = BulletSimAPI.DestroyConstraint2(m_world.Ptr, m_constraint.Ptr); | ||
53 | m_world.scene.DetailLog("{0},BSConstraint.Dispose,taint,body1={1},body2={2},success={3}", BSScene.DetailLogZero, m_body1.ID, m_body2.ID, success); | ||
54 | m_constraint.Ptr = System.IntPtr.Zero; | ||
59 | m_enabled = false; | 55 | m_enabled = false; |
60 | if (m_constraint.ptr != IntPtr.Zero) | ||
61 | { | ||
62 | bool success = BulletSimAPI.DestroyConstraint2(m_world.ptr, m_constraint.ptr); | ||
63 | m_world.physicsScene.DetailLog("{0},BSConstraint.Dispose,taint,id1={1},body1={2},id2={3},body2={4},success={5}", | ||
64 | BSScene.DetailLogZero, | ||
65 | m_body1.ID, m_body1.ptr.ToString("X"), | ||
66 | m_body2.ID, m_body2.ptr.ToString("X"), | ||
67 | success); | ||
68 | m_constraint.ptr = System.IntPtr.Zero; | ||
69 | } | ||
70 | } | 56 | } |
71 | } | 57 | } |
72 | 58 | ||
59 | public BulletBody Body1 { get { return m_body1; } } | ||
60 | public BulletBody Body2 { get { return m_body2; } } | ||
61 | |||
73 | public virtual bool SetLinearLimits(Vector3 low, Vector3 high) | 62 | public virtual bool SetLinearLimits(Vector3 low, Vector3 high) |
74 | { | 63 | { |
75 | bool ret = false; | 64 | bool ret = false; |
76 | if (m_enabled) | 65 | if (m_enabled) |
77 | ret = BulletSimAPI.SetLinearLimits2(m_constraint.ptr, low, high); | 66 | ret = BulletSimAPI.SetLinearLimits2(m_constraint.Ptr, low, high); |
78 | return ret; | 67 | return ret; |
79 | } | 68 | } |
80 | 69 | ||
@@ -82,18 +71,7 @@ public abstract class BSConstraint : IDisposable | |||
82 | { | 71 | { |
83 | bool ret = false; | 72 | bool ret = false; |
84 | if (m_enabled) | 73 | if (m_enabled) |
85 | ret = BulletSimAPI.SetAngularLimits2(m_constraint.ptr, low, high); | 74 | ret = BulletSimAPI.SetAngularLimits2(m_constraint.Ptr, low, high); |
86 | return ret; | ||
87 | } | ||
88 | |||
89 | public virtual bool SetSolverIterations(float cnt) | ||
90 | { | ||
91 | bool ret = false; | ||
92 | if (m_enabled) | ||
93 | { | ||
94 | BulletSimAPI.SetConstraintNumSolverIterations2(m_constraint.ptr, cnt); | ||
95 | ret = true; | ||
96 | } | ||
97 | return ret; | 75 | return ret; |
98 | } | 76 | } |
99 | 77 | ||
@@ -103,7 +81,7 @@ public abstract class BSConstraint : IDisposable | |||
103 | if (m_enabled) | 81 | if (m_enabled) |
104 | { | 82 | { |
105 | // Recompute the internal transforms | 83 | // Recompute the internal transforms |
106 | BulletSimAPI.CalculateTransforms2(m_constraint.ptr); | 84 | BulletSimAPI.CalculateTransforms2(m_constraint.Ptr); |
107 | ret = true; | 85 | ret = true; |
108 | } | 86 | } |
109 | return ret; | 87 | return ret; |
@@ -119,14 +97,13 @@ public abstract class BSConstraint : IDisposable | |||
119 | ret = CalculateTransforms(); | 97 | ret = CalculateTransforms(); |
120 | if (ret) | 98 | if (ret) |
121 | { | 99 | { |
122 | // Setting an object's mass to zero (making it static like when it's selected) | 100 | // m_world.scene.PhysicsLogging.Write("{0},BSConstraint.RecomputeConstraintVariables,taint,enabling,A={1},B={2}", |
123 | // automatically disables the constraints. | 101 | // BSScene.DetailLogZero, Body1.ID, Body2.ID); |
124 | // If the link is enabled, be sure to set the constraint itself to enabled. | 102 | BulletSimAPI.SetConstraintEnable2(m_constraint.Ptr, m_world.scene.NumericBool(true)); |
125 | BulletSimAPI.SetConstraintEnable2(m_constraint.ptr, m_world.physicsScene.NumericBool(true)); | ||
126 | } | 103 | } |
127 | else | 104 | else |
128 | { | 105 | { |
129 | m_world.physicsScene.Logger.ErrorFormat("{0} CalculateTransforms failed. A={1}, B={2}", LogHeader, Body1.ID, Body2.ID); | 106 | m_world.scene.Logger.ErrorFormat("[BULLETSIM CONSTRAINT] CalculateTransforms failed. A={0}, B={1}", Body1.ID, Body2.ID); |
130 | } | 107 | } |
131 | } | 108 | } |
132 | return ret; | 109 | return ret; |