diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs index 9f0d5af..cbc1772 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs | |||
@@ -683,22 +683,31 @@ public sealed class BSCharacter : BSPhysObject | |||
683 | public override void AddForce(OMV.Vector3 force, bool pushforce) { | 683 | public override void AddForce(OMV.Vector3 force, bool pushforce) { |
684 | if (force.IsFinite()) | 684 | if (force.IsFinite()) |
685 | { | 685 | { |
686 | _force.X += force.X; | 686 | float magnitude = force.Length(); |
687 | _force.Y += force.Y; | 687 | if (magnitude > BSParam.MaxAddForceMagnitude) |
688 | _force.Z += force.Z; | 688 | { |
689 | // m_log.DebugFormat("{0}: AddForce. adding={1}, newForce={2}", LogHeader, force, _force); | 689 | // Force has a limit |
690 | force = force / magnitude * BSParam.MaxAddForceMagnitude; | ||
691 | } | ||
692 | |||
693 | OMV.Vector3 addForce = force / PhysicsScene.LastTimeStep; | ||
694 | DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); | ||
695 | |||
690 | PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() | 696 | PhysicsScene.TaintedObject("BSCharacter.AddForce", delegate() |
691 | { | 697 | { |
692 | DetailLog("{0},BSCharacter.setAddForce,taint,addedForce={1}", LocalID, _force); | 698 | // Bullet adds this central force to the total force for this tick |
699 | DetailLog("{0},BSCharacter.addForce,taint,force={1}", LocalID, addForce); | ||
693 | if (PhysBody.HasPhysicalBody) | 700 | if (PhysBody.HasPhysicalBody) |
694 | BulletSimAPI.SetObjectForce2(PhysBody.ptr, _force); | 701 | { |
702 | BulletSimAPI.ApplyCentralForce2(PhysBody.ptr, addForce); | ||
703 | } | ||
695 | }); | 704 | }); |
696 | } | 705 | } |
697 | else | 706 | else |
698 | { | 707 | { |
699 | m_log.ErrorFormat("{0}: Got a NaN force applied to a Character", LogHeader); | 708 | m_log.WarnFormat("{0}: Got a NaN force applied to a character. LocalID={1}", LogHeader, LocalID); |
709 | return; | ||
700 | } | 710 | } |
701 | //m_lastUpdateSent = false; | ||
702 | } | 711 | } |
703 | 712 | ||
704 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { | 713 | public override void AddAngularForce(OMV.Vector3 force, bool pushforce) { |