aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Physics
diff options
context:
space:
mode:
authorRobert Adams2013-07-09 09:33:46 -0700
committerRobert Adams2013-07-09 09:37:42 -0700
commit2c761cef192670a6f54fe10bb5b5894b5371ea7c (patch)
tree223c6582ef8d27db7465d351492399c110318781 /OpenSim/Region/Physics
parentremove some cruft and trigger a rebuild (diff)
downloadopensim-SC_OLD-2c761cef192670a6f54fe10bb5b5894b5371ea7c.zip
opensim-SC_OLD-2c761cef192670a6f54fe10bb5b5894b5371ea7c.tar.gz
opensim-SC_OLD-2c761cef192670a6f54fe10bb5b5894b5371ea7c.tar.bz2
opensim-SC_OLD-2c761cef192670a6f54fe10bb5b5894b5371ea7c.tar.xz
BulletSim: add parameter to optionally disable vehicle linear deflection.
Add parameter to not apply vehicle linear deflection Z forces if vehicle is not colliding. This defaults to 'true' so vehicles will fall even if there is some linear deflection to apply.
Diffstat (limited to 'OpenSim/Region/Physics')
-rw-r--r--OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs42
-rwxr-xr-xOpenSim/Region/Physics/BulletSPlugin/BSParam.cs8
2 files changed, 34 insertions, 16 deletions
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
index a5f2e98..0204967 100644
--- a/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs
@@ -905,6 +905,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
905 return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation)); 905 return VehicleVelocity * Quaternion.Inverse(Quaternion.Normalize(VehicleOrientation));
906 } 906 }
907 } 907 }
908
908 private float VehicleForwardSpeed 909 private float VehicleForwardSpeed
909 { 910 {
910 get 911 get
@@ -1040,26 +1041,37 @@ namespace OpenSim.Region.Physics.BulletSPlugin
1040 Vector3 linearDeflectionV = Vector3.Zero; 1041 Vector3 linearDeflectionV = Vector3.Zero;
1041 Vector3 velocityV = VehicleForwardVelocity; 1042 Vector3 velocityV = VehicleForwardVelocity;
1042 1043
1043 // Velocity in Y and Z dimensions is movement to the side or turning. 1044 if (BSParam.VehicleEnableLinearDeflection)
1044 // Compute deflection factor from the to the side and rotational velocity 1045 {
1045 linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y); 1046 // Velocity in Y and Z dimensions is movement to the side or turning.
1046 linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z); 1047 // Compute deflection factor from the to the side and rotational velocity
1048 linearDeflectionV.Y = SortedClampInRange(0, (velocityV.Y * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Y);
1049 linearDeflectionV.Z = SortedClampInRange(0, (velocityV.Z * m_linearDeflectionEfficiency) / m_linearDeflectionTimescale, velocityV.Z);
1047 1050
1048 // Velocity to the side and around is corrected and moved into the forward direction 1051 // Velocity to the side and around is corrected and moved into the forward direction
1049 linearDeflectionV.X += Math.Abs(linearDeflectionV.Y); 1052 linearDeflectionV.X += Math.Abs(linearDeflectionV.Y);
1050 linearDeflectionV.X += Math.Abs(linearDeflectionV.Z); 1053 linearDeflectionV.X += Math.Abs(linearDeflectionV.Z);
1051 1054
1052 // Scale the deflection to the fractional simulation time 1055 // Scale the deflection to the fractional simulation time
1053 linearDeflectionV *= pTimestep; 1056 linearDeflectionV *= pTimestep;
1054 1057
1055 // Subtract the sideways and rotational velocity deflection factors while adding the correction forward 1058 // Subtract the sideways and rotational velocity deflection factors while adding the correction forward
1056 linearDeflectionV *= new Vector3(1,-1,-1); 1059 linearDeflectionV *= new Vector3(1, -1, -1);
1057 1060
1058 // Correciont is vehicle relative. Convert to world coordinates and add to the velocity 1061 // Correction is vehicle relative. Convert to world coordinates.
1059 VehicleVelocity += linearDeflectionV * VehicleOrientation; 1062 Vector3 linearDeflectionW = linearDeflectionV * VehicleOrientation;
1060 1063
1061 VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}", 1064 // Optionally, if not colliding, don't effect world downward velocity. Let falling things fall.
1062 ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV); 1065 if (BSParam.VehicleLinearDeflectionNotCollidingNoZ && !m_controllingPrim.IsColliding)
1066 {
1067 linearDeflectionW.Z = 0f;
1068 }
1069
1070 VehicleVelocity += linearDeflectionW;
1071
1072 VDetailLog("{0}, MoveLinear,LinearDeflection,linDefEff={1},linDefTS={2},linDeflectionV={3}",
1073 ControllingPrim.LocalID, m_linearDeflectionEfficiency, m_linearDeflectionTimescale, linearDeflectionV);
1074 }
1063 } 1075 }
1064 1076
1065 public void ComputeLinearTerrainHeightCorrection(float pTimestep) 1077 public void ComputeLinearTerrainHeightCorrection(float pTimestep)
diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
index 75c3399..dcf1e83 100755
--- a/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
+++ b/OpenSim/Region/Physics/BulletSPlugin/BSParam.cs
@@ -155,6 +155,8 @@ public static class BSParam
155 public static Vector3 VehicleInertiaFactor { get; private set; } 155 public static Vector3 VehicleInertiaFactor { get; private set; }
156 public static float VehicleGroundGravityFudge { get; private set; } 156 public static float VehicleGroundGravityFudge { get; private set; }
157 public static float VehicleAngularBankingTimescaleFudge { get; private set; } 157 public static float VehicleAngularBankingTimescaleFudge { get; private set; }
158 public static bool VehicleEnableLinearDeflection { get; private set; }
159 public static bool VehicleLinearDeflectionNotCollidingNoZ { get; private set; }
158 public static bool VehicleEnableAngularVerticalAttraction { get; private set; } 160 public static bool VehicleEnableAngularVerticalAttraction { get; private set; }
159 public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; } 161 public static int VehicleAngularVerticalAttractionAlgorithm { get; private set; }
160 public static bool VehicleEnableAngularDeflection { get; private set; } 162 public static bool VehicleEnableAngularDeflection { get; private set; }
@@ -609,10 +611,14 @@ public static class BSParam
609 0.2f ), 611 0.2f ),
610 new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.", 612 new ParameterDefn<float>("VehicleAngularBankingTimescaleFudge", "Factor to multiple angular banking timescale. Tune to increase realism.",
611 60.0f ), 613 60.0f ),
614 new ParameterDefn<bool>("VehicleEnableLinearDeflection", "Turn on/off vehicle linear deflection effect",
615 true ),
616 new ParameterDefn<bool>("VehicleLinearDeflectionNotCollidingNoZ", "Turn on/off linear deflection Z effect on non-colliding vehicles",
617 true ),
612 new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect", 618 new ParameterDefn<bool>("VehicleEnableAngularVerticalAttraction", "Turn on/off vehicle angular vertical attraction effect",
613 true ), 619 true ),
614 new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.", 620 new ParameterDefn<int>("VehicleAngularVerticalAttractionAlgorithm", "Select vertical attraction algo. You need to look at the source.",
615 1 ), 621 0 ),
616 new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect", 622 new ParameterDefn<bool>("VehicleEnableAngularDeflection", "Turn on/off vehicle angular deflection effect",
617 true ), 623 true ),
618 new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect", 624 new ParameterDefn<bool>("VehicleEnableAngularBanking", "Turn on/off vehicle angular banking effect",