aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
diff options
context:
space:
mode:
authorRobert Adams2012-10-31 09:26:58 -0700
committerRobert Adams2012-11-03 21:14:58 -0700
commit28e2cd3fa21835b124552dec024745f5784f6b3a (patch)
tree03b422548908cb2c4ec734c27ac2ad9824015cca /OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
parentBulletSim: remove center-of-mass setting for linksets because it causes the c... (diff)
downloadopensim-SC_OLD-28e2cd3fa21835b124552dec024745f5784f6b3a.zip
opensim-SC_OLD-28e2cd3fa21835b124552dec024745f5784f6b3a.tar.gz
opensim-SC_OLD-28e2cd3fa21835b124552dec024745f5784f6b3a.tar.bz2
opensim-SC_OLD-28e2cd3fa21835b124552dec024745f5784f6b3a.tar.xz
BulletSim: vehicle tweeking.
Add AddTorque() method to BSPrim. Remove some manual motor actions in computing angular force (will eventually be replaced with motor class). Remove some experimental changes.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs45
1 files changed, 37 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index 7851a40..9ced61fa 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -378,7 +378,9 @@ public sealed class BSPrim : BSPhysObject
378 { 378 {
379 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, physMass); 379 OMV.Vector3 localInertia = BulletSimAPI.CalculateLocalInertia2(BSShape.ptr, physMass);
380 BulletSimAPI.SetMassProps2(BSBody.ptr, physMass, localInertia); 380 BulletSimAPI.SetMassProps2(BSBody.ptr, physMass, localInertia);
381 BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr); 381 // center of mass is at the zero of the object
382 BulletSimAPI.SetCenterOfMassByPosRot2(BSBody.ptr, ForcePosition, ForceOrientation);
383 // BulletSimAPI.UpdateInertiaTensor2(BSBody.ptr);
382 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2}", LocalID, physMass, localInertia); 384 DetailLog("{0},BSPrim.UpdateMassProperties,mass={1},localInertia={2}", LocalID, physMass, localInertia);
383 } 385 }
384 } 386 }
@@ -462,9 +464,16 @@ public sealed class BSPrim : BSPhysObject
462 // Called from Scene when doing simulation step so we're in taint processing time. 464 // Called from Scene when doing simulation step so we're in taint processing time.
463 public override void StepVehicle(float timeStep) 465 public override void StepVehicle(float timeStep)
464 { 466 {
465 if (IsPhysical) 467 if (IsPhysical && _vehicle.IsActive)
466 { 468 {
467 _vehicle.Step(timeStep); 469 _vehicle.Step(timeStep);
470 /* // TEST TEST DEBUG DEBUG -- trying to reduce the extra action of Bullet simulation step
471 PhysicsScene.PostTaintObject("BSPrim.StepVehicles", LocalID, delegate()
472 {
473 // This resets the interpolation values and recomputes the tensor variables
474 BulletSimAPI.SetCenterOfMassByPosRot2(BSBody.ptr, ForcePosition, ForceOrientation);
475 });
476 */
468 } 477 }
469 } 478 }
470 479
@@ -502,7 +511,9 @@ public sealed class BSPrim : BSPhysObject
502 } 511 }
503 public override OMV.Vector3 Torque { 512 public override OMV.Vector3 Torque {
504 get { return _torque; } 513 get { return _torque; }
505 set { _torque = value; 514 set {
515 _torque = value;
516 AddAngularForce(_torque, false, false);
506 // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque); 517 // DetailLog("{0},BSPrim.SetTorque,call,torque={1}", LocalID, _torque);
507 } 518 }
508 } 519 }
@@ -831,7 +842,7 @@ public sealed class BSPrim : BSPhysObject
831 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity); 842 // m_log.DebugFormat("{0}: RotationalVelocity={1}", LogHeader, _rotationalVelocity);
832 PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate() 843 PhysicsScene.TaintedObject("BSPrim.setRotationalVelocity", delegate()
833 { 844 {
834 // DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); 845 DetailLog("{0},BSPrim.SetRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity);
835 BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity); 846 BulletSimAPI.SetAngularVelocity2(BSBody.ptr, _rotationalVelocity);
836 }); 847 });
837 } 848 }
@@ -972,14 +983,31 @@ public sealed class BSPrim : BSPhysObject
972 } 983 }
973 m_accumulatedAngularForces.Clear(); 984 m_accumulatedAngularForces.Clear();
974 } 985 }
975 // DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum); 986 DetailLog("{0},BSPrim.AddAngularForce,taint,aForce={1}", LocalID, fSum);
976 if (fSum != OMV.Vector3.Zero) 987 if (fSum != OMV.Vector3.Zero)
988 {
977 BulletSimAPI.ApplyTorque2(BSBody.ptr, fSum); 989 BulletSimAPI.ApplyTorque2(BSBody.ptr, fSum);
990 _torque = fSum;
991 }
978 }; 992 };
979 if (inTaintTime) 993 if (inTaintTime)
980 addAngularForceOperation(); 994 addAngularForceOperation();
981 else 995 else
982 PhysicsScene.TaintedObject("BSPrim.AddForce", addAngularForceOperation); 996 PhysicsScene.TaintedObject("BSPrim.AddAngularForce", addAngularForceOperation);
997 }
998 // A torque impulse.
999 public void ApplyTorqueImpulse(OMV.Vector3 impulse, bool inTaintTime)
1000 {
1001 OMV.Vector3 applyImpulse = impulse;
1002 BSScene.TaintCallback applyTorqueImpulseOperation = delegate()
1003 {
1004 DetailLog("{0},BSPrim.ApplyTorqueImpulse,taint,tImpulse={1}", LocalID, applyImpulse);
1005 BulletSimAPI.ApplyTorqueImpulse2(BSBody.ptr, applyImpulse);
1006 };
1007 if (inTaintTime)
1008 applyTorqueImpulseOperation();
1009 else
1010 PhysicsScene.TaintedObject("BSPrim.ApplyTorqueImpulse", applyTorqueImpulseOperation);
983 } 1011 }
984 public override void SetMomentum(OMV.Vector3 momentum) { 1012 public override void SetMomentum(OMV.Vector3 momentum) {
985 // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum); 1013 // DetailLog("{0},BSPrim.SetMomentum,call,mom={1}", LocalID, momentum);
@@ -1418,8 +1446,9 @@ public sealed class BSPrim : BSPhysObject
1418 1446
1419 PositionSanityCheck(true); 1447 PositionSanityCheck(true);
1420 1448
1421 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 1449 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation;
1422 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity); 1450 DetailLog("{0},BSPrim.UpdateProperties,call,pos={1},orient={2},dir={3},vel={4},rotVel={5}",
1451 LocalID, _position, _orientation, direction, _velocity, _rotationalVelocity);
1423 1452
1424 // BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, BSBody.ptr); // DEBUG DEBUG DEBUG 1453 // BulletSimAPI.DumpRigidBody2(PhysicsScene.World.ptr, BSBody.ptr); // DEBUG DEBUG DEBUG
1425 1454