diff options
author | Robert Adams | 2013-07-09 09:33:46 -0700 |
---|---|---|
committer | Robert Adams | 2013-07-09 09:37:42 -0700 |
commit | 2c761cef192670a6f54fe10bb5b5894b5371ea7c (patch) | |
tree | 223c6582ef8d27db7465d351492399c110318781 /OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | |
parent | remove some cruft and trigger a rebuild (diff) | |
download | opensim-SC-2c761cef192670a6f54fe10bb5b5894b5371ea7c.zip opensim-SC-2c761cef192670a6f54fe10bb5b5894b5371ea7c.tar.gz opensim-SC-2c761cef192670a6f54fe10bb5b5894b5371ea7c.tar.bz2 opensim-SC-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/BulletSPlugin/BSDynamics.cs')
-rw-r--r-- | OpenSim/Region/Physics/BulletSPlugin/BSDynamics.cs | 42 |
1 files changed, 27 insertions, 15 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) |