diff options
Diffstat (limited to '')
5 files changed, 43 insertions, 35 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs index 5f74a14..aa75663 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActorLockAxis.cs | |||
@@ -42,14 +42,14 @@ public class BSActorLockAxis : BSActor | |||
42 | public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName) | 42 | public BSActorLockAxis(BSScene physicsScene, BSPhysObject pObj, string actorName) |
43 | : base(physicsScene, pObj,actorName) | 43 | : base(physicsScene, pObj,actorName) |
44 | { | 44 | { |
45 | PhysicsScene.DetailLog("{0},BSActorLockAxis,constructor", Prim.LocalID); | 45 | m_physicsScene.DetailLog("{0},BSActorLockAxis,constructor", m_controllingPrim.LocalID); |
46 | LockAxisConstraint = null; | 46 | LockAxisConstraint = null; |
47 | } | 47 | } |
48 | 48 | ||
49 | // BSActor.isActive | 49 | // BSActor.isActive |
50 | public override bool isActive | 50 | public override bool isActive |
51 | { | 51 | { |
52 | get { return Enabled && Prim.IsPhysicallyActive; } | 52 | get { return Enabled && m_controllingPrim.IsPhysicallyActive; } |
53 | } | 53 | } |
54 | 54 | ||
55 | // Release any connections and resources used by the actor. | 55 | // Release any connections and resources used by the actor. |
@@ -64,21 +64,22 @@ public class BSActorLockAxis : BSActor | |||
64 | // BSActor.Refresh() | 64 | // BSActor.Refresh() |
65 | public override void Refresh() | 65 | public override void Refresh() |
66 | { | 66 | { |
67 | PhysicsScene.DetailLog("{0},BSActorLockAxis,refresh,lockedAxis={1},enabled={2},pActive={3}", | 67 | m_physicsScene.DetailLog("{0},BSActorLockAxis,refresh,lockedAxis={1},enabled={2},pActive={3}", |
68 | Prim.LocalID, Prim.LockedAxis, Enabled, Prim.IsPhysicallyActive); | 68 | m_controllingPrim.LocalID, m_controllingPrim.LockedAxis, Enabled, m_controllingPrim.IsPhysicallyActive); |
69 | // If all the axis are free, we don't need to exist | 69 | // If all the axis are free, we don't need to exist |
70 | if (Prim.LockedAxis == Prim.LockedAxisFree) | 70 | if (m_controllingPrim.LockedAxis == m_controllingPrim.LockedAxisFree) |
71 | { | 71 | { |
72 | Prim.PhysicalActors.RemoveAndRelease(ActorName); | 72 | m_physicsScene.DetailLog("{0},BSActorLockAxis,refresh,allAxisFree,removing={1}", m_controllingPrim.LocalID, ActorName); |
73 | m_controllingPrim.PhysicalActors.RemoveAndRelease(ActorName); | ||
73 | return; | 74 | return; |
74 | } | 75 | } |
75 | // If the object is physically active, add the axis locking constraint | 76 | // If the object is physically active, add the axis locking constraint |
76 | if (Enabled | 77 | if (Enabled |
77 | && Prim.IsPhysicallyActive | 78 | && m_controllingPrim.IsPhysicallyActive |
78 | && TryExperimentalLockAxisCode | 79 | && TryExperimentalLockAxisCode |
79 | && Prim.LockedAxis != Prim.LockedAxisFree) | 80 | && m_controllingPrim.LockedAxis != m_controllingPrim.LockedAxisFree) |
80 | { | 81 | { |
81 | if (LockAxisConstraint != null) | 82 | if (LockAxisConstraint == null) |
82 | AddAxisLockConstraint(); | 83 | AddAxisLockConstraint(); |
83 | } | 84 | } |
84 | else | 85 | else |
@@ -98,7 +99,7 @@ public class BSActorLockAxis : BSActor | |||
98 | // If a constraint is set up, remove it from the physical scene | 99 | // If a constraint is set up, remove it from the physical scene |
99 | RemoveAxisLockConstraint(); | 100 | RemoveAxisLockConstraint(); |
100 | // Schedule a call before the next simulation step to restore the constraint. | 101 | // Schedule a call before the next simulation step to restore the constraint. |
101 | PhysicsScene.PostTaintObject(Prim.LockedAxisActorName, Prim.LocalID, delegate() | 102 | m_physicsScene.PostTaintObject(m_controllingPrim.LockedAxisActorName, m_controllingPrim.LocalID, delegate() |
102 | { | 103 | { |
103 | Refresh(); | 104 | Refresh(); |
104 | }); | 105 | }); |
@@ -115,56 +116,61 @@ public class BSActorLockAxis : BSActor | |||
115 | // Remove any existing axis constraint (just to be sure) | 116 | // Remove any existing axis constraint (just to be sure) |
116 | RemoveAxisLockConstraint(); | 117 | RemoveAxisLockConstraint(); |
117 | 118 | ||
118 | BSConstraint6Dof axisConstrainer = new BSConstraint6Dof(PhysicsScene.World, Prim.PhysBody, | 119 | BSConstraint6Dof axisConstrainer = new BSConstraint6Dof(m_physicsScene.World, m_controllingPrim.PhysBody, |
119 | OMV.Vector3.Zero, OMV.Quaternion.Inverse(Prim.RawOrientation), | 120 | // OMV.Vector3.Zero, OMV.Quaternion.Identity, |
120 | true /* useLinearReferenceFrameB */, true /* disableCollisionsBetweenLinkedBodies */); | 121 | OMV.Vector3.Zero, OMV.Quaternion.Inverse(m_controllingPrim.RawOrientation), |
122 | // OMV.Vector3.Zero, m_controllingPrim.RawOrientation, | ||
123 | false /* useLinearReferenceFrameB */, true /* disableCollisionsBetweenLinkedBodies */); | ||
121 | LockAxisConstraint = axisConstrainer; | 124 | LockAxisConstraint = axisConstrainer; |
122 | PhysicsScene.Constraints.AddConstraint(LockAxisConstraint); | 125 | m_physicsScene.Constraints.AddConstraint(LockAxisConstraint); |
123 | 126 | ||
124 | // The constraint is tied to the world and oriented to the prim. | 127 | // The constraint is tied to the world and oriented to the prim. |
125 | 128 | ||
126 | // Free to move linearly | 129 | // Free to move linearly in the region |
127 | OMV.Vector3 linearLow = OMV.Vector3.Zero; | 130 | OMV.Vector3 linearLow = OMV.Vector3.Zero; |
128 | OMV.Vector3 linearHigh = PhysicsScene.TerrainManager.DefaultRegionSize; | 131 | OMV.Vector3 linearHigh = m_physicsScene.TerrainManager.DefaultRegionSize; |
129 | axisConstrainer.SetLinearLimits(linearLow, linearHigh); | 132 | axisConstrainer.SetLinearLimits(linearLow, linearHigh); |
130 | 133 | ||
131 | // Angular with some axis locked | 134 | // Angular with some axis locked |
132 | float f2PI = (float)Math.PI * 2f; | 135 | float fPI = (float)Math.PI; |
133 | OMV.Vector3 angularLow = new OMV.Vector3(-f2PI, -f2PI, -f2PI); | 136 | OMV.Vector3 angularLow = new OMV.Vector3(-fPI, -fPI, -fPI); |
134 | OMV.Vector3 angularHigh = new OMV.Vector3(f2PI, f2PI, f2PI); | 137 | OMV.Vector3 angularHigh = new OMV.Vector3(fPI, fPI, fPI); |
135 | if (Prim.LockedAxis.X != 1f) | 138 | if (m_controllingPrim.LockedAxis.X != 1f) |
136 | { | 139 | { |
137 | angularLow.X = 0f; | 140 | angularLow.X = 0f; |
138 | angularHigh.X = 0f; | 141 | angularHigh.X = 0f; |
139 | } | 142 | } |
140 | if (Prim.LockedAxis.Y != 1f) | 143 | if (m_controllingPrim.LockedAxis.Y != 1f) |
141 | { | 144 | { |
142 | angularLow.Y = 0f; | 145 | angularLow.Y = 0f; |
143 | angularHigh.Y = 0f; | 146 | angularHigh.Y = 0f; |
144 | } | 147 | } |
145 | if (Prim.LockedAxis.Z != 1f) | 148 | if (m_controllingPrim.LockedAxis.Z != 1f) |
146 | { | 149 | { |
147 | angularLow.Z = 0f; | 150 | angularLow.Z = 0f; |
148 | angularHigh.Z = 0f; | 151 | angularHigh.Z = 0f; |
149 | } | 152 | } |
150 | axisConstrainer.SetAngularLimits(angularLow, angularHigh); | 153 | if (!axisConstrainer.SetAngularLimits(angularLow, angularHigh)) |
154 | { | ||
155 | m_physicsScene.DetailLog("{0},BSActorLockAxis.AddAxisLockConstraint,failedSetAngularLimits", m_controllingPrim.LocalID); | ||
156 | } | ||
151 | 157 | ||
152 | PhysicsScene.DetailLog("{0},BSPrim.LockAngularMotion,create,linLow={1},linHi={2},angLow={3},angHi={4}", | 158 | m_physicsScene.DetailLog("{0},BSActorLockAxis.AddAxisLockConstraint,create,linLow={1},linHi={2},angLow={3},angHi={4}", |
153 | Prim.LocalID, linearLow, linearHigh, angularLow, angularHigh); | 159 | m_controllingPrim.LocalID, linearLow, linearHigh, angularLow, angularHigh); |
154 | 160 | ||
155 | // Constants from one of the posts mentioned above and used in Bullet's ConstraintDemo. | 161 | // Constants from one of the posts mentioned above and used in Bullet's ConstraintDemo. |
156 | axisConstrainer.TranslationalLimitMotor(true /* enable */, 5.0f, 0.1f); | 162 | axisConstrainer.TranslationalLimitMotor(true /* enable */, 5.0f, 0.1f); |
157 | 163 | ||
158 | axisConstrainer.RecomputeConstraintVariables(Prim.RawMass); | 164 | axisConstrainer.RecomputeConstraintVariables(m_controllingPrim.RawMass); |
159 | } | 165 | } |
160 | 166 | ||
161 | private void RemoveAxisLockConstraint() | 167 | private void RemoveAxisLockConstraint() |
162 | { | 168 | { |
163 | if (LockAxisConstraint != null) | 169 | if (LockAxisConstraint != null) |
164 | { | 170 | { |
165 | PhysicsScene.Constraints.RemoveAndDestroyConstraint(LockAxisConstraint); | 171 | m_physicsScene.Constraints.RemoveAndDestroyConstraint(LockAxisConstraint); |
166 | LockAxisConstraint = null; | 172 | LockAxisConstraint = null; |
167 | PhysicsScene.DetailLog("{0},BSPrim.CleanUpLockAxisPhysicals,destroyingConstraint", Prim.LocalID); | 173 | m_physicsScene.DetailLog("{0},BSActorLockAxis.RemoveAxisLockConstraint,destroyingConstraint", m_controllingPrim.LocalID); |
168 | } | 174 | } |
169 | } | 175 | } |
170 | } | 176 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs index 3163440..5a19ba4 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSActors.cs | |||
@@ -96,15 +96,15 @@ public class BSActorCollection | |||
96 | /// </summary> | 96 | /// </summary> |
97 | public abstract class BSActor | 97 | public abstract class BSActor |
98 | { | 98 | { |
99 | protected BSScene PhysicsScene { get; private set; } | 99 | protected BSScene m_physicsScene { get; private set; } |
100 | protected BSPhysObject Prim { get; private set; } | 100 | protected BSPhysObject m_controllingPrim { get; private set; } |
101 | protected bool Enabled { get; set; } | 101 | protected bool Enabled { get; set; } |
102 | public string ActorName { get; private set; } | 102 | public string ActorName { get; private set; } |
103 | 103 | ||
104 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) | 104 | public BSActor(BSScene physicsScene, BSPhysObject pObj, string actorName) |
105 | { | 105 | { |
106 | PhysicsScene = physicsScene; | 106 | m_physicsScene = physicsScene; |
107 | Prim = pObj; | 107 | m_controllingPrim = pObj; |
108 | ActorName = actorName; | 108 | ActorName = actorName; |
109 | Enabled = true; | 109 | Enabled = true; |
110 | } | 110 | } |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs index b813974..42b5c49 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint.cs | |||
@@ -85,7 +85,9 @@ public abstract class BSConstraint : IDisposable | |||
85 | { | 85 | { |
86 | bool ret = false; | 86 | bool ret = false; |
87 | if (m_enabled) | 87 | if (m_enabled) |
88 | { | ||
88 | ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high); | 89 | ret = PhysicsScene.PE.SetAngularLimits(m_constraint, low, high); |
90 | } | ||
89 | return ret; | 91 | return ret; |
90 | } | 92 | } |
91 | 93 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs index 476a0e5..d0949f5 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSConstraint6Dof.cs | |||
@@ -97,14 +97,14 @@ public sealed class BSConstraint6Dof : BSConstraint | |||
97 | 97 | ||
98 | // A 6 Dof constraint that is fixed in the world and constrained to a on-the-fly created static object | 98 | // A 6 Dof constraint that is fixed in the world and constrained to a on-the-fly created static object |
99 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, Vector3 frameInBloc, Quaternion frameInBrot, | 99 | public BSConstraint6Dof(BulletWorld world, BulletBody obj1, Vector3 frameInBloc, Quaternion frameInBrot, |
100 | bool useLinearReferenceFrameA, bool disableCollisionsBetweenLinkedBodies) | 100 | bool useLinearReferenceFrameB, bool disableCollisionsBetweenLinkedBodies) |
101 | : base(world) | 101 | : base(world) |
102 | { | 102 | { |
103 | m_body1 = obj1; | 103 | m_body1 = obj1; |
104 | m_body2 = obj1; // Look out for confusion down the road | 104 | m_body2 = obj1; // Look out for confusion down the road |
105 | m_constraint = PhysicsScene.PE.Create6DofConstraintFixed(m_world, m_body1, | 105 | m_constraint = PhysicsScene.PE.Create6DofConstraintFixed(m_world, m_body1, |
106 | frameInBloc, frameInBrot, | 106 | frameInBloc, frameInBrot, |
107 | useLinearReferenceFrameA, disableCollisionsBetweenLinkedBodies); | 107 | useLinearReferenceFrameB, disableCollisionsBetweenLinkedBodies); |
108 | m_enabled = true; | 108 | m_enabled = true; |
109 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}", | 109 | world.physicsScene.DetailLog("{0},BS6DofConstraint,createFixed,wID={1},rID={2},rBody={3}", |
110 | BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString); | 110 | BSScene.DetailLogZero, world.worldID, obj1.ID, obj1.AddrString); |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index ec78fdc..e56276a 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -274,10 +274,10 @@ public class BSPrim : BSPhysObject | |||
274 | { | 274 | { |
275 | PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate() | 275 | PhysicsScene.TaintedObject("BSPrim.LockAngularMotion", delegate() |
276 | { | 276 | { |
277 | DetailLog("{0},BSPrim.LockAngularMotion,taint,registeringLockAxisActor", LocalID); | ||
278 | // If there is not already an axis locker, make one | 277 | // If there is not already an axis locker, make one |
279 | if (!PhysicalActors.HasActor(LockedAxisActorName)) | 278 | if (!PhysicalActors.HasActor(LockedAxisActorName)) |
280 | { | 279 | { |
280 | DetailLog("{0},BSPrim.LockAngularMotion,taint,registeringLockAxisActor", LocalID); | ||
281 | PhysicalActors.Add(LockedAxisActorName, new BSActorLockAxis(PhysicsScene, this, LockedAxisActorName)); | 281 | PhysicalActors.Add(LockedAxisActorName, new BSActorLockAxis(PhysicsScene, this, LockedAxisActorName)); |
282 | } | 282 | } |
283 | UpdatePhysicalParameters(); | 283 | UpdatePhysicalParameters(); |