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