diff options
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SOPVehicle.cs | 10 | ||||
-rwxr-xr-x | OpenSim/Region/Framework/Scenes/Scene.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 30 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 1 | ||||
-rw-r--r-- | OpenSim/Region/PhysicsModules/ubOde/ODEDynamics.cs | 142 |
5 files changed, 141 insertions, 43 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs index 2b33cf7..897918a 100644 --- a/OpenSim/Region/Framework/Scenes/SOPVehicle.cs +++ b/OpenSim/Region/Framework/Scenes/SOPVehicle.cs | |||
@@ -406,6 +406,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
406 | ph.SetVehicle(vd); | 406 | ph.SetVehicle(vd); |
407 | } | 407 | } |
408 | 408 | ||
409 | public bool CameraDecoupled | ||
410 | { | ||
411 | get | ||
412 | { | ||
413 | if((vd.m_flags & VehicleFlag.CAMERA_DECOUPLED) != 0) | ||
414 | return true; | ||
415 | return false; | ||
416 | } | ||
417 | } | ||
418 | |||
409 | private XmlTextWriter writer; | 419 | private XmlTextWriter writer; |
410 | 420 | ||
411 | private void XWint(string name, int i) | 421 | private void XWint(string name, int i) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index fee3bcf..0d6af77 100755 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -5431,7 +5431,6 @@ Label_GroupsDone: | |||
5431 | } | 5431 | } |
5432 | } | 5432 | } |
5433 | } | 5433 | } |
5434 | |||
5435 | } | 5434 | } |
5436 | 5435 | ||
5437 | public void DeleteFromStorage(UUID uuid) | 5436 | public void DeleteFromStorage(UUID uuid) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index bf78c3f..f7f1835 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2162,9 +2162,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2162 | { | 2162 | { |
2163 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); | 2163 | AddToPhysics(isPhysical, isPhantom, building, isPhysical); |
2164 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here | 2164 | UpdatePhysicsSubscribedEvents(); // not sure if appliable here |
2165 | if(!_VolumeDetectActive && | ||
2166 | m_vehicleParams != null && | ||
2167 | m_vehicleParams.CameraDecoupled && | ||
2168 | m_localId == ParentGroup.RootPart.LocalId) | ||
2169 | AddFlag(PrimFlags.CameraDecoupled); | ||
2170 | else | ||
2171 | RemFlag(PrimFlags.CameraDecoupled); | ||
2165 | } | 2172 | } |
2166 | else | 2173 | else |
2174 | { | ||
2167 | PhysActor = null; // just to be sure | 2175 | PhysActor = null; // just to be sure |
2176 | RemFlag(PrimFlags.CameraDecoupled); | ||
2177 | } | ||
2168 | } | 2178 | } |
2169 | } | 2179 | } |
2170 | 2180 | ||
@@ -3539,6 +3549,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3539 | set | 3549 | set |
3540 | { | 3550 | { |
3541 | m_vehicleParams = value; | 3551 | m_vehicleParams = value; |
3552 | |||
3542 | } | 3553 | } |
3543 | } | 3554 | } |
3544 | 3555 | ||
@@ -3583,7 +3594,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
3583 | 3594 | ||
3584 | m_vehicleParams.ProcessVehicleFlags(param, remove); | 3595 | m_vehicleParams.ProcessVehicleFlags(param, remove); |
3585 | 3596 | ||
3586 | if (_parentID ==0 && PhysActor != null) | 3597 | if (_parentID == 0 && PhysActor != null) |
3587 | { | 3598 | { |
3588 | PhysActor.VehicleFlags(param, remove); | 3599 | PhysActor.VehicleFlags(param, remove); |
3589 | } | 3600 | } |
@@ -4662,6 +4673,11 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
4662 | 4673 | ||
4663 | if (ParentGroup != null) | 4674 | if (ParentGroup != null) |
4664 | { | 4675 | { |
4676 | if(UsePhysics && !SetPhantom && m_localId == ParentGroup.RootPart.LocalId && | ||
4677 | m_vehicleParams != null && m_vehicleParams.CameraDecoupled) | ||
4678 | AddFlag(PrimFlags.CameraDecoupled); | ||
4679 | else | ||
4680 | RemFlag(PrimFlags.CameraDecoupled); | ||
4665 | ParentGroup.HasGroupChanged = true; | 4681 | ParentGroup.HasGroupChanged = true; |
4666 | ScheduleFullUpdate(); | 4682 | ScheduleFullUpdate(); |
4667 | } | 4683 | } |
@@ -4722,9 +4738,16 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
4722 | if (VolumeDetectActive) // change if not the default only | 4738 | if (VolumeDetectActive) // change if not the default only |
4723 | pa.SetVolumeDetect(1); | 4739 | pa.SetVolumeDetect(1); |
4724 | 4740 | ||
4725 | if (m_vehicleParams != null && LocalId == ParentGroup.RootPart.LocalId) | 4741 | if (m_vehicleParams != null && m_localId == ParentGroup.RootPart.LocalId) |
4742 | { | ||
4726 | m_vehicleParams.SetVehicle(pa); | 4743 | m_vehicleParams.SetVehicle(pa); |
4727 | 4744 | if(isPhysical && !isPhantom && m_vehicleParams.CameraDecoupled) | |
4745 | AddFlag(PrimFlags.CameraDecoupled); | ||
4746 | else | ||
4747 | RemFlag(PrimFlags.CameraDecoupled); | ||
4748 | } | ||
4749 | else | ||
4750 | RemFlag(PrimFlags.CameraDecoupled); | ||
4728 | // we are going to tell rest of code about physics so better have this here | 4751 | // we are going to tell rest of code about physics so better have this here |
4729 | PhysActor = pa; | 4752 | PhysActor = pa; |
4730 | 4753 | ||
@@ -4800,6 +4823,7 @@ SendFullUpdateToClient(remoteClient, Position) ignores position parameter | |||
4800 | 4823 | ||
4801 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); | 4824 | ParentGroup.Scene.EventManager.TriggerObjectRemovedFromPhysicalScene(this); |
4802 | } | 4825 | } |
4826 | RemFlag(PrimFlags.CameraDecoupled); | ||
4803 | PhysActor = null; | 4827 | PhysActor = null; |
4804 | } | 4828 | } |
4805 | 4829 | ||
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 643a479..2dc6f48 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -5442,6 +5442,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5442 | Valid = true, | 5442 | Valid = true, |
5443 | MouseLook = this.m_mouseLook, | 5443 | MouseLook = this.m_mouseLook, |
5444 | CameraRotation = this.CameraRotation, | 5444 | CameraRotation = this.CameraRotation, |
5445 | CameraAtAxis = this.CameraAtAxis | ||
5445 | }; | 5446 | }; |
5446 | } | 5447 | } |
5447 | 5448 | ||
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 | ||