diff options
author | Robert Adams | 2013-01-27 12:48:36 -0800 |
---|---|---|
committer | Robert Adams | 2013-01-27 12:50:07 -0800 |
commit | b546af9ac290951f22e8c8e56798adb176076591 (patch) | |
tree | 23f60e1100732357122ffa073c838d8747609507 /OpenSim/Region | |
parent | BulletSim: reinstate the supression of rotational velocity for vehicles (diff) | |
download | opensim-SC-b546af9ac290951f22e8c8e56798adb176076591.zip opensim-SC-b546af9ac290951f22e8c8e56798adb176076591.tar.gz opensim-SC-b546af9ac290951f22e8c8e56798adb176076591.tar.bz2 opensim-SC-b546af9ac290951f22e8c8e56798adb176076591.tar.xz |
BulletSim: simplify the initialization of some of the parameters.
Disable vertical attraction for vehicles by default (for the moment).
Fix bug where vehicle would go crazy when velocity got above a
certain speed.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 19 | ||||
-rwxr-xr-x | OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | 36 |
2 files changed, 23 insertions, 32 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs index 90482fd..94194b0 100644 --- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |||
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
141 | // in changes by making enablement of debugging flags from INI file. | 141 | // in changes by making enablement of debugging flags from INI file. |
142 | public void SetupVehicleDebugging() | 142 | public void SetupVehicleDebugging() |
143 | { | 143 | { |
144 | enableAngularVerticalAttraction = true; | 144 | enableAngularVerticalAttraction = false; |
145 | enableAngularDeflection = false; | 145 | enableAngularDeflection = false; |
146 | enableAngularBanking = false; | 146 | enableAngularBanking = false; |
147 | if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse) | 147 | if (BSParam.VehicleDebuggingEnabled != ConfigurationParameters.numericFalse) |
@@ -803,7 +803,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
803 | m_knownVelocity = Prim.ForceVelocity; | 803 | m_knownVelocity = Prim.ForceVelocity; |
804 | m_knownHas |= m_knownChangedVelocity; | 804 | m_knownHas |= m_knownChangedVelocity; |
805 | } | 805 | } |
806 | return (Vector3)m_knownVelocity; | 806 | return m_knownVelocity; |
807 | } | 807 | } |
808 | set | 808 | set |
809 | { | 809 | { |
@@ -926,6 +926,8 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
926 | // Called after the simulation step | 926 | // Called after the simulation step |
927 | internal void PostStep(float pTimestep) | 927 | internal void PostStep(float pTimestep) |
928 | { | 928 | { |
929 | if (!IsActive) return; | ||
930 | |||
929 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) | 931 | if (PhysicsScene.VehiclePhysicalLoggingEnabled) |
930 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); | 932 | PhysicsScene.PE.DumpRigidBody(PhysicsScene.World, Prim.PhysBody); |
931 | } | 933 | } |
@@ -961,10 +963,13 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
961 | // ================================================================== | 963 | // ================================================================== |
962 | // Clamp high or low velocities | 964 | // Clamp high or low velocities |
963 | float newVelocityLengthSq = VehicleVelocity.LengthSquared(); | 965 | float newVelocityLengthSq = VehicleVelocity.LengthSquared(); |
964 | if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocity) | 966 | if (newVelocityLengthSq > BSParam.VehicleMaxLinearVelocitySq) |
965 | { | 967 | { |
968 | Vector3 origVelW = VehicleVelocity; // DEBUG DEBUG | ||
966 | VehicleVelocity /= VehicleVelocity.Length(); | 969 | VehicleVelocity /= VehicleVelocity.Length(); |
967 | VehicleVelocity *= BSParam.VehicleMaxLinearVelocity; | 970 | VehicleVelocity *= BSParam.VehicleMaxLinearVelocity; |
971 | VDetailLog("{0}, MoveLinear,clampMax,origVelW={1},lenSq={2},maxVelSq={3},,newVelW={4}", | ||
972 | Prim.LocalID, origVelW, newVelocityLengthSq, BSParam.VehicleMaxLinearVelocitySq, VehicleVelocity); | ||
968 | } | 973 | } |
969 | else if (newVelocityLengthSq < 0.001f) | 974 | else if (newVelocityLengthSq < 0.001f) |
970 | VehicleVelocity = Vector3.Zero; | 975 | VehicleVelocity = Vector3.Zero; |
@@ -1301,6 +1306,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1301 | if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff) | 1306 | if (enableAngularVerticalAttraction && m_verticalAttractionTimescale < m_verticalAttractionCutoff) |
1302 | { | 1307 | { |
1303 | Vector3 vertContributionV = Vector3.Zero; | 1308 | Vector3 vertContributionV = Vector3.Zero; |
1309 | Vector3 origRotVelW = VehicleRotationalVelocity; // DEBUG DEBUG | ||
1304 | 1310 | ||
1305 | // Take a vector pointing up and convert it from world to vehicle relative coords. | 1311 | // Take a vector pointing up and convert it from world to vehicle relative coords. |
1306 | Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; | 1312 | Vector3 verticalError = Vector3.UnitZ * VehicleOrientation; |
@@ -1328,13 +1334,14 @@ namespace OpenSim.Region.Physics.BulletSPlugin | |||
1328 | 1334 | ||
1329 | // 'vertContrbution' is now the necessary angular correction to correct tilt in one second. | 1335 | // 'vertContrbution' is now the necessary angular correction to correct tilt in one second. |
1330 | // Correction happens over a number of seconds. | 1336 | // Correction happens over a number of seconds. |
1331 | Vector3 unscaledContrib = vertContributionV; // DEBUG DEBUG | 1337 | Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG |
1332 | vertContributionV /= m_verticalAttractionTimescale; | 1338 | vertContributionV /= m_verticalAttractionTimescale; |
1333 | 1339 | ||
1334 | VehicleRotationalVelocity += vertContributionV * VehicleOrientation; | 1340 | VehicleRotationalVelocity += vertContributionV * VehicleOrientation; |
1335 | 1341 | ||
1336 | VDetailLog("{0}, MoveAngular,verticalAttraction,,verticalError={1},unscaled={2},eff={3},ts={4},vertAttr={5}", | 1342 | VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}", |
1337 | Prim.LocalID, verticalError, unscaledContrib, m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV); | 1343 | Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV, |
1344 | m_verticalAttractionEfficiency, m_verticalAttractionTimescale, vertContributionV); | ||
1338 | } | 1345 | } |
1339 | } | 1346 | } |
1340 | 1347 | ||
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs index 75eed86..4ece944 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs | |||
@@ -84,32 +84,16 @@ public static class BSParam | |||
84 | 84 | ||
85 | // Vehicle parameters | 85 | // Vehicle parameters |
86 | public static float VehicleMaxLinearVelocity { get; private set; } | 86 | public static float VehicleMaxLinearVelocity { get; private set; } |
87 | public static float VehicleMaxLinearVelocitySq { get; private set; } | ||
87 | public static float VehicleMaxAngularVelocity { get; private set; } | 88 | public static float VehicleMaxAngularVelocity { get; private set; } |
89 | public static float VehicleMaxAngularVelocitySq { get; private set; } | ||
88 | public static float VehicleAngularDamping { get; private set; } | 90 | public static float VehicleAngularDamping { get; private set; } |
89 | public static float VehicleFriction { get; private set; } | 91 | public static float VehicleFriction { get; private set; } |
90 | public static float VehicleRestitution { get; private set; } | 92 | public static float VehicleRestitution { get; private set; } |
91 | public static float VehicleLinearFactor { get; private set; } | 93 | public static float VehicleLinearFactor { get; private set; } |
92 | private static Vector3? vehicleLinearFactorV; | 94 | public static Vector3 VehicleLinearFactorV { get; private set; } |
93 | public static Vector3 VehicleLinearFactorV | ||
94 | { | ||
95 | get | ||
96 | { | ||
97 | if (!vehicleLinearFactorV.HasValue) | ||
98 | vehicleLinearFactorV = new Vector3(VehicleLinearFactor, VehicleLinearFactor, VehicleLinearFactor); | ||
99 | return (Vector3)vehicleLinearFactorV; | ||
100 | } | ||
101 | } | ||
102 | public static float VehicleAngularFactor { get; private set; } | 95 | public static float VehicleAngularFactor { get; private set; } |
103 | private static Vector3? vehicleAngularFactorV; | 96 | public static Vector3 VehicleAngularFactorV { get; private set; } |
104 | public static Vector3 VehicleAngularFactorV | ||
105 | { | ||
106 | get | ||
107 | { | ||
108 | if (!vehicleAngularFactorV.HasValue) | ||
109 | vehicleAngularFactorV = new Vector3(VehicleAngularFactor, VehicleAngularFactor, VehicleAngularFactor); | ||
110 | return (Vector3)vehicleAngularFactorV; | ||
111 | } | ||
112 | } | ||
113 | public static float VehicleGroundGravityFudge { get; private set; } | 97 | public static float VehicleGroundGravityFudge { get; private set; } |
114 | public static float VehicleDebuggingEnabled { get; private set; } | 98 | public static float VehicleDebuggingEnabled { get; private set; } |
115 | 99 | ||
@@ -469,12 +453,12 @@ public static class BSParam | |||
469 | 1000.0f, | 453 | 1000.0f, |
470 | (s,cf,p,v) => { VehicleMaxLinearVelocity = cf.GetFloat(p, v); }, | 454 | (s,cf,p,v) => { VehicleMaxLinearVelocity = cf.GetFloat(p, v); }, |
471 | (s) => { return (float)VehicleMaxLinearVelocity; }, | 455 | (s) => { return (float)VehicleMaxLinearVelocity; }, |
472 | (s,p,l,v) => { VehicleMaxLinearVelocity = v; } ), | 456 | (s,p,l,v) => { VehicleMaxLinearVelocity = v; VehicleMaxLinearVelocitySq = v * v; } ), |
473 | new ParameterDefn("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle", | 457 | new ParameterDefn("VehicleMaxAngularVelocity", "Maximum rotational velocity magnitude that can be assigned to a vehicle", |
474 | 12.0f, | 458 | 12.0f, |
475 | (s,cf,p,v) => { VehicleMaxAngularVelocity = cf.GetFloat(p, v); }, | 459 | (s,cf,p,v) => { VehicleMaxAngularVelocity = cf.GetFloat(p, v); }, |
476 | (s) => { return (float)VehicleMaxAngularVelocity; }, | 460 | (s) => { return (float)VehicleMaxAngularVelocity; }, |
477 | (s,p,l,v) => { VehicleMaxAngularVelocity = v; } ), | 461 | (s,p,l,v) => { VehicleMaxAngularVelocity = v; VehicleMaxAngularVelocitySq = v * v; } ), |
478 | new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)", | 462 | new ParameterDefn("VehicleAngularDamping", "Factor to damp vehicle angular movement per second (0.0 - 1.0)", |
479 | 0.0f, | 463 | 0.0f, |
480 | (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); }, | 464 | (s,cf,p,v) => { VehicleAngularDamping = cf.GetFloat(p, v); }, |
@@ -484,24 +468,24 @@ public static class BSParam | |||
484 | 1.0f, | 468 | 1.0f, |
485 | (s,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); }, | 469 | (s,cf,p,v) => { VehicleLinearFactor = cf.GetFloat(p, v); }, |
486 | (s) => { return VehicleLinearFactor; }, | 470 | (s) => { return VehicleLinearFactor; }, |
487 | (s,p,l,v) => { VehicleLinearFactor = v; } ), | 471 | (s,p,l,v) => { VehicleLinearFactor = v; VehicleLinearFactorV = new Vector3(v, v, v); } ), |
488 | new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)", | 472 | new ParameterDefn("VehicleAngularFactor", "Fraction of physical angular changes applied to vehicle (0.0 - 1.0)", |
489 | 1.0f, | 473 | 1.0f, |
490 | (s,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); }, | 474 | (s,cf,p,v) => { VehicleAngularFactor = cf.GetFloat(p, v); }, |
491 | (s) => { return VehicleAngularFactor; }, | 475 | (s) => { return VehicleAngularFactor; }, |
492 | (s,p,l,v) => { VehicleAngularFactor = v; } ), | 476 | (s,p,l,v) => { VehicleAngularFactor = v; VehicleAngularFactorV = new Vector3(v, v, v); } ), |
493 | new ParameterDefn("VehicleFriction", "Friction of vehicle on the ground (0.0 - 1.0)", | 477 | new ParameterDefn("VehicleFriction", "Friction of vehicle on the ground (0.0 - 1.0)", |
494 | 0.0f, | 478 | 0.0f, |
495 | (s,cf,p,v) => { VehicleFriction = cf.GetFloat(p, v); }, | 479 | (s,cf,p,v) => { VehicleFriction = cf.GetFloat(p, v); }, |
496 | (s) => { return VehicleFriction; }, | 480 | (s) => { return VehicleFriction; }, |
497 | (s,p,l,v) => { VehicleFriction = v; } ), | 481 | (s,p,l,v) => { VehicleFriction = v; } ), |
498 | new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)", | 482 | new ParameterDefn("VehicleRestitution", "Bouncyness factor for vehicles (0.0 - 1.0)", |
499 | 0.2f, | 483 | 0.0f, |
500 | (s,cf,p,v) => { VehicleRestitution = cf.GetFloat(p, v); }, | 484 | (s,cf,p,v) => { VehicleRestitution = cf.GetFloat(p, v); }, |
501 | (s) => { return VehicleRestitution; }, | 485 | (s) => { return VehicleRestitution; }, |
502 | (s,p,l,v) => { VehicleRestitution = v; } ), | 486 | (s,p,l,v) => { VehicleRestitution = v; } ), |
503 | new ParameterDefn("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", | 487 | new ParameterDefn("VehicleGroundGravityFudge", "Factor to multiple gravity if a ground vehicle is probably on the ground (0.0 - 1.0)", |
504 | 1.0f, | 488 | 0.2f, |
505 | (s,cf,p,v) => { VehicleGroundGravityFudge = cf.GetFloat(p, v); }, | 489 | (s,cf,p,v) => { VehicleGroundGravityFudge = cf.GetFloat(p, v); }, |
506 | (s) => { return VehicleGroundGravityFudge; }, | 490 | (s) => { return VehicleGroundGravityFudge; }, |
507 | (s,p,l,v) => { VehicleGroundGravityFudge = v; } ), | 491 | (s,p,l,v) => { VehicleGroundGravityFudge = v; } ), |