aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authordan miller2007-09-13 21:53:13 +0000
committerdan miller2007-09-13 21:53:13 +0000
commitb31fc4980f95710cd93384f434b1a0655c30a2fd (patch)
tree8ef0b1eeebeb2733347e1ee4ceb4a13575f88248
parentAdded CLI "debug packet 0..255" to enable the in/out packet dumps with variou... (diff)
downloadopensim-SC-b31fc4980f95710cd93384f434b1a0655c30a2fd.zip
opensim-SC-b31fc4980f95710cd93384f434b1a0655c30a2fd.tar.gz
opensim-SC-b31fc4980f95710cd93384f434b1a0655c30a2fd.tar.bz2
opensim-SC-b31fc4980f95710cd93384f434b1a0655c30a2fd.tar.xz
ODE: no more slippin' & slidin'
-rw-r--r--OpenSim/Region/Physics/OdePlugin/OdePlugin.cs28
1 files changed, 24 insertions, 4 deletions
diff --git a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
index bfbd880..a6834d4 100644
--- a/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
+++ b/OpenSim/Region/Physics/OdePlugin/OdePlugin.cs
@@ -272,6 +272,8 @@ namespace OpenSim.Region.Physics.OdePlugin
272 public class OdeCharacter : PhysicsActor 272 public class OdeCharacter : PhysicsActor
273 { 273 {
274 private PhysicsVector _position; 274 private PhysicsVector _position;
275 private d.Vector3 _zeroPosition;
276 private bool _zeroFlag=false;
275 private PhysicsVector _velocity; 277 private PhysicsVector _velocity;
276 private PhysicsVector _acceleration; 278 private PhysicsVector _acceleration;
277 private bool flying = false; 279 private bool flying = false;
@@ -402,11 +404,29 @@ namespace OpenSim.Region.Physics.OdePlugin
402 // no lock; for now it's only called from within Simulate() 404 // no lock; for now it's only called from within Simulate()
403 PhysicsVector vec = new PhysicsVector(); 405 PhysicsVector vec = new PhysicsVector();
404 d.Vector3 vel = d.BodyGetLinearVel(BoundingCapsule); 406 d.Vector3 vel = d.BodyGetLinearVel(BoundingCapsule);
405 vec.X = (vel.X - this._velocity.X) * -75000.0f; 407
406 vec.Y = (vel.Y - this._velocity.Y) * -75000.0f; 408 // if velocity is zero, use position control; otherwise, velocity control
407 if (flying) 409 if (_velocity.X == 0.0f & _velocity.Y == 0.0f & _velocity.Z == 0.0f & !flying)
408 { 410 {
409 vec.Z = (vel.Z - this._velocity.Z) * -75000.0f; 411 // keep track of where we stopped. No more slippin' & slidin'
412 if (!_zeroFlag)
413 {
414 _zeroFlag = true;
415 _zeroPosition = d.BodyGetPosition(BoundingCapsule);
416 }
417 d.Vector3 pos = d.BodyGetPosition(BoundingCapsule);
418 vec.X = (_velocity.X - vel.X) * 75000.0f + (_zeroPosition.X - pos.X) * 120000.0f;
419 vec.Y = (_velocity.Y - vel.Y) * 75000.0f + (_zeroPosition.Y - pos.Y) * 120000.0f;
420 }
421 else
422 {
423 _zeroFlag = false;
424 vec.X = (_velocity.X - vel.X) * 75000.0f;
425 vec.Y = (_velocity.Y - vel.Y) * 75000.0f;
426 if (flying)
427 {
428 vec.Z = (_velocity.Z - vel.Z) * 75000.0f;
429 }
410 } 430 }
411 d.BodyAddForce(this.BoundingCapsule, vec.X, vec.Y, vec.Z); 431 d.BodyAddForce(this.BoundingCapsule, vec.X, vec.Y, vec.Z);
412 } 432 }