aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorTeravus Ovares2009-04-11 03:04:08 +0000
committerTeravus Ovares2009-04-11 03:04:08 +0000
commit2dca78b2bf019c46432ee018df36ee13310c9c94 (patch)
tree468a9ca3a5b2a2aa3c3a3c40cf25fb1ac5585532 /OpenSim/Region
parent* Add catch-all error handlers back to scene. (diff)
downloadopensim-SC_OLD-2dca78b2bf019c46432ee018df36ee13310c9c94.zip
opensim-SC_OLD-2dca78b2bf019c46432ee018df36ee13310c9c94.tar.gz
opensim-SC_OLD-2dca78b2bf019c46432ee018df36ee13310c9c94.tar.bz2
opensim-SC_OLD-2dca78b2bf019c46432ee018df36ee13310c9c94.tar.xz
* BulletDotNETPlugin supports Axis lock (LLSetStatus) from the script engine now.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs95
1 files changed, 93 insertions, 2 deletions
diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
index 9f68f02..a2caeac 100644
--- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
+++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs
@@ -181,8 +181,13 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
181 private btTransform tempTransform3; 181 private btTransform tempTransform3;
182 private btTransform tempTransform4; 182 private btTransform tempTransform4;
183 private btTriangleIndexVertexArray btshapeArray; 183 private btTriangleIndexVertexArray btshapeArray;
184 private btVector3 AxisLockAngleHigh;
185 private btVector3 AxisLockLinearLow;
186 private btVector3 AxisLockLinearHigh;
184 private bool forceenable = false; 187 private bool forceenable = false;
185 188
189 private btGeneric6DofConstraint m_aMotor;
190
186 public btRigidBody Body; 191 public btRigidBody Body;
187 192
188 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size, 193 public BulletDotNETPrim(String primName, BulletDotNETScene parent_scene, PhysicsVector pos, PhysicsVector size,
@@ -211,6 +216,9 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
211 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero); 216 tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero);
212 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero); 217 tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero);
213 218
219 AxisLockLinearLow = new btVector3(-256,-256,-256);
220 AxisLockLinearHigh = new btVector3(512, 512, 512);
221
214 _target_velocity = new PhysicsVector(0, 0, 0); 222 _target_velocity = new PhysicsVector(0, 0, 0);
215 _velocity = new PhysicsVector(); 223 _velocity = new PhysicsVector();
216 _position = pos; 224 _position = pos;
@@ -594,9 +602,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
594 internal void Dispose() 602 internal void Dispose()
595 { 603 {
596 //TODO: 604 //TODO:
605 DisableAxisMotor();
597 DisposeOfBody(); 606 DisposeOfBody();
598 SetCollisionShape(null); 607 SetCollisionShape(null);
599 608
600 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero) 609 if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero)
601 { 610 {
602 tempMotionState3.Dispose(); 611 tempMotionState3.Dispose();
@@ -717,6 +726,16 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
717 tempPosition1.Dispose(); 726 tempPosition1.Dispose();
718 tempPosition1 = null; 727 tempPosition1 = null;
719 } 728 }
729 if (AxisLockLinearLow != null && AxisLockLinearLow.Handle != IntPtr.Zero)
730 {
731 AxisLockLinearLow.Dispose();
732 AxisLockLinearLow = null;
733 }
734 if (AxisLockLinearHigh != null && AxisLockLinearHigh.Handle != IntPtr.Zero)
735 {
736 AxisLockLinearHigh.Dispose();
737 AxisLockLinearHigh = null;
738 }
720 739
721 } 740 }
722 741
@@ -847,6 +866,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
847 { 866 {
848 if (Body.Handle != IntPtr.Zero) 867 if (Body.Handle != IntPtr.Zero)
849 { 868 {
869 DisableAxisMotor();
850 _parent_scene.removeFromWorld(this, Body); 870 _parent_scene.removeFromWorld(this, Body);
851 //Body.Dispose(); 871 //Body.Dispose();
852 } 872 }
@@ -903,6 +923,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
903 { 923 {
904 if (Body.Handle != IntPtr.Zero) 924 if (Body.Handle != IntPtr.Zero)
905 { 925 {
926 DisableAxisMotor();
906 _parent_scene.removeFromWorld(this, Body); 927 _parent_scene.removeFromWorld(this, Body);
907 //Body.Dispose(); 928 //Body.Dispose();
908 } 929 }
@@ -958,6 +979,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
958 { 979 {
959 if (Body.Handle != IntPtr.Zero) 980 if (Body.Handle != IntPtr.Zero)
960 { 981 {
982 DisableAxisMotor();
961 _parent_scene.removeFromWorld(this, Body); 983 _parent_scene.removeFromWorld(this, Body);
962 //Body.Dispose(); 984 //Body.Dispose();
963 } 985 }
@@ -1048,6 +1070,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1048 { 1070 {
1049 if (Body.Handle != IntPtr.Zero) 1071 if (Body.Handle != IntPtr.Zero)
1050 { 1072 {
1073 DisableAxisMotor();
1051 _parent_scene.removeFromWorld(this, Body); 1074 _parent_scene.removeFromWorld(this, Body);
1052 //Body.Dispose(); 1075 //Body.Dispose();
1053 } 1076 }
@@ -1075,6 +1098,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1075 { 1098 {
1076 if (Body.Handle != IntPtr.Zero) 1099 if (Body.Handle != IntPtr.Zero)
1077 { 1100 {
1101 DisableAxisMotor();
1078 _parent_scene.removeFromWorld(this, Body); 1102 _parent_scene.removeFromWorld(this, Body);
1079 //Body.Dispose(); 1103 //Body.Dispose();
1080 } 1104 }
@@ -1299,6 +1323,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1299 { 1323 {
1300 if (Body.Handle != IntPtr.Zero) 1324 if (Body.Handle != IntPtr.Zero)
1301 { 1325 {
1326 DisableAxisMotor();
1302 _parent_scene.removeFromWorld(this, Body); 1327 _parent_scene.removeFromWorld(this, Body);
1303 //Body.Dispose(); 1328 //Body.Dispose();
1304 } 1329 }
@@ -1347,7 +1372,25 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
1347 1372
1348 private void changeAngularLock(float timestep) 1373 private void changeAngularLock(float timestep)
1349 { 1374 {
1350 // TODO: throw new NotImplementedException(); 1375 if (IsPhysical && Body != null && Body.Handle != IntPtr.Zero)
1376 {
1377 if (_parent == null)
1378 {
1379 if (!m_taintAngularLock.IsIdentical(new PhysicsVector(1f, 1f, 1f), 0))
1380 {
1381 //d.BodySetFiniteRotationMode(Body, 0);
1382 //d.BodySetFiniteRotationAxis(Body,m_taintAngularLock.X,m_taintAngularLock.Y,m_taintAngularLock.Z);
1383 EnableAxisMotor(m_taintAngularLock);
1384 }
1385 else
1386 {
1387 DisableAxisMotor();
1388 }
1389 }
1390
1391 }
1392 m_angularlock = new PhysicsVector(m_taintAngularLock.X, m_taintAngularLock.Y, m_taintAngularLock.Z);
1393
1351 } 1394 }
1352 #endregion 1395 #endregion
1353 1396
@@ -2187,7 +2230,11 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2187 ((btGImpactMeshShape)prim_geom).updateBound(); 2230 ((btGImpactMeshShape)prim_geom).updateBound();
2188 } 2231 }
2189 _parent_scene.AddPrimToScene(this); 2232 _parent_scene.AddPrimToScene(this);
2233
2190 } 2234 }
2235
2236 if (IsPhysical)
2237 changeAngularLock(0);
2191 } 2238 }
2192 2239
2193 private void DisposeOfBody() 2240 private void DisposeOfBody()
@@ -2196,6 +2243,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2196 { 2243 {
2197 if (Body.Handle != IntPtr.Zero) 2244 if (Body.Handle != IntPtr.Zero)
2198 { 2245 {
2246 DisableAxisMotor();
2199 _parent_scene.removeFromWorld(this,Body); 2247 _parent_scene.removeFromWorld(this,Body);
2200 Body.Dispose(); 2248 Body.Dispose();
2201 } 2249 }
@@ -2317,6 +2365,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2317 2365
2318 } 2366 }
2319 */ 2367 */
2368 DisableAxisMotor();
2320 m_disabled = true; 2369 m_disabled = true;
2321 m_collisionscore = 0; 2370 m_collisionscore = 0;
2322 } 2371 }
@@ -2597,6 +2646,48 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin
2597 { 2646 {
2598 m_taintremove = true; 2647 m_taintremove = true;
2599 } 2648 }
2649
2650 internal void EnableAxisMotor(PhysicsVector axislock)
2651 {
2652 if (m_aMotor != null)
2653 DisableAxisMotor();
2654
2655 if (Body == null)
2656 return;
2657
2658 if (Body.Handle == IntPtr.Zero)
2659 return;
2660
2661 if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero)
2662 AxisLockAngleHigh.Dispose();
2663
2664
2665
2666 m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero,
2667 _parent_scene.TransZero, false);
2668
2669 float endNoLock = (360 * Utils.DEG_TO_RAD);
2670 AxisLockAngleHigh = new btVector3((axislock.X == 0) ? 0 : endNoLock, (axislock.Y == 0) ? 0 : endNoLock, (axislock.Z == 0) ? 0 : endNoLock);
2671
2672 m_aMotor.setAngularLowerLimit(_parent_scene.VectorZero);
2673 m_aMotor.setAngularUpperLimit(AxisLockAngleHigh);
2674 m_aMotor.setLinearLowerLimit(AxisLockLinearLow);
2675 m_aMotor.setLinearUpperLimit(AxisLockLinearHigh);
2676 _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor);
2677 //m_aMotor.
2678
2679
2680 }
2681 internal void DisableAxisMotor()
2682 {
2683 if (m_aMotor != null && m_aMotor.Handle != IntPtr.Zero)
2684 {
2685 _parent_scene.getBulletWorld().removeConstraint(m_aMotor);
2686 m_aMotor.Dispose();
2687 m_aMotor = null;
2688 }
2689 }
2690
2600 } 2691 }
2601} 2692}
2602 2693