aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
authorMelanie2012-12-28 08:32:34 +0000
committerMelanie2012-12-28 08:32:34 +0000
commit3ab1bd04031ca0bc1039e4e1d267ea19d0017430 (patch)
tree3f2417f3b96e151642158d29d1982dee2bd850a8 /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
parentMerge branch 'master' into careminster (diff)
parentBulletSim: correct collision mask definition for linkset children. (diff)
downloadopensim-SC_OLD-3ab1bd04031ca0bc1039e4e1d267ea19d0017430.zip
opensim-SC_OLD-3ab1bd04031ca0bc1039e4e1d267ea19d0017430.tar.gz
opensim-SC_OLD-3ab1bd04031ca0bc1039e4e1d267ea19d0017430.tar.bz2
opensim-SC_OLD-3ab1bd04031ca0bc1039e4e1d267ea19d0017430.tar.xz
Merge branch 'master' into careminster
Conflicts: OpenSim/Region/Framework/Scenes/ScenePresence.cs
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs66
1 files changed, 33 insertions, 33 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index bf0545a..3f7b5e1 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -260,7 +260,6 @@ public sealed class BSCharacter : BSPhysObject
260 public override void ZeroMotion(bool inTaintTime) 260 public override void ZeroMotion(bool inTaintTime)
261 { 261 {
262 _velocity = OMV.Vector3.Zero; 262 _velocity = OMV.Vector3.Zero;
263 _velocityMotor.Zero();
264 _acceleration = OMV.Vector3.Zero; 263 _acceleration = OMV.Vector3.Zero;
265 _rotationalVelocity = OMV.Vector3.Zero; 264 _rotationalVelocity = OMV.Vector3.Zero;
266 265
@@ -585,18 +584,6 @@ public sealed class BSCharacter : BSPhysObject
585 get { return _throttleUpdates; } 584 get { return _throttleUpdates; }
586 set { _throttleUpdates = value; } 585 set { _throttleUpdates = value; }
587 } 586 }
588 public override bool IsColliding {
589 get { return (CollidingStep == PhysicsScene.SimulationStep); }
590 set { _isColliding = value; }
591 }
592 public override bool CollidingGround {
593 get { return (CollidingGroundStep == PhysicsScene.SimulationStep); }
594 set { CollidingGround = value; }
595 }
596 public override bool CollidingObj {
597 get { return _collidingObj; }
598 set { _collidingObj = value; }
599 }
600 public override bool FloatOnWater { 587 public override bool FloatOnWater {
601 set { 588 set {
602 _floatOnWater = value; 589 _floatOnWater = value;
@@ -684,22 +671,31 @@ public sealed class BSCharacter : BSPhysObject
684 public override void AddForce(OMV.Vector3 force, bool pushforce) { 671 public override void AddForce(OMV.Vector3 force, bool pushforce) {
685 if (force.IsFinite()) 672 if (force.IsFinite())
686 { 673 {
687 _force.X += force.X; 674 float magnitude = force.Length();
688 _force.Y += force.Y; 675 if (magnitude > BSParam.MaxAddForceMagnitude)
689 _force.Z += force.Z; 676 {
690 // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); 677 // Force has a limit
678 force = force / magnitude * BSParam.MaxAddForceMagnitude;
679 }
680
681 OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep;
682 DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce);
683
691 PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() 684 PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate()
692 { 685 {
693 DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); 686 // Bullet adds this central force to the total force for this tick
687 DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce);
694 if (PhysBody.HasPhysicalBody) 688 if (PhysBody.HasPhysicalBody)
695 BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); 689 {
690 BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce);
691 }
696 }); 692 });
697 } 693 }
698 else 694 else
699 { 695 {
700 m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader); 696 m_log.WarnFormat("{0}: Got a NaN force applied to a character. LocalID={1}", LogHeader, LocalID);
697 return;
701 } 698 }
702 //m_lastUpdateSent = false;
703 } 699 }
704 700
705 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { 701 public override void AddAngularForce(OMV.Vector3 force, bool pushforce) {
@@ -761,22 +757,26 @@ public sealed class BSCharacter : BSPhysObject
761 757
762 OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep); 758 OMV.Vector3 stepVelocity = _velocityMotor.Step(PhysicsScene.LastTimeStep);
763 759
764 // If falling, we keep the world's downward vector no matter what the other axis specify. 760 // Check for cases to turn off the motor.
765 if (!Flying && !IsColliding) 761 if (
766 { 762 // If the walking motor is all done, turn it off
767 stepVelocity.Z = entprop.Velocity.Z; 763 (_velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f) && _velocityMotor.ErrorIsZero) )
768 DetailLog("{0},BSCharacter.UpdateProperties,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
769 }
770
771 // If the user has said stop and we've stopped applying velocity correction,
772 // the motor can be turned off. Set the velocity to zero so the zero motion is sent to the viewer.
773 if (_velocityMotor.TargetValue.ApproxEquals(OMV.Vector3.Zero, 0.01f) && _velocityMotor.ErrorIsZero)
774 { 764 {
775 _velocityMotor.Enabled = false;
776 stepVelocity = OMV.Vector3.Zero;
777 ZeroMotion(true); 765 ZeroMotion(true);
766 stepVelocity = OMV.Vector3.Zero;
767 _velocityMotor.Enabled = false;
778 DetailLog("{0},BSCharacter.UpdateProperties,taint,disableVelocityMotor,m={1}", LocalID, _velocityMotor); 768 DetailLog("{0},BSCharacter.UpdateProperties,taint,disableVelocityMotor,m={1}", LocalID, _velocityMotor);
779 } 769 }
770 else
771 {
772 // If the motor is not being turned off...
773 // If falling, we keep the world's downward vector no matter what the other axis specify.
774 if (!Flying && !IsColliding)
775 {
776 stepVelocity.Z = entprop.Velocity.Z;
777 DetailLog("{0},BSCharacter.UpdateProperties,taint,overrideStepZWithWorldZ,stepVel={1}", LocalID, stepVelocity);
778 }
779 }
780 780
781 _velocity = stepVelocity; 781 _velocity = stepVelocity;
782 entprop.Velocity = _velocity; 782 entprop.Velocity = _velocity;