diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 101 |
1 files changed, 90 insertions, 11 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 65c97e8..1673a22 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; |
@@ -1158,34 +1180,91 @@ namespace OpenSim.Region.Framework.Scenes | |||
1158 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); | 1180 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); |
1159 | uint neighbourx = m_regionInfo.RegionLocX; | 1181 | uint neighbourx = m_regionInfo.RegionLocX; |
1160 | uint neighboury = m_regionInfo.RegionLocY; | 1182 | uint neighboury = m_regionInfo.RegionLocY; |
1183 | const float boundaryDistance = 1.7f; | ||
1184 | Vector3 northCross = new Vector3(0, boundaryDistance, 0); | ||
1185 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); | ||
1186 | Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); | ||
1187 | Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); | ||
1161 | 1188 | ||
1162 | // distance to edge that will trigger crossing | 1189 | // distance to edge that will trigger crossing |
1163 | const float boundaryDistance = 1.7f; | 1190 | |
1164 | 1191 | ||
1165 | // distance into new region to place avatar | 1192 | // distance into new region to place avatar |
1166 | const float enterDistance = 0.1f; | 1193 | const float enterDistance = 0.5f; |
1194 | |||
1195 | if (scene.TestBorderCross(pos + westCross, Cardinals.W)) | ||
1196 | { | ||
1197 | if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1198 | { | ||
1199 | Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1200 | neighboury += (uint)(int)(b.BorderLine.Z/(int)Constants.RegionSize); | ||
1201 | } | ||
1202 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1203 | { | ||
1204 | neighboury--; | ||
1205 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1206 | } | ||
1207 | |||
1208 | neighbourx--; | ||
1209 | newpos.X = Constants.RegionSize - enterDistance; | ||
1210 | |||
1211 | } | ||
1212 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) | ||
1213 | { | ||
1214 | Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E); | ||
1215 | neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1216 | newpos.X = enterDistance; | ||
1217 | |||
1218 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1219 | { | ||
1220 | neighboury--; | ||
1221 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1222 | } | ||
1223 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1224 | { | ||
1225 | Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1226 | neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); | ||
1227 | newpos.Y = enterDistance; | ||
1228 | } | ||
1229 | |||
1230 | |||
1231 | } | ||
1232 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1233 | { | ||
1234 | neighboury--; | ||
1235 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1236 | } | ||
1237 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1238 | { | ||
1239 | Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1240 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1241 | newpos.Y = enterDistance; | ||
1242 | } | ||
1243 | |||
1244 | /* | ||
1167 | 1245 | ||
1168 | if (pos.X < boundaryDistance) | 1246 | if (pos.X < boundaryDistance) //West |
1169 | { | 1247 | { |
1170 | neighbourx--; | 1248 | neighbourx--; |
1171 | newpos.X = Constants.RegionSize - enterDistance; | 1249 | newpos.X = Constants.RegionSize - enterDistance; |
1172 | } | 1250 | } |
1173 | else if (pos.X > Constants.RegionSize - boundaryDistance) | 1251 | else if (pos.X > Constants.RegionSize - boundaryDistance) // East |
1174 | { | 1252 | { |
1175 | neighbourx++; | 1253 | neighbourx++; |
1176 | newpos.X = enterDistance; | 1254 | newpos.X = enterDistance; |
1177 | } | 1255 | } |
1178 | 1256 | ||
1179 | if (pos.Y < boundaryDistance) | 1257 | if (pos.Y < boundaryDistance) // South |
1180 | { | 1258 | { |
1181 | neighboury--; | 1259 | neighboury--; |
1182 | newpos.Y = Constants.RegionSize - enterDistance; | 1260 | newpos.Y = Constants.RegionSize - enterDistance; |
1183 | } | 1261 | } |
1184 | else if (pos.Y > Constants.RegionSize - boundaryDistance) | 1262 | else if (pos.Y > Constants.RegionSize - boundaryDistance) // North |
1185 | { | 1263 | { |
1186 | neighboury++; | 1264 | neighboury++; |
1187 | newpos.Y = enterDistance; | 1265 | newpos.Y = enterDistance; |
1188 | } | 1266 | } |
1267 | */ | ||
1189 | 1268 | ||
1190 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | 1269 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; |
1191 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); | 1270 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); |