diff options
Diffstat (limited to 'OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 47 |
1 files changed, 41 insertions, 6 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs index 8f660c4..a465613 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | |||
@@ -108,6 +108,9 @@ public class BSPrim : BSPhysObject | |||
108 | // do the actual object creation at taint time | 108 | // do the actual object creation at taint time |
109 | PhysicsScene.TaintedObject("BSPrim.create", delegate() | 109 | PhysicsScene.TaintedObject("BSPrim.create", delegate() |
110 | { | 110 | { |
111 | // Make sure the object is being created with some sanity. | ||
112 | ExtremeSanityCheck(true /* inTaintTime */); | ||
113 | |||
111 | CreateGeomAndObject(true); | 114 | CreateGeomAndObject(true); |
112 | 115 | ||
113 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); | 116 | CurrentCollisionFlags = PhysicsScene.PE.GetCollisionFlags(PhysBody); |
@@ -450,6 +453,38 @@ public class BSPrim : BSPhysObject | |||
450 | return ret; | 453 | return ret; |
451 | } | 454 | } |
452 | 455 | ||
456 | // Occasionally things will fly off and really get lost. | ||
457 | // Find the wanderers and bring them back. | ||
458 | // Return 'true' if some parameter need some sanity. | ||
459 | private bool ExtremeSanityCheck(bool inTaintTime) | ||
460 | { | ||
461 | bool ret = false; | ||
462 | |||
463 | uint wayOutThere = Constants.RegionSize * Constants.RegionSize; | ||
464 | // There have been instances of objects getting thrown way out of bounds and crashing | ||
465 | // the border crossing code. | ||
466 | if ( _position.X < -Constants.RegionSize || _position.X > wayOutThere | ||
467 | || _position.Y < -Constants.RegionSize || _position.Y > wayOutThere | ||
468 | || _position.Z < -Constants.RegionSize || _position.Z > wayOutThere) | ||
469 | { | ||
470 | _position = new OMV.Vector3(10, 10, 50); | ||
471 | ZeroMotion(inTaintTime); | ||
472 | ret = true; | ||
473 | } | ||
474 | if (_velocity.LengthSquared() > BSParam.MaxLinearVelocity) | ||
475 | { | ||
476 | _velocity = Util.ClampV(_velocity, BSParam.MaxLinearVelocity); | ||
477 | ret = true; | ||
478 | } | ||
479 | if (_rotationalVelocity.LengthSquared() > BSParam.MaxAngularVelocitySquared) | ||
480 | { | ||
481 | _rotationalVelocity = Util.ClampV(_rotationalVelocity, BSParam.MaxAngularVelocity); | ||
482 | ret = true; | ||
483 | } | ||
484 | |||
485 | return ret; | ||
486 | } | ||
487 | |||
453 | // Return the effective mass of the object. | 488 | // Return the effective mass of the object. |
454 | // The definition of this call is to return the mass of the prim. | 489 | // The definition of this call is to return the mass of the prim. |
455 | // If the simulator cares about the mass of the linkset, it will sum it itself. | 490 | // If the simulator cares about the mass of the linkset, it will sum it itself. |
@@ -585,12 +620,12 @@ public class BSPrim : BSPhysObject | |||
585 | if (VehicleController.Type == Vehicle.TYPE_NONE) | 620 | if (VehicleController.Type == Vehicle.TYPE_NONE) |
586 | { | 621 | { |
587 | UnRegisterPreStepAction("BSPrim.Vehicle", LocalID); | 622 | UnRegisterPreStepAction("BSPrim.Vehicle", LocalID); |
588 | PhysicsScene.AfterStep -= VehicleController.PostStep; | 623 | UnRegisterPostStepAction("BSPrim.Vehicle", LocalID); |
589 | } | 624 | } |
590 | else | 625 | else |
591 | { | 626 | { |
592 | RegisterPreStepAction("BSPrim.Vehicle", LocalID, VehicleController.Step); | 627 | RegisterPreStepAction("BSPrim.Vehicle", LocalID, VehicleController.Step); |
593 | PhysicsScene.AfterStep += VehicleController.PostStep; | 628 | RegisterPostStepAction("BSPrim.Vehicle", LocalID, VehicleController.PostStep); |
594 | } | 629 | } |
595 | }); | 630 | }); |
596 | } | 631 | } |
@@ -732,7 +767,7 @@ public class BSPrim : BSPhysObject | |||
732 | set { | 767 | set { |
733 | PhysicsScene.AssertInTaintTime("BSPrim.ForceVelocity"); | 768 | PhysicsScene.AssertInTaintTime("BSPrim.ForceVelocity"); |
734 | 769 | ||
735 | _velocity = value; | 770 | _velocity = Util.ClampV(value, BSParam.MaxLinearVelocity); |
736 | if (PhysBody.HasPhysicalBody) | 771 | if (PhysBody.HasPhysicalBody) |
737 | { | 772 | { |
738 | DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, _velocity); | 773 | DetailLog("{0},BSPrim.ForceVelocity,taint,vel={1}", LocalID, _velocity); |
@@ -1098,7 +1133,7 @@ public class BSPrim : BSPhysObject | |||
1098 | return _rotationalVelocity; | 1133 | return _rotationalVelocity; |
1099 | } | 1134 | } |
1100 | set { | 1135 | set { |
1101 | _rotationalVelocity = value; | 1136 | _rotationalVelocity = Util.ClampV(value, BSParam.MaxAngularVelocity); |
1102 | if (PhysBody.HasPhysicalBody) | 1137 | if (PhysBody.HasPhysicalBody) |
1103 | { | 1138 | { |
1104 | DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); | 1139 | DetailLog("{0},BSPrim.ForceRotationalVel,taint,rotvel={1}", LocalID, _rotationalVelocity); |
@@ -1230,6 +1265,7 @@ public class BSPrim : BSPhysObject | |||
1230 | 1265 | ||
1231 | RegisterPreStepAction("BSPrim.Hover", LocalID, delegate(float timeStep) | 1266 | RegisterPreStepAction("BSPrim.Hover", LocalID, delegate(float timeStep) |
1232 | { | 1267 | { |
1268 | // Don't do hovering while the object is selected. | ||
1233 | if (!IsPhysicallyActive) | 1269 | if (!IsPhysicallyActive) |
1234 | return; | 1270 | return; |
1235 | 1271 | ||
@@ -1737,10 +1773,9 @@ public class BSPrim : BSPhysObject | |||
1737 | // Assign directly to the local variables so the normal set actions do not happen | 1773 | // Assign directly to the local variables so the normal set actions do not happen |
1738 | _position = entprop.Position; | 1774 | _position = entprop.Position; |
1739 | _orientation = entprop.Rotation; | 1775 | _orientation = entprop.Rotation; |
1740 | // _velocity = entprop.Velocity; | ||
1741 | // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be | 1776 | // DEBUG DEBUG DEBUG -- smooth velocity changes a bit. The simulator seems to be |
1742 | // very sensitive to velocity changes. | 1777 | // very sensitive to velocity changes. |
1743 | if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(_velocity, 0.1f)) | 1778 | if (entprop.Velocity == OMV.Vector3.Zero || !entprop.Velocity.ApproxEquals(_velocity, BSParam.UpdateVelocityChangeThreshold)) |
1744 | _velocity = entprop.Velocity; | 1779 | _velocity = entprop.Velocity; |
1745 | _acceleration = entprop.Acceleration; | 1780 | _acceleration = entprop.Acceleration; |
1746 | _rotationalVelocity = entprop.RotationalVelocity; | 1781 | _rotationalVelocity = entprop.RotationalVelocity; |