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