aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics/BulletSPlugin/BSPrim.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/BSPrim.cs
parentTry to normalize the creatorData of scene object parts with the trailing '/'.... (diff)
downloadopensim-SC_OLD-70d24a654b8eb0257ca927327d51bd0e47f85259.zip
opensim-SC_OLD-70d24a654b8eb0257ca927327d51bd0e47f85259.tar.gz
opensim-SC_OLD-70d24a654b8eb0257ca927327d51bd0e47f85259.tar.bz2
opensim-SC_OLD-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/BSPrim.cs')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs84
1 files changed, 36 insertions, 48 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
index ce4c3da..d43448e 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs
@@ -51,12 +51,8 @@ public class BSPrim : BSPhysObject
51 private bool _isSelected; 51 private bool _isSelected;
52 private bool _isVolumeDetect; 52 private bool _isVolumeDetect;
53 53
54 // _position is what the simulator thinks the positions of the prim is.
55 private OMV.Vector3 _position;
56
57 private float _mass; // the mass of this object 54 private float _mass; // the mass of this object
58 private OMV.Vector3 _acceleration; 55 private OMV.Vector3 _acceleration;
59 private OMV.Quaternion _orientation;
60 private int _physicsActorType; 56 private int _physicsActorType;
61 private bool _isPhysical; 57 private bool _isPhysical;
62 private bool _flying; 58 private bool _flying;
@@ -88,10 +84,10 @@ public class BSPrim : BSPhysObject
88 { 84 {
89 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID); 85 // m_log.DebugFormat("{0}: BSPrim creation of {1}, id={2}", LogHeader, primName, localID);
90 _physicsActorType = (int)ActorTypes.Prim; 86 _physicsActorType = (int)ActorTypes.Prim;
91 _position = pos; 87 RawPosition = pos;
92 _size = size; 88 _size = size;
93 Scale = size; // prims are the size the user wants them to be (different for BSCharactes). 89 Scale = size; // prims are the size the user wants them to be (different for BSCharactes).
94 _orientation = rotation; 90 RawOrientation = rotation;
95 _buoyancy = 0f; 91 _buoyancy = 0f;
96 RawVelocity = OMV.Vector3.Zero; 92 RawVelocity = OMV.Vector3.Zero;
97 _rotationalVelocity = OMV.Vector3.Zero; 93 _rotationalVelocity = OMV.Vector3.Zero;
@@ -270,46 +266,42 @@ public class BSPrim : BSPhysObject
270 return; 266 return;
271 } 267 }
272 268
273 public override OMV.Vector3 RawPosition
274 {
275 get { return _position; }
276 set { _position = value; }
277 }
278 public override OMV.Vector3 Position { 269 public override OMV.Vector3 Position {
279 get { 270 get {
280 // don't do the GetObjectPosition for root elements because this function is called a zillion times. 271 // don't do the GetObjectPosition for root elements because this function is called a zillion times.
281 // _position = ForcePosition; 272 // RawPosition = ForcePosition;
282 return _position; 273 return RawPosition;
283 } 274 }
284 set { 275 set {
285 // If the position must be forced into the physics engine, use ForcePosition. 276 // If the position must be forced into the physics engine, use ForcePosition.
286 // All positions are given in world positions. 277 // All positions are given in world positions.
287 if (_position == value) 278 if (RawPosition == value)
288 { 279 {
289 DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, _position, _orientation); 280 DetailLog("{0},BSPrim.setPosition,call,positionNotChanging,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
290 return; 281 return;
291 } 282 }
292 _position = value; 283 RawPosition = value;
293 PositionSanityCheck(false); 284 PositionSanityCheck(false);
294 285
295 PhysScene.TaintedObject("BSPrim.setPosition", delegate() 286 PhysScene.TaintedObject("BSPrim.setPosition", delegate()
296 { 287 {
297 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, _position, _orientation); 288 DetailLog("{0},BSPrim.SetPosition,taint,pos={1},orient={2}", LocalID, RawPosition, RawOrientation);
298 ForcePosition = _position; 289 ForcePosition = RawPosition;
299 }); 290 });
300 } 291 }
301 } 292 }
302 293
294 // NOTE: overloaded by BSPrimDisplaced to handle offset for center-of-gravity.
303 public override OMV.Vector3 ForcePosition { 295 public override OMV.Vector3 ForcePosition {
304 get { 296 get {
305 _position = PhysScene.PE.GetPosition(PhysBody); 297 RawPosition = PhysScene.PE.GetPosition(PhysBody);
306 return _position; 298 return RawPosition;
307 } 299 }
308 set { 300 set {
309 _position = value; 301 RawPosition = value;
310 if (PhysBody.HasPhysicalBody) 302 if (PhysBody.HasPhysicalBody)
311 { 303 {
312 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 304 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
313 ActivateIfPhysical(false); 305 ActivateIfPhysical(false);
314 } 306 }
315 } 307 }
@@ -343,10 +335,10 @@ public class BSPrim : BSPhysObject
343 float targetHeight = terrainHeight + (Size.Z / 2f); 335 float targetHeight = terrainHeight + (Size.Z / 2f);
344 // If the object is below ground it just has to be moved up because pushing will 336 // If the object is below ground it just has to be moved up because pushing will
345 // not get it through the terrain 337 // not get it through the terrain
346 _position.Z = targetHeight; 338 RawPosition = new OMV.Vector3(RawPosition.X, RawPosition.Y, targetHeight);
347 if (inTaintTime) 339 if (inTaintTime)
348 { 340 {
349 ForcePosition = _position; 341 ForcePosition = RawPosition;
350 } 342 }
351 // If we are throwing the object around, zero its other forces 343 // If we are throwing the object around, zero its other forces
352 ZeroMotion(inTaintTime); 344 ZeroMotion(inTaintTime);
@@ -355,7 +347,7 @@ public class BSPrim : BSPhysObject
355 347
356 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0) 348 if ((CurrentCollisionFlags & CollisionFlags.BS_FLOATS_ON_WATER) != 0)
357 { 349 {
358 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(_position); 350 float waterHeight = PhysScene.TerrainManager.GetWaterLevelAtXYZ(RawPosition);
359 // TODO: a floating motor so object will bob in the water 351 // TODO: a floating motor so object will bob in the water
360 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f) 352 if (Math.Abs(RawPosition.Z - waterHeight) > 0.1f)
361 { 353 {
@@ -364,7 +356,7 @@ public class BSPrim : BSPhysObject
364 356
365 // Apply upforce and overcome gravity. 357 // Apply upforce and overcome gravity.
366 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity; 358 OMV.Vector3 correctionForce = upForce - PhysScene.DefaultGravity;
367 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, _position, upForce, correctionForce); 359 DetailLog("{0},BSPrim.PositionSanityCheck,applyForce,pos={1},upForce={2},correctionForce={3}", LocalID, RawPosition, upForce, correctionForce);
368 AddForce(correctionForce, false, inTaintTime); 360 AddForce(correctionForce, false, inTaintTime);
369 ret = true; 361 ret = true;
370 } 362 }
@@ -383,11 +375,11 @@ public class BSPrim : BSPhysObject
383 uint wayOutThere = Constants.RegionSize * Constants.RegionSize; 375 uint wayOutThere = Constants.RegionSize * Constants.RegionSize;
384 // There have been instances of objects getting thrown way out of bounds and crashing 376 // There have been instances of objects getting thrown way out of bounds and crashing
385 // the border crossing code. 377 // the border crossing code.
386 if ( _position.X < -Constants.RegionSize || _position.X > wayOutThere 378 if ( RawPosition.X < -Constants.RegionSize || RawPosition.X > wayOutThere
387 || _position.Y < -Constants.RegionSize || _position.Y > wayOutThere 379 || RawPosition.Y < -Constants.RegionSize || RawPosition.Y > wayOutThere
388 || _position.Z < -Constants.RegionSize || _position.Z > wayOutThere) 380 || RawPosition.Z < -Constants.RegionSize || RawPosition.Z > wayOutThere)
389 { 381 {
390 _position = new OMV.Vector3(10, 10, 50); 382 RawPosition = new OMV.Vector3(10, 10, 50);
391 ZeroMotion(inTaintTime); 383 ZeroMotion(inTaintTime);
392 ret = true; 384 ret = true;
393 } 385 }
@@ -713,23 +705,19 @@ public class BSPrim : BSPhysObject
713 get { return _acceleration; } 705 get { return _acceleration; }
714 set { _acceleration = value; } 706 set { _acceleration = value; }
715 } 707 }
716 public override OMV.Quaternion RawOrientation 708
717 {
718 get { return _orientation; }
719 set { _orientation = value; }
720 }
721 public override OMV.Quaternion Orientation { 709 public override OMV.Quaternion Orientation {
722 get { 710 get {
723 return _orientation; 711 return RawOrientation;
724 } 712 }
725 set { 713 set {
726 if (_orientation == value) 714 if (RawOrientation == value)
727 return; 715 return;
728 _orientation = value; 716 RawOrientation = value;
729 717
730 PhysScene.TaintedObject("BSPrim.setOrientation", delegate() 718 PhysScene.TaintedObject("BSPrim.setOrientation", delegate()
731 { 719 {
732 ForceOrientation = _orientation; 720 ForceOrientation = RawOrientation;
733 }); 721 });
734 } 722 }
735 } 723 }
@@ -738,14 +726,14 @@ public class BSPrim : BSPhysObject
738 { 726 {
739 get 727 get
740 { 728 {
741 _orientation = PhysScene.PE.GetOrientation(PhysBody); 729 RawOrientation = PhysScene.PE.GetOrientation(PhysBody);
742 return _orientation; 730 return RawOrientation;
743 } 731 }
744 set 732 set
745 { 733 {
746 _orientation = value; 734 RawOrientation = value;
747 if (PhysBody.HasPhysicalBody) 735 if (PhysBody.HasPhysicalBody)
748 PhysScene.PE.SetTranslation(PhysBody, _position, _orientation); 736 PhysScene.PE.SetTranslation(PhysBody, RawPosition, RawOrientation);
749 } 737 }
750 } 738 }
751 public override int PhysicsActorType { 739 public override int PhysicsActorType {
@@ -889,7 +877,7 @@ public class BSPrim : BSPhysObject
889 // PhysicsScene.PE.ClearAllForces(BSBody); 877 // PhysicsScene.PE.ClearAllForces(BSBody);
890 878
891 // For good measure, make sure the transform is set through to the motion state 879 // For good measure, make sure the transform is set through to the motion state
892 ForcePosition = _position; 880 ForcePosition = RawPosition;
893 ForceVelocity = RawVelocity; 881 ForceVelocity = RawVelocity;
894 ForceRotationalVelocity = _rotationalVelocity; 882 ForceRotationalVelocity = _rotationalVelocity;
895 883
@@ -1543,8 +1531,8 @@ public class BSPrim : BSPhysObject
1543 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG 1531 // DetailLog("{0},BSPrim.UpdateProperties,entry,entprop={1}", LocalID, entprop); // DEBUG DEBUG
1544 1532
1545 // Assign directly to the local variables so the normal set actions do not happen 1533 // Assign directly to the local variables so the normal set actions do not happen
1546 _position = entprop.Position; 1534 RawPosition = entprop.Position;
1547 _orientation = entprop.Rotation; 1535 RawOrientation = entprop.Rotation;
1548 // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be 1536 // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be
1549 // very sensitive to velocity changes. 1537 // very sensitive to velocity changes.
1550 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold)) 1538 if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(RawVelocity, BSParam.UpdateVelocityChangeThreshold))
@@ -1557,13 +1545,13 @@ public class BSPrim : BSPhysObject
1557 // The sanity check can change the velocity and/or position. 1545 // The sanity check can change the velocity and/or position.
1558 if (PositionSanityCheck(true /* inTaintTime */ )) 1546 if (PositionSanityCheck(true /* inTaintTime */ ))
1559 { 1547 {
1560 entprop.Position = _position; 1548 entprop.Position = RawPosition;
1561 entprop.Velocity = RawVelocity; 1549 entprop.Velocity = RawVelocity;
1562 entprop.RotationalVelocity = _rotationalVelocity; 1550 entprop.RotationalVelocity = _rotationalVelocity;
1563 entprop.Acceleration = _acceleration; 1551 entprop.Acceleration = _acceleration;
1564 } 1552 }
1565 1553
1566 OMV.Vector3 direction = OMV.Vector3.UnitX * _orientation; // DEBUG DEBUG DEBUG 1554 OMV.Vector3 direction = OMV.Vector3.UnitX * RawOrientation; // DEBUG DEBUG DEBUG
1567 DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction); 1555 DetailLog("{0},BSPrim.UpdateProperties,call,entProp={1},dir={2}", LocalID, entprop, direction);
1568 1556
1569 // remember the current and last set values 1557 // remember the current and last set values