aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs41
1 files changed, 31 insertions, 10 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index b88ec3c..5cf8953 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -234,6 +234,15 @@ public class BSCharacter : BSPhysObject
234 _position.Z = terrainHeight + 2.0f; 234 _position.Z = terrainHeight + 2.0f;
235 ret = true; 235 ret = true;
236 } 236 }
237 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) == 0)
238 {
239 float waterHeight = PhysicsScene.GetWaterLevelAtXYZ(_position);
240 if (Position.Z < waterHeight)
241 {
242 _position.Z = waterHeight;
243 ret = true;
244 }
245 }
237 246
238 // TODO: check for out of bounds 247 // TODO: check for out of bounds
239 return ret; 248 return ret;
@@ -242,18 +251,22 @@ public class BSCharacter : BSPhysObject
242 // A version of the sanity check that also makes sure a new position value is 251 // A version of the sanity check that also makes sure a new position value is
243 // pushed back to the physics engine. This routine would be used by anyone 252 // pushed back to the physics engine. This routine would be used by anyone
244 // who is not already pushing the value. 253 // who is not already pushing the value.
245 private bool PositionSanityCheck2() 254 private bool PositionSanityCheck2(bool atTaintTime)
246 { 255 {
247 bool ret = false; 256 bool ret = false;
248 if (PositionSanityCheck()) 257 if (PositionSanityCheck())
249 { 258 {
250 // The new position value must be pushed into the physics engine but we can't 259 // The new position value must be pushed into the physics engine but we can't
251 // just assign to "Position" because of potential call loops. 260 // just assign to "Position" because of potential call loops.
252 PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", delegate() 261 BSScene.TaintCallback sanityOperation = delegate()
253 { 262 {
254 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 263 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
255 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation); 264 BulletSimAPI.SetObjectTranslation(PhysicsScene.WorldID, LocalID, _position, _orientation);
256 }); 265 };
266 if (atTaintTime)
267 sanityOperation();
268 else
269 PhysicsScene.TaintedObject("BSCharacter.PositionSanityCheck", sanityOperation);
257 ret = true; 270 ret = true;
258 } 271 }
259 return ret; 272 return ret;
@@ -378,7 +391,16 @@ public class BSCharacter : BSPhysObject
378 set { _collidingObj = value; } 391 set { _collidingObj = value; }
379 } 392 }
380 public override bool FloatOnWater { 393 public override bool FloatOnWater {
381 set { _floatOnWater = value; } 394 set {
395 _floatOnWater = value;
396 PhysicsScene.TaintedObject("BSCharacter.setFloatOnWater", delegate()
397 {
398 if (_floatOnWater)
399 CurrentCollisionFlags = BulletSimAPI.AddToCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
400 else
401 CurrentCollisionFlags = BulletSimAPI.RemoveFromCollisionFlags2(BSBody.ptr, CollisionFlags.BS_FLOATS_ON_WATER);
402 });
403 }
382 } 404 }
383 public override OMV.Vector3 RotationalVelocity { 405 public override OMV.Vector3 RotationalVelocity {
384 get { return _rotationalVelocity; } 406 get { return _rotationalVelocity; }
@@ -493,15 +515,14 @@ public class BSCharacter : BSPhysObject
493 _velocity = entprop.Velocity; 515 _velocity = entprop.Velocity;
494 _acceleration = entprop.Acceleration; 516 _acceleration = entprop.Acceleration;
495 _rotationalVelocity = entprop.RotationalVelocity; 517 _rotationalVelocity = entprop.RotationalVelocity;
518 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
519 PositionSanityCheck2(true);
520
496 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop. 521 // Avatars don't report their changes the usual way. Changes are checked for in the heartbeat loop.
497 // base.RequestPhysicsterseUpdate(); 522 // base.RequestPhysicsterseUpdate();
498 523
499 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. 524 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
500 PositionSanityCheck2(); 525 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity);
501
502 float heightHere = PhysicsScene.TerrainManager.GetTerrainHeightAtXYZ(_position); // only for debug
503 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5},terrain={6}",
504 LocalID, _position, _orientation, _velocity, _acceleration, _rotationalVelocity, heightHere);
505 } 526 }
506} 527}
507} 528}