aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
diff options
context:
space:
mode:
authorRobert Adams2013-07-07 05:46:24 -0700
committerRobert Adams2013-07-07 05:46:24 -0700
commit70d24a654b8eb0257ca927327d51bd0e47f85259 (patch)
treec57c2ff12bd0dfcd38ddf435394f3b5dc78d627e /OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
parentTry to normalize the creatorData of scene object parts with the trailing '/'.... (diff)
downloadopensim-SC-70d24a654b8eb0257ca927327d51bd0e47f85259.zip
opensim-SC-70d24a654b8eb0257ca927327d51bd0e47f85259.tar.gz
opensim-SC-70d24a654b8eb0257ca927327d51bd0e47f85259.tar.bz2
opensim-SC-70d24a654b8eb0257ca927327d51bd0e47f85259.tar.xz
BulletSim: rename position and orientation variables to remove the
inconsistant use of Raw* and _* conventions.
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs78
1 files changed, 33 insertions, 45 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
index 5ef6992..c9e3ca0 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSCharacter.cs
@@ -43,12 +43,10 @@ public sealed class BSCharacter : BSPhysObject
43 private OMV.Vector3 _size; 43 private OMV.Vector3 _size;
44 private bool _grabbed; 44 private bool _grabbed;
45 private bool _selected; 45 private bool _selected;
46 private OMV.Vector3 _position;
47 private float _mass; 46 private float _mass;
48 private float _avatarVolume; 47 private float _avatarVolume;
49 private float _collisionScore; 48 private float _collisionScore;
50 private OMV.Vector3 _acceleration; 49 private OMV.Vector3 _acceleration;
51 private OMV.Quaternion _orientation;
52 private int _physicsActorType; 50 private int _physicsActorType;
53 private bool _isPhysical; 51 private bool _isPhysical;
54 private bool _flying; 52 private bool _flying;
@@ -70,10 +68,10 @@ public sealed class BSCharacter : BSPhysObject
70 : base(parent_scene, localID, avName, "BSCharacter") 68 : base(parent_scene, localID, avName, "BSCharacter")
71 { 69 {
72 _physicsActorType = (int)ActorTypes.Agent; 70 _physicsActorType = (int)ActorTypes.Agent;
73 _position = pos; 71 RawPosition = pos;
74 72
75 _flying = isFlying; 73 _flying = isFlying;
76 _orientation = OMV.Quaternion.Identity; 74 RawOrientation = OMV.Quaternion.Identity;
77 RawVelocity = OMV.Vector3.Zero; 75 RawVelocity = OMV.Vector3.Zero;
78 _buoyancy = ComputeBuoyancyFromFlying(isFlying); 76 _buoyancy = ComputeBuoyancyFromFlying(isFlying);
79 Friction = BSParam.AvatarStandingFriction; 77 Friction = BSParam.AvatarStandingFriction;
@@ -133,7 +131,7 @@ public sealed class BSCharacter : BSPhysObject
133 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody); 131 PhysScene.PE.RemoveObjectFromWorld(PhysScene.World, PhysBody);
134 132
135 ZeroMotion(true); 133 ZeroMotion(true);
136 ForcePosition = _position; 134 ForcePosition = RawPosition;
137 135
138 // Set the velocity 136 // Set the velocity
139 if (m_moveActor != null) 137 if (m_moveActor != null)
@@ -272,38 +270,33 @@ public sealed class BSCharacter : BSPhysObject
272 270
273 public override void LockAngularMotion(OMV.Vector3 axis) { return; } 271 public override void LockAngularMotion(OMV.Vector3 axis) { return; }
274 272
275 public override OMV.Vector3 RawPosition
276 {
277 get { return _position; }
278 set { _position = value; }
279 }
280 public override OMV.Vector3 Position { 273 public override OMV.Vector3 Position {
281 get { 274 get {
282 // Don't refetch the position because this function is called a zillion times 275 // Don't refetch the position because this function is called a zillion times
283 // _position = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID); 276 // RawPosition = PhysicsScene.PE.GetObjectPosition(Scene.World, LocalID);
284 return _position; 277 return RawPosition;
285 } 278 }
286 set { 279 set {
287 _position = value; 280 RawPosition = value;
288 281
289 PhysScene.TaintedObject("BSCharacter.setPosition", delegate() 282 PhysScene.TaintedObject("BSCharacter.setPosition", delegate()
290 { 283 {
291 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 284 DetailLog("{0},BSCharacter.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
292 PositionSanityCheck(); 285 PositionSanityCheck();
293 ForcePosition = _position; 286 ForcePosition = RawPosition;
294 }); 287 });
295 } 288 }
296 } 289 }
297 public override OMV.Vector3 ForcePosition { 290 public override OMV.Vector3 ForcePosition {
298 get { 291 get {
299 _position = PhysScene.PE.GetPosition(PhysBody); 292 RawPosition = PhysScene.PE.GetPosition(PhysBody);
300 return _position; 293 return RawPosition;
301 } 294 }
302 set { 295 set {
303 _position = value; 296 RawPosition = value;
304 if (PhysBody.HasPhysicalBody) 297 if (PhysBody.HasPhysicalBody)
305 { 298 {
306 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 299 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
307 } 300 }
308 } 301 }
309 } 302 }
@@ -331,16 +324,16 @@ public sealed class BSCharacter : BSPhysObject
331 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition); 324 float terrainHeight = PhysScene.TerrainManager.GetTerrainHeightAtXYZ(RawPosition);
332 if (Position.Z < terrainHeight) 325 if (Position.Z < terrainHeight)
333 { 326 {
334 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, _position, terrainHeight); 327 DetailLog("{0},BSCharacter.PositionSanityCheck,adjustForUnderGround,pos={1},terrain={2}", LocalID, RawPosition, terrainHeight);
335 _position.Z = terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters; 328 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, terrainHeight + BSParam.AvatarBelowGroundUpCorrectionMeters);
336 ret = true; 329 ret = true;
337 } 330 }
338 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 331 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
339 { 332 {
340 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); 333 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition);
341 if (Position.Z < waterHeight) 334 if (Position.Z < waterHeight)
342 { 335 {
343 _position.Z = waterHeight; 336 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, waterHeight);
344 ret = true; 337 ret = true;
345 } 338 }
346 } 339 }
@@ -360,8 +353,8 @@ public sealed class BSCharacter : BSPhysObject
360 // just assign to "Position" because of potential call loops. 353 // just assign to "Position" because of potential call loops.
361 PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate() 354 PhysScene.TaintedObject(inTaintTime, "BSCharacter.PositionSanityCheck", delegate()
362 { 355 {
363 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, _position, _orientation); 356 DetailLog("{0},BSCharacter.PositionSanityCheck,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
364 ForcePosition = _position; 357 ForcePosition = RawPosition;
365 }); 358 });
366 ret = true; 359 ret = true;
367 } 360 }
@@ -466,19 +459,14 @@ public sealed class BSCharacter : BSPhysObject
466 get { return _acceleration; } 459 get { return _acceleration; }
467 set { _acceleration = value; } 460 set { _acceleration = value; }
468 } 461 }
469 public override OMV.Quaternion RawOrientation
470 {
471 get { return _orientation; }
472 set { _orientation = value; }
473 }
474 public override OMV.Quaternion Orientation { 462 public override OMV.Quaternion Orientation {
475 get { return _orientation; } 463 get { return RawOrientation; }
476 set { 464 set {
477 // Orientation is set zillions of times when an avatar is walking. It's like 465 // Orientation is set zillions of times when an avatar is walking. It's like
478 // the viewer doesn't trust us. 466 // the viewer doesn't trust us.
479 if (_orientation != value) 467 if (RawOrientation != value)
480 { 468 {
481 _orientation = value; 469 RawOrientation = value;
482 PhysScene.TaintedObject("BSCharacter.setOrientation", delegate() 470 PhysScene.TaintedObject("BSCharacter.setOrientation", delegate()
483 { 471 {
484 // Bullet assumes we know what we are doing when forcing orientation 472 // Bullet assumes we know what we are doing when forcing orientation
@@ -486,10 +474,10 @@ public sealed class BSCharacter : BSPhysObject
486 // This forces rotation to be only around the Z axis and doesn't change any of the other axis. 474 // This forces rotation to be only around the Z axis and doesn't change any of the other axis.
487 // This keeps us from flipping the capsule over which the veiwer does not understand. 475 // This keeps us from flipping the capsule over which the veiwer does not understand.
488 float oRoll, oPitch, oYaw; 476 float oRoll, oPitch, oYaw;
489 _orientation.GetEulerAngles(out oRoll, out oPitch, out oYaw); 477 RawOrientation.GetEulerAngles(out oRoll, out oPitch, out oYaw);
490 OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw); 478 OMV.Quaternion trimmedOrientation = OMV.Quaternion.CreateFromEulers(0f, 0f, oYaw);
491 // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}", 479 // DetailLog("{0},BSCharacter.setOrientation,taint,val={1},valDir={2},conv={3},convDir={4}",
492 // LocalID, _orientation, OMV.Vector3.UnitX * _orientation, 480 // LocalID, RawOrientation, OMV.Vector3.UnitX * RawOrientation,
493 // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation); 481 // trimmedOrientation, OMV.Vector3.UnitX * trimmedOrientation);
494 ForceOrientation = trimmedOrientation; 482 ForceOrientation = trimmedOrientation;
495 }); 483 });
@@ -501,16 +489,16 @@ public sealed class BSCharacter : BSPhysObject
501 { 489 {
502 get 490 get
503 { 491 {
504 _orientation = PhysScene.PE.GetOrientation(PhysBody); 492 RawOrientation = PhysScene.PE.GetOrientation(PhysBody);
505 return _orientation; 493 return RawOrientation;
506 } 494 }
507 set 495 set
508 { 496 {
509 _orientation = value; 497 RawOrientation = value;
510 if (PhysBody.HasPhysicalBody) 498 if (PhysBody.HasPhysicalBody)
511 { 499 {
512 // _position = PhysicsScene.PE.GetPosition(BSBody); 500 // RawPosition = PhysicsScene.PE.GetPosition(BSBody);
513 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 501 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
514 } 502 }
515 } 503 }
516 } 504 }
@@ -723,9 +711,9 @@ public sealed class BSCharacter : BSPhysObject
723 { 711 {
724 // Don't change position if standing on a stationary object. 712 // Don't change position if standing on a stationary object.
725 if (!IsStationary) 713 if (!IsStationary)
726 _position = entprop.Position; 714 RawPosition = entprop.Position;
727 715
728 _orientation = entprop.Rotation; 716 RawOrientation = entprop.Rotation;
729 717
730 // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar 718 // Smooth velocity. OpenSimulator is VERY sensitive to changes in velocity of the avatar
731 // and will send agent updates to the clients if velocity changes by more than 719 // and will send agent updates to the clients if velocity changes by more than
@@ -740,8 +728,8 @@ public sealed class BSCharacter : BSPhysObject
740 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds. 728 // Do some sanity checking for the avatar. Make sure it's above ground and inbounds.
741 if (PositionSanityCheck(true)) 729 if (PositionSanityCheck(true))
742 { 730 {
743 DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, _position); 731 DetailLog("{0},BSCharacter.UpdateProperties,updatePosForSanity,pos={1}", LocalID, RawPosition);
744 entprop.Position = _position; 732 entprop.Position = RawPosition;
745 } 733 }
746 734
747 // remember the current and last set values 735 // remember the current and last set values
@@ -755,7 +743,7 @@ public sealed class BSCharacter : BSPhysObject
755 // base.RequestPhysicsterseUpdate(); 743 // base.RequestPhysicsterseUpdate();
756 744
757 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}", 745 DetailLog("{0},BSCharacter.UpdateProperties,call,pos={1},orient={2},vel={3},accel={4},rotVel={5}",
758 LocalID, _position, _orientation, RawVelocity, _acceleration, _rotationalVelocity); 746 LocalID, RawPosition, RawOrientation, RawVelocity, _acceleration, _rotationalVelocity);
759 } 747 }
760} 748}
761} 749}