diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 89 |
1 files changed, 80 insertions, 9 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 65c97e8..167d5f7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -803,11 +803,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
803 | if (regionHandle == m_regionInfo.RegionHandle) | 803 | if (regionHandle == m_regionInfo.RegionHandle) |
804 | { | 804 | { |
805 | m_log.DebugFormat( | 805 | m_log.DebugFormat( |
806 | "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}", | 806 | "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}", |
807 | position, m_regionInfo.RegionName); | 807 | position, m_regionInfo.RegionName); |
808 | 808 | ||
809 | // Teleport within the same region | 809 | // Teleport within the same region |
810 | if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0) | 810 | if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) |
811 | { | 811 | { |
812 | Vector3 emergencyPos = new Vector3(128, 128, 128); | 812 | Vector3 emergencyPos = new Vector3(128, 128, 128); |
813 | 813 | ||
@@ -816,10 +816,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
816 | position, avatar.Name, avatar.UUID, emergencyPos); | 816 | position, avatar.Name, avatar.UUID, emergencyPos); |
817 | position = emergencyPos; | 817 | position = emergencyPos; |
818 | } | 818 | } |
819 | 819 | ||
820 | // TODO: Get proper AVG Height | 820 | // TODO: Get proper AVG Height |
821 | float localAVHeight = 1.56f; | 821 | float localAVHeight = 1.56f; |
822 | float posZLimit = (float)avatar.Scene.Heightmap[(int)position.X, (int)position.Y]; | 822 | float posZLimit = 22; |
823 | |||
824 | // TODO: Check other Scene HeightField | ||
825 | if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize) | ||
826 | { | ||
827 | posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y]; | ||
828 | } | ||
829 | |||
823 | float newPosZ = posZLimit + localAVHeight; | 830 | float newPosZ = posZLimit + localAVHeight; |
824 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | 831 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) |
825 | { | 832 | { |
@@ -1084,6 +1091,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1084 | } | 1091 | } |
1085 | } | 1092 | } |
1086 | 1093 | ||
1094 | private bool IsOutsideRegion(Scene s, Vector3 pos) | ||
1095 | { | ||
1096 | |||
1097 | if (s.TestBorderCross(pos,Cardinals.N)) | ||
1098 | return true; | ||
1099 | if (s.TestBorderCross(pos, Cardinals.S)) | ||
1100 | return true; | ||
1101 | if (s.TestBorderCross(pos, Cardinals.E)) | ||
1102 | return true; | ||
1103 | if (s.TestBorderCross(pos, Cardinals.W)) | ||
1104 | return true; | ||
1105 | |||
1106 | return false; | ||
1107 | } | ||
1108 | |||
1087 | public bool WaitForCallback(UUID id) | 1109 | public bool WaitForCallback(UUID id) |
1088 | { | 1110 | { |
1089 | int count = 200; | 1111 | int count = 200; |
@@ -1165,27 +1187,76 @@ namespace OpenSim.Region.Framework.Scenes | |||
1165 | // distance into new region to place avatar | 1187 | // distance into new region to place avatar |
1166 | const float enterDistance = 0.1f; | 1188 | const float enterDistance = 0.1f; |
1167 | 1189 | ||
1168 | if (pos.X < boundaryDistance) | 1190 | if (scene.TestBorderCross(pos, Cardinals.W)) |
1191 | { | ||
1192 | if (scene.TestBorderCross(pos, Cardinals.N)) | ||
1193 | { | ||
1194 | Border b = scene.GetCrossedBorder(pos, Cardinals.N); | ||
1195 | neighboury += (uint)(int)(b.BorderLine.Z/(int)Constants.RegionSize); | ||
1196 | } | ||
1197 | |||
1198 | |||
1199 | neighbourx--; | ||
1200 | newpos.X = Constants.RegionSize - enterDistance; | ||
1201 | |||
1202 | } | ||
1203 | else if (scene.TestBorderCross(pos, Cardinals.E)) | ||
1204 | { | ||
1205 | if (scene.TestBorderCross(pos, Cardinals.S)) | ||
1206 | { | ||
1207 | neighboury--; | ||
1208 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1209 | } | ||
1210 | else if (scene.TestBorderCross(pos, Cardinals.N)) | ||
1211 | { | ||
1212 | Border b = scene.GetCrossedBorder(pos, Cardinals.N); | ||
1213 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1214 | newpos.Y = enterDistance; | ||
1215 | } | ||
1216 | else | ||
1217 | { | ||
1218 | Border b = scene.GetCrossedBorder(pos, Cardinals.E); | ||
1219 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1220 | newpos.X = enterDistance; | ||
1221 | } | ||
1222 | |||
1223 | } | ||
1224 | else if (scene.TestBorderCross(pos, Cardinals.S)) | ||
1225 | { | ||
1226 | neighboury--; | ||
1227 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1228 | } | ||
1229 | else if (scene.TestBorderCross(pos, Cardinals.N)) | ||
1230 | { | ||
1231 | Border b = scene.GetCrossedBorder(pos, Cardinals.N); | ||
1232 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1233 | newpos.Y = enterDistance; | ||
1234 | } | ||
1235 | |||
1236 | /* | ||
1237 | |||
1238 | if (pos.X < boundaryDistance) //West | ||
1169 | { | 1239 | { |
1170 | neighbourx--; | 1240 | neighbourx--; |
1171 | newpos.X = Constants.RegionSize - enterDistance; | 1241 | newpos.X = Constants.RegionSize - enterDistance; |
1172 | } | 1242 | } |
1173 | else if (pos.X > Constants.RegionSize - boundaryDistance) | 1243 | else if (pos.X > Constants.RegionSize - boundaryDistance) // East |
1174 | { | 1244 | { |
1175 | neighbourx++; | 1245 | neighbourx++; |
1176 | newpos.X = enterDistance; | 1246 | newpos.X = enterDistance; |
1177 | } | 1247 | } |
1178 | 1248 | ||
1179 | if (pos.Y < boundaryDistance) | 1249 | if (pos.Y < boundaryDistance) // South |
1180 | { | 1250 | { |
1181 | neighboury--; | 1251 | neighboury--; |
1182 | newpos.Y = Constants.RegionSize - enterDistance; | 1252 | newpos.Y = Constants.RegionSize - enterDistance; |
1183 | } | 1253 | } |
1184 | else if (pos.Y > Constants.RegionSize - boundaryDistance) | 1254 | else if (pos.Y > Constants.RegionSize - boundaryDistance) // North |
1185 | { | 1255 | { |
1186 | neighboury++; | 1256 | neighboury++; |
1187 | newpos.Y = enterDistance; | 1257 | newpos.Y = enterDistance; |
1188 | } | 1258 | } |
1259 | */ | ||
1189 | 1260 | ||
1190 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | 1261 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; |
1191 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); | 1262 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); |