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.cs37
1 files changed, 31 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 784076d..e76d8a4 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -226,16 +226,37 @@ public class BSCharacter : BSPhysObject
226 bool ret = false; 226 bool ret = false;
227 227
228 // If below the ground, move the avatar up 228 // If below the ground, move the avatar up
229 float terrainHeight = Scene.GetTerrainHeightAtXYZ(_position); 229 float terrainHeight = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position);
230 if (_position.Z < terrainHeight) 230 if (Position.Z < terrainHeight)
231 { 231 {
232 DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},orient={2}", LocalID, _position, _orientation); 232 DetailLog("{0},BSCharacter.PositionAdjustUnderGround,call,pos={1},terrain={2}", LocalID, _position, terrainHeight);
233 _position.Z = terrainHeight + 2.0f; 233 Vector3 newPos = _position;
234 newPos.Z = terrainHeight + 2.0f;
235 _position = newPos;
234 ret = true; 236 ret = true;
235 } 237 }
236 238
237 // TODO: check for out of bounds 239 // TODO: check for out of bounds
240 return ret;
241 }
238 242
243 // A version of the sanity check that also makes sure a new position value is
244 // pushed back to the physics engine. This routine would be used by anyone
245 // who is not already pushing the value.
246 private bool PositionSanityCheck2()
247 {
248 bool ret = false;
249 if (PositionSanityCheck())
250 {
251 // The new position value must be pushed into the physics engine but we can't
252 // just assign to "Position" because of potential call loops.
253 _scene.TaintedObject("BSCharacter.PositionSanityCheck", delegate()
254 {
255 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation);
256 BulletSimAPI.SetObjectTranslation(_scene.WorldID, _localID, _position, _orientation);
257 });
258 ret = true;
259 }
239 return ret; 260 return ret;
240 } 261 }
241 262
@@ -500,9 +521,13 @@ public class BSCharacter : BSPhysObject
500 // 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.
501 // base.RequestPhysicsterseUpdate(); 522 // base.RequestPhysicsterseUpdate();
502 523
503 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 524 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
525 PositionSanityCheck2();
526
527 float heightHere = Scene.TerrainManager.GetTerrainHeightAtXYZ(_position); // just for debug
528 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5},terrain={6}",
504 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity, 529 LocalID, entprop.Position, entprop.Rotation, entprop.Velocity,
505 entprop.Acceleration, entprop.RotationalVelocity); 530 entprop.Acceleration, entprop.RotationalVelocity, heightHere);
506 } 531 }
507 532
508 // Called by the scene when a collision with this object is reported 533 // Called by the scene when a collision with this object is reported