diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 4 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 20 | ||||
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSPrim.cs | 47 |
3 files changed, 57 insertions, 14 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index e6933f9..235cefc 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -961,13 +961,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
961 | // ================================================================== | 961 | // ================================================================== |
962 | // Clamp high or low velocities | 962 | // Clamp high or low velocities |
963 | float newVelocityLengthSq = VehicleVelocity.LengthSquared(); | 963 | float newVelocityLengthSq = VehicleVelocity.LengthSquared(); |
964 | if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySq) | 964 | if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySquared) |
965 | { | 965 | { |
966 | Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG | 966 | Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG |
967 | VehicleVelocity /= VehicleVelocity.Length(); | 967 | VehicleVelocity /= VehicleVelocity.Length(); |
968 | VehicleVelocity *= BSParam.VehicleMaxLinearVelocity; | 968 | VehicleVelocity *= BSParam.VehicleMaxLinearVelocity; |
969 | VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}", | 969 | VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}", |
970 | Prim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySq, VehicleVelocity); | 970 | Prim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySquared, VehicleVelocity); |
971 | } | 971 | } |
972 | else if (newVelocityLengthSq < 0.001f) | 972 | else if (newVelocityLengthSq < 0.001f) |
973 | VehicleVelocity = Vector3.Zero; | 973 | VehicleVelocity = Vector3.Zero; |
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index dc57b67..fa58109 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -47,12 +47,16 @@ public static class BSParam | |||
47 | public static float SculptLOD { get; private set; } | 47 | public static float SculptLOD { get; private set; } |
48 | 48 | ||
49 | public static int CrossingFailuresBeforeOutOfBounds { get; private set; } | 49 | public static int CrossingFailuresBeforeOutOfBounds { get; private set; } |
50 | public static float UpdateVelocityChangeThreshold { get; private set; } | ||
50 | 51 | ||
51 | public static float MinimumObjectMass { get; private set; } | 52 | public static float MinimumObjectMass { get; private set; } |
52 | public static float MaximumObjectMass { get; private set; } | 53 | public static float MaximumObjectMass { get; private set; } |
53 | public static float MaxLinearVelocity { get; private set; } | 54 | public static float MaxLinearVelocity { get; private set; } |
55 | public static float MaxLinearVelocitySquared { get; private set; } | ||
54 | public static float MaxAngularVelocity { get; private set; } | 56 | public static float MaxAngularVelocity { get; private set; } |
57 | public static float MaxAngularVelocitySquared { get; private set; } | ||
55 | public static float MaxAddForceMagnitude { get; private set; } | 58 | public static float MaxAddForceMagnitude { get; private set; } |
59 | public static float MaxAddForceMagnitudeSquared { get; private set; } | ||
56 | public static float DensityScaleFactor { get; private set; } | 60 | public static float DensityScaleFactor { get; private set; } |
57 | 61 | ||
58 | public static float LinearDamping { get; private set; } | 62 | public static float LinearDamping { get; private set; } |
@@ -109,7 +113,7 @@ public static class BSParam | |||
109 | 113 | ||
110 | // Vehicle parameters | 114 | // Vehicle parameters |
111 | public static float VehicleMaxLinearVelocity { get; private set; } | 115 | public static float VehicleMaxLinearVelocity { get; private set; } |
112 | public static float VehicleMaxLinearVelocitySq { get; private set; } | 116 | public static float VehicleMaxLinearVelocitySquared { get; private set; } |
113 | public static float VehicleMaxAngularVelocity { get; private set; } | 117 | public static float VehicleMaxAngularVelocity { get; private set; } |
114 | public static float VehicleMaxAngularVelocitySq { get; private set; } | 118 | public static float VehicleMaxAngularVelocitySq { get; private set; } |
115 | public static float VehicleAngularDamping { get; private set; } | 119 | public static float VehicleAngularDamping { get; private set; } |
@@ -265,7 +269,7 @@ public static class BSParam | |||
265 | // The single letter parameters for the delegates are: | 269 | // The single letter parameters for the delegates are: |
266 | // s = BSScene | 270 | // s = BSScene |
267 | // o = BSPhysObject | 271 | // o = BSPhysObject |
268 | // v = value (float) | 272 | // v = value (appropriate type) |
269 | private static ParameterDefnBase[] ParameterDefinitions = | 273 | private static ParameterDefnBase[] ParameterDefinitions = |
270 | { | 274 | { |
271 | new ParameterDefn<bool>("MeshSculptedPrim", "Whether to create meshes for sculpties", | 275 | new ParameterDefn<bool>("MeshSculptedPrim", "Whether to create meshes for sculpties", |
@@ -289,6 +293,10 @@ public static class BSParam | |||
289 | 5, | 293 | 5, |
290 | (s) => { return CrossingFailuresBeforeOutOfBounds; }, | 294 | (s) => { return CrossingFailuresBeforeOutOfBounds; }, |
291 | (s,v) => { CrossingFailuresBeforeOutOfBounds = v; } ), | 295 | (s,v) => { CrossingFailuresBeforeOutOfBounds = v; } ), |
296 | new ParameterDefn<float>("UpdateVelocityChangeThreshold", "Change in updated velocity required before reporting change to simulator", | ||
297 | 0.1f, | ||
298 | (s) => { return UpdateVelocityChangeThreshold; }, | ||
299 | (s,v) => { UpdateVelocityChangeThreshold = v; } ), | ||
292 | 300 | ||
293 | new ParameterDefn<float>("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", | 301 | new ParameterDefn<float>("MeshLevelOfDetail", "Level of detail to render meshes (32, 16, 8 or 4. 32=most detailed)", |
294 | 32f, | 302 | 32f, |
@@ -343,16 +351,16 @@ public static class BSParam | |||
343 | new ParameterDefn<float>("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object", | 351 | new ParameterDefn<float>("MaxLinearVelocity", "Maximum velocity magnitude that can be assigned to an object", |
344 | 1000.0f, | 352 | 1000.0f, |
345 | (s) => { return MaxLinearVelocity; }, | 353 | (s) => { return MaxLinearVelocity; }, |
346 | (s,v) => { MaxLinearVelocity = v; } ), | 354 | (s,v) => { MaxLinearVelocity = v; MaxLinearVelocitySquared = v * v; } ), |
347 | new ParameterDefn<float>("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object", | 355 | new ParameterDefn<float>("MaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to an object", |
348 | 1000.0f, | 356 | 1000.0f, |
349 | (s) => { return MaxAngularVelocity; }, | 357 | (s) => { return MaxAngularVelocity; }, |
350 | (s,v) => { MaxAngularVelocity = v; } ), | 358 | (s,v) => { MaxAngularVelocity = v; MaxAngularVelocitySquared = v * v; } ), |
351 | // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject | 359 | // LL documentation says thie number should be 20f for llApplyImpulse and 200f for llRezObject |
352 | new ParameterDefn<float>("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)", | 360 | new ParameterDefn<float>("MaxAddForceMagnitude", "Maximum force that can be applied by llApplyImpulse (SL says 20f)", |
353 | 20000.0f, | 361 | 20000.0f, |
354 | (s) => { return MaxAddForceMagnitude; }, | 362 | (s) => { return MaxAddForceMagnitude; }, |
355 | (s,v) => { MaxAddForceMagnitude = v; } ), | 363 | (s,v) => { MaxAddForceMagnitude = v; MaxAddForceMagnitudeSquared = v * v; } ), |
356 | // Density is passed around as 100kg/m3. This scales that to 1kg/m3. | 364 | // Density is passed around as 100kg/m3. This scales that to 1kg/m3. |
357 | new ParameterDefn<float>("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)", | 365 | new ParameterDefn<float>("DensityScaleFactor", "Conversion for simulator/viewer density (100kg/m3) to physical density (1kg/m3)", |
358 | 0.01f, | 366 | 0.01f, |
@@ -505,7 +513,7 @@ public static class BSParam | |||
505 | new ParameterDefn<float>("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle", | 513 | new ParameterDefn<float>("VehicleMaxLinearVelocity", "Maximum velocity magnitude that can be assigned to a vehicle", |
506 | 1000.0f, | 514 | 1000.0f, |
507 | (s) => { return (float)VehicleMaxLinearVelocity; }, | 515 | (s) => { return (float)VehicleMaxLinearVelocity; }, |
508 | (s,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySq = v * v; } ), | 516 | (s,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySquared = v * v; } ), |
509 | new ParameterDefn<float>("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle", | 517 | new ParameterDefn<float>("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle", |
510 | 12.0f, | 518 | 12.0f, |
511 | (s) => { return (float)VehicleMaxAngularVelocity; }, | 519 | (s) => { return (float)VehicleMaxAngularVelocity; }, |
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; |