aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs29
1 files changed, 13 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index f442ca2..e208d3a 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -205,7 +205,7 @@ public sealed class BSCharacter : BSPhysObject
205 // errors can creap in and the avatar will slowly float off in some direction. 205 // errors can creap in and the avatar will slowly float off in some direction.
206 // So, the problem is that, when an avatar is standing, we cannot tell creaping error 206 // So, the problem is that, when an avatar is standing, we cannot tell creaping error
207 // from real pushing. 207 // from real pushing.
208 // The code below keeps setting the velocity to zero hoping the world will keep pushing. 208 // The code below uses whether the collider is static or moving to decide whether to zero motion.
209 209
210 _velocityMotor.Step(timeStep); 210 _velocityMotor.Step(timeStep);
211 211
@@ -244,6 +244,7 @@ public sealed class BSCharacter : BSPhysObject
244 } 244 }
245 else 245 else
246 { 246 {
247 // Supposed to be moving.
247 OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue; 248 OMV.Vector3 stepVelocity = _velocityMotor.CurrentValue;
248 249
249 if (Friction != BSParam.AvatarFriction) 250 if (Friction != BSParam.AvatarFriction)
@@ -276,8 +277,8 @@ public sealed class BSCharacter : BSPhysObject
276 }); 277 });
277 } 278 }
278 279
279 // Decide of the character is colliding with a low object and compute a force to pop the 280 // Decide if the character is colliding with a low object and compute a force to pop the
280 // avatar up so it has a chance of walking up and over the low object. 281 // avatar up so it can walk up and over the low objects.
281 private OMV.Vector3 WalkUpStairs() 282 private OMV.Vector3 WalkUpStairs()
282 { 283 {
283 OMV.Vector3 ret = OMV.Vector3.Zero; 284 OMV.Vector3 ret = OMV.Vector3.Zero;
@@ -476,17 +477,19 @@ public sealed class BSCharacter : BSPhysObject
476 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition)) 477 if (!PhysicsScene.TerrainManager.IsWithinKnownTerrain(RawPosition))
477 { 478 {
478 // The character is out of the known/simulated area. 479 // The character is out of the known/simulated area.
479 // Upper levels of code will handle the transition to other areas so, for 480 // Force the avatar position to be within known. ScenePresence will use the position
480 // the time, we just ignore the position. 481 // plus the velocity to decide if the avatar is moving out of the region.
481 return ret; 482 RawPosition = PhysicsScene.TerrainManager.ClampPositionIntoKnownTerrain(RawPosition);
483 DetailLog("{0},BSCharacter.PositionSanityCheck,notWithinKnownTerrain,clampedPos={1}", LocalID, RawPosition);
484 return true;
482 } 485 }
483 486
484 // If below the ground, move the avatar up 487 // If below the ground, move the avatar up
485 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 488 float terrainHeight = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
486 if (Position.Z < terrainHeight) 489 if (Position.Z < terrainHeight)
487 { 490 {
488 DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight); 491 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight);
489 _position.Z = terrainHeight + 2.0f; 492 _position.Z = terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters;
490 ret = true; 493 ret = true;
491 } 494 }
492 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 495 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
@@ -806,14 +809,7 @@ public sealed class BSCharacter : BSPhysObject
806 private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) { 809 private void AddForce(OMV.Vector3 force, bool pushforce, bool inTaintTime) {
807 if (force.IsFinite()) 810 if (force.IsFinite())
808 { 811 {
809 float magnitude = force.Length(); 812 OMV.Vector3 addForce = Util.ClampV(force, BSParam.MaxAddForceMagnitude);
810 if (magnitude > BSParam.MaxAddForceMagnitude)
811 {
812 // Force has a limit
813 force = force / magnitude * BSParam.MaxAddForceMagnitude;
814 }
815
816 OMV.Vector3 addForce = force;
817 // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce); 813 // DetailLog("{0},BSCharacter.addForce,call,force={1}", LocalID, addForce);
818 814
819 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate() 815 PhysicsScene.TaintedObject(inTaintTime, "BSCharacter.AddForce", delegate()
@@ -902,6 +898,7 @@ public sealed class BSCharacter : BSPhysObject
902 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. 898 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
903 if (PositionSanityCheck(true)) 899 if (PositionSanityCheck(true))
904 { 900 {
901 DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, _position);
905 entprop.Position = _position; 902 entprop.Position = _position;
906 } 903 }
907 904