diff options
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs')
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs | 69 |
1 files changed, 51 insertions, 18 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs index 456d9e9..2b8e3ba 100644 --- a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs +++ b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs | |||
@@ -799,12 +799,24 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
799 | float ldampZ = 0; | 799 | float ldampZ = 0; |
800 | 800 | ||
801 | bool mousemode = false; | 801 | bool mousemode = false; |
802 | if((m_flags & (VehicleFlag.MOUSELOOK_STEER |VehicleFlag.MOUSELOOK_BANK)) != 0 ) | 802 | bool mousemodebank = false; |
803 | mousemode = true; | ||
804 | 803 | ||
805 | float bankingEfficiency; | 804 | float bankingEfficiency; |
806 | if(mousemode) | 805 | float verticalAttractionTimescale = m_verticalAttractionTimescale; |
807 | bankingEfficiency = 0; | 806 | |
807 | if((m_flags & (VehicleFlag.MOUSELOOK_STEER | VehicleFlag.MOUSELOOK_BANK)) != 0 ) | ||
808 | { | ||
809 | mousemode = true; | ||
810 | mousemodebank = (m_flags & VehicleFlag.MOUSELOOK_BANK) != 0; | ||
811 | if(mousemodebank) | ||
812 | { | ||
813 | bankingEfficiency = m_bankingEfficiency; | ||
814 | if(verticalAttractionTimescale < 149.9) | ||
815 | verticalAttractionTimescale *= 2.0f; // reduce current instability | ||
816 | } | ||
817 | else | ||
818 | bankingEfficiency = 0; | ||
819 | } | ||
808 | else | 820 | else |
809 | bankingEfficiency = m_bankingEfficiency; | 821 | bankingEfficiency = m_bankingEfficiency; |
810 | 822 | ||
@@ -944,12 +956,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
944 | } | 956 | } |
945 | 957 | ||
946 | // vertical atractor | 958 | // vertical atractor |
947 | if (m_verticalAttractionTimescale < 300) | 959 | if (verticalAttractionTimescale < 300) |
948 | { | 960 | { |
949 | float roll; | 961 | float roll; |
950 | float pitch; | 962 | float pitch; |
951 | 963 | ||
952 | float ftmp = m_invtimestep / m_verticalAttractionTimescale / m_verticalAttractionTimescale; | 964 | float ftmp = m_invtimestep / verticalAttractionTimescale / verticalAttractionTimescale; |
953 | 965 | ||
954 | float ftmp2; | 966 | float ftmp2; |
955 | ftmp2 = 0.5f * m_verticalAttractionEfficiency * m_invtimestep; | 967 | ftmp2 = 0.5f * m_verticalAttractionEfficiency * m_invtimestep; |
@@ -1039,36 +1051,57 @@ namespace OpenSim.Region.PhysicsModule.ubOde | |||
1039 | { | 1051 | { |
1040 | Vector3 dirv = cam.CameraAtAxis * irotq; | 1052 | Vector3 dirv = cam.CameraAtAxis * irotq; |
1041 | 1053 | ||
1054 | float invamts = 1.0f/m_angularMotorTimescale; | ||
1042 | float tmp; | 1055 | float tmp; |
1043 | if(Math.Abs(dirv.X) > 0.01f) | 1056 | |
1057 | // get out x == 0 plane | ||
1058 | if(Math.Abs(dirv.X) < 0.001f) | ||
1059 | dirv.X = 0001f; | ||
1060 | |||
1061 | if (Math.Abs(dirv.Z) > 0.01) | ||
1062 | { | ||
1063 | tmp = -(float)Math.Atan2(dirv.Z, dirv.X) * m_angularMotorDirection.Y; | ||
1064 | if(tmp < -4f) | ||
1065 | tmp = -4f; | ||
1066 | else if(tmp > 4f) | ||
1067 | tmp = 4f; | ||
1068 | torque.Y += (tmp - curLocalAngVel.Y) * invamts; | ||
1069 | torque.Y -= curLocalAngVel.Y * m_amdampY; | ||
1070 | } | ||
1071 | else | ||
1072 | torque.Y -= curLocalAngVel.Y * m_invtimestep; | ||
1073 | |||
1074 | if (Math.Abs(dirv.Y) > 0.01) | ||
1044 | { | 1075 | { |
1045 | if (Math.Abs(dirv.Z) > 0.01) | 1076 | if(mousemodebank) |
1046 | { | 1077 | { |
1047 | tmp = -(float)Math.Atan2(dirv.Z, dirv.X) * m_angularMotorDirection.Y; | 1078 | tmp = -(float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.X; |
1048 | if(tmp < -4f) | 1079 | if(tmp < -4f) |
1049 | tmp = -4f; | 1080 | tmp = -4f; |
1050 | else if(tmp > 4f) | 1081 | else if(tmp > 4f) |
1051 | tmp = 4f; | 1082 | tmp = 4f; |
1052 | torque.Y += (tmp - curLocalAngVel.Y) / m_angularMotorTimescale; | 1083 | torque.X += (tmp - curLocalAngVel.X) * invamts; |
1053 | } | 1084 | } |
1054 | 1085 | else | |
1055 | if (Math.Abs(dirv.Y) > 0.01) | ||
1056 | { | 1086 | { |
1057 | tmp = (float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.Z; | 1087 | tmp = (float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.Z; |
1088 | tmp *= invamts; | ||
1058 | if(tmp < -4f) | 1089 | if(tmp < -4f) |
1059 | tmp = -4f; | 1090 | tmp = -4f; |
1060 | else if(tmp > 4f) | 1091 | else if(tmp > 4f) |
1061 | tmp = 4f; | 1092 | tmp = 4f; |
1062 | torque.Z += (tmp - curLocalAngVel.Z) / m_angularMotorTimescale; | 1093 | torque.Z += (tmp - curLocalAngVel.Z) * invamts; |
1063 | } | 1094 | } |
1064 | } | ||
1065 | // angular friction | ||
1066 | if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0) | ||
1067 | { | ||
1068 | torque.X -= curLocalAngVel.X * m_amdampX; | 1095 | torque.X -= curLocalAngVel.X * m_amdampX; |
1069 | torque.Y -= curLocalAngVel.Y * m_amdampY; | ||
1070 | torque.Z -= curLocalAngVel.Z * m_amdampZ; | 1096 | torque.Z -= curLocalAngVel.Z * m_amdampZ; |
1071 | } | 1097 | } |
1098 | else | ||
1099 | { | ||
1100 | if(mousemodebank) | ||
1101 | torque.X -= curLocalAngVel.X * m_invtimestep; | ||
1102 | else | ||
1103 | torque.Z -= curLocalAngVel.Z * m_invtimestep; | ||
1104 | } | ||
1072 | } | 1105 | } |
1073 | else | 1106 | else |
1074 | { | 1107 | { |