aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/PhysicsModules/ubOde
diff options
context:
space:
mode:
authorUbitUmarov2016-08-28 03:51:20 +0100
committerUbitUmarov2016-08-28 03:51:20 +0100
commit804d4971e236a0e75a51358f3d9c43313d140e5f (patch)
tree8ff7a27cfea2af211cdfa7f0f06ff55c3a7da7d7 /OpenSim/Region/PhysicsModules/ubOde
parentreduce math on use of camerarotation (need to add a lock there). Fix a bug o... (diff)
downloadopensim-SC_OLD-804d4971e236a0e75a51358f3d9c43313d140e5f.zip
opensim-SC_OLD-804d4971e236a0e75a51358f3d9c43313d140e5f.tar.gz
opensim-SC_OLD-804d4971e236a0e75a51358f3d9c43313d140e5f.tar.bz2
opensim-SC_OLD-804d4971e236a0e75a51358f3d9c43313d140e5f.tar.xz
my broken version of vehicle mouse steer on ubOde (no bank,needs better damp)
Diffstat (limited to 'OpenSim/Region/PhysicsModules/ubOde')
-rw-r--r--OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs142
1 files changed, 103 insertions, 39 deletions
diff --git a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs
index d8a2272..456d9e9 100644
--- a/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs
+++ b/OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs
@@ -648,6 +648,10 @@ namespace OpenSim.Region.PhysicsModule.ubOde
648 break; 648 break;
649 649
650 } 650 }
651 // disable mouse steering
652 m_flags &= ~(VehicleFlag.MOUSELOOK_STEER |
653 VehicleFlag.MOUSELOOK_BANK |
654 VehicleFlag.CAMERA_DECOUPLED);
651 655
652 m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale); 656 m_lmDecay = (1.0f - 1.0f / m_linearMotorDecayTimescale);
653 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale; 657 m_amDecay = 1.0f - 1.0f / m_angularMotorDecayTimescale;
@@ -794,6 +798,16 @@ namespace OpenSim.Region.PhysicsModule.ubOde
794 798
795 float ldampZ = 0; 799 float ldampZ = 0;
796 800
801 bool mousemode = false;
802 if((m_flags & (VehicleFlag.MOUSELOOK_STEER |VehicleFlag.MOUSELOOK_BANK)) != 0 )
803 mousemode = true;
804
805 float bankingEfficiency;
806 if(mousemode)
807 bankingEfficiency = 0;
808 else
809 bankingEfficiency = m_bankingEfficiency;
810
797 // linear motor 811 // linear motor
798 if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000) 812 if (m_lmEfect > 0.01 && m_linearMotorTimescale < 1000)
799 { 813 {
@@ -967,7 +981,7 @@ namespace OpenSim.Region.PhysicsModule.ubOde
967 torque.Y += effpitch * ftmp; 981 torque.Y += effpitch * ftmp;
968 } 982 }
969 983
970 if (m_bankingEfficiency != 0 && Math.Abs(effroll) > 0.01) 984 if (bankingEfficiency != 0 && Math.Abs(effroll) > 0.01)
971 { 985 {
972 986
973 float broll = effroll; 987 float broll = effroll;
@@ -1018,58 +1032,108 @@ namespace OpenSim.Region.PhysicsModule.ubOde
1018 m_amdampZ = 1 / m_angularFrictionTimescale.Z; 1032 m_amdampZ = 1 / m_angularFrictionTimescale.Z;
1019 } 1033 }
1020 1034
1021 // angular motor 1035 if(mousemode)
1022 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
1023 { 1036 {
1024 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error 1037 CameraData cam = rootPrim.TryGetCameraData();
1025 tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep 1038 if(cam.Valid && cam.MouseLook)
1026 torque.X += tmpV.X * m_ampwr; 1039 {
1027 torque.Y += tmpV.Y * m_ampwr; 1040 Vector3 dirv = cam.CameraAtAxis * irotq;
1028 torque.Z += tmpV.Z;
1029 1041
1030 m_amEfect *= m_amDecay; 1042 float tmp;
1043 if(Math.Abs(dirv.X) > 0.01f)
1044 {
1045 if (Math.Abs(dirv.Z) > 0.01)
1046 {
1047 tmp = -(float)Math.Atan2(dirv.Z, dirv.X) * m_angularMotorDirection.Y;
1048 if(tmp < -4f)
1049 tmp = -4f;
1050 else if(tmp > 4f)
1051 tmp = 4f;
1052 torque.Y += (tmp - curLocalAngVel.Y) / m_angularMotorTimescale;
1053 }
1054
1055 if (Math.Abs(dirv.Y) > 0.01)
1056 {
1057 tmp = (float)Math.Atan2(dirv.Y, dirv.X) * m_angularMotorDirection.Z;
1058 if(tmp < -4f)
1059 tmp = -4f;
1060 else if(tmp > 4f)
1061 tmp = 4f;
1062 torque.Z += (tmp - curLocalAngVel.Z) / m_angularMotorTimescale;
1063 }
1064 }
1065 // angular friction
1066 if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
1067 {
1068 torque.X -= curLocalAngVel.X * m_amdampX;
1069 torque.Y -= curLocalAngVel.Y * m_amdampY;
1070 torque.Z -= curLocalAngVel.Z * m_amdampZ;
1071 }
1072 }
1073 else
1074 {
1075 if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
1076 {
1077 torque.X -= curLocalAngVel.X * 10f;
1078 torque.Y -= curLocalAngVel.Y * 10f;
1079 torque.Z -= curLocalAngVel.Z * 10f;
1080 }
1081 }
1031 } 1082 }
1032 else 1083 else
1033 m_amEfect = 0;
1034
1035 // angular deflection
1036 if (m_angularDeflectionEfficiency > 0)
1037 { 1084 {
1038 Vector3 dirv; 1085 // angular motor
1039 1086 if (m_amEfect > 0.01 && m_angularMotorTimescale < 1000)
1040 if (curLocalVel.X > 0.01f)
1041 dirv = curLocalVel;
1042 else if (curLocalVel.X < -0.01f)
1043 // use oposite
1044 dirv = -curLocalVel;
1045 else
1046 { 1087 {
1047 // make it fall into small positive x case 1088 tmpV = m_angularMotorDirection - curLocalAngVel; // velocity error
1048 dirv.X = 0.01f; 1089 tmpV *= m_amEfect / m_angularMotorTimescale; // error to correct in this timestep
1049 dirv.Y = curLocalVel.Y; 1090 torque.X += tmpV.X * m_ampwr;
1050 dirv.Z = curLocalVel.Z; 1091 torque.Y += tmpV.Y * m_ampwr;
1051 } 1092 torque.Z += tmpV.Z;
1052 1093
1053 float ftmp = m_angularDeflectionEfficiency / m_angularDeflectionTimescale; 1094 m_amEfect *= m_amDecay;
1095 }
1096 else
1097 m_amEfect = 0;
1054 1098
1055 if (Math.Abs(dirv.Z) > 0.01) 1099 // angular deflection
1100 if (m_angularDeflectionEfficiency > 0)
1056 { 1101 {
1057 torque.Y += - (float)Math.Atan2(dirv.Z, dirv.X) * ftmp; 1102 Vector3 dirv;
1103
1104 if (curLocalVel.X > 0.01f)
1105 dirv = curLocalVel;
1106 else if (curLocalVel.X < -0.01f)
1107 // use oposite
1108 dirv = -curLocalVel;
1109 else
1110 {
1111 // make it fall into small positive x case
1112 dirv.X = 0.01f;
1113 dirv.Y = curLocalVel.Y;
1114 dirv.Z = curLocalVel.Z;
1115 }
1116
1117 float ftmp = m_angularDeflectionEfficiency / m_angularDeflectionTimescale;
1118
1119 if (Math.Abs(dirv.Z) > 0.01)
1120 {
1121 torque.Y += - (float)Math.Atan2(dirv.Z, dirv.X) * ftmp;
1122 }
1123
1124 if (Math.Abs(dirv.Y) > 0.01)
1125 {
1126 torque.Z += (float)Math.Atan2(dirv.Y, dirv.X) * ftmp;
1127 }
1058 } 1128 }
1059 1129
1060 if (Math.Abs(dirv.Y) > 0.01) 1130 if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
1061 { 1131 {
1062 torque.Z += (float)Math.Atan2(dirv.Y, dirv.X) * ftmp; 1132 torque.X -= curLocalAngVel.X * m_amdampX;
1133 torque.Y -= curLocalAngVel.Y * m_amdampY;
1134 torque.Z -= curLocalAngVel.Z * m_amdampZ;
1063 } 1135 }
1064 } 1136 }
1065
1066 // angular friction
1067 if (curLocalAngVel.X != 0 || curLocalAngVel.Y != 0 || curLocalAngVel.Z != 0)
1068 {
1069 torque.X -= curLocalAngVel.X * m_amdampX;
1070 torque.Y -= curLocalAngVel.Y * m_amdampY;
1071 torque.Z -= curLocalAngVel.Z * m_amdampZ;
1072 }
1073 1137
1074 force *= dmass.mass; 1138 force *= dmass.mass;
1075 1139