diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 146 |
1 files changed, 47 insertions, 99 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 7772f94..d8a4ed1 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -1033,7 +1033,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1033 | 1033 | ||
1034 | BordersLocked = true; | 1034 | BordersLocked = true; |
1035 | Border northBorder = new Border(); | 1035 | Border northBorder = new Border(); |
1036 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- | 1036 | northBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<--- |
1037 | northBorder.CrossDirection = Cardinals.N; | 1037 | northBorder.CrossDirection = Cardinals.N; |
1038 | NorthBorders.Add(northBorder); | 1038 | NorthBorders.Add(northBorder); |
1039 | 1039 | ||
@@ -1043,7 +1043,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1043 | SouthBorders.Add(southBorder); | 1043 | SouthBorders.Add(southBorder); |
1044 | 1044 | ||
1045 | Border eastBorder = new Border(); | 1045 | Border eastBorder = new Border(); |
1046 | eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (int)Constants.RegionSize); //<--- | 1046 | eastBorder.BorderLine = new Vector3(float.MinValue, float.MaxValue, (float)RegionInfo.RegionSizeY); //<--- |
1047 | eastBorder.CrossDirection = Cardinals.E; | 1047 | eastBorder.CrossDirection = Cardinals.E; |
1048 | EastBorders.Add(eastBorder); | 1048 | EastBorders.Add(eastBorder); |
1049 | 1049 | ||
@@ -1099,8 +1099,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1099 | /// <returns>True after all operations complete, throws exceptions otherwise.</returns> | 1099 | /// <returns>True after all operations complete, throws exceptions otherwise.</returns> |
1100 | public override void OtherRegionUp(GridRegion otherRegion) | 1100 | public override void OtherRegionUp(GridRegion otherRegion) |
1101 | { | 1101 | { |
1102 | uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize); | 1102 | uint xcell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocX); |
1103 | uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize); | 1103 | uint ycell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocY); |
1104 | |||
1104 | //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}", | 1105 | //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}", |
1105 | // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell); | 1106 | // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell); |
1106 | 1107 | ||
@@ -1172,46 +1173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1172 | return found; | 1173 | return found; |
1173 | } | 1174 | } |
1174 | 1175 | ||
1175 | /// <summary> | ||
1176 | /// Checks whether this region has a neighbour in the given direction. | ||
1177 | /// </summary> | ||
1178 | /// <param name="car"></param> | ||
1179 | /// <param name="fix"></param> | ||
1180 | /// <returns> | ||
1181 | /// An integer which represents a compass point. N == 1, going clockwise until we reach NW == 8. | ||
1182 | /// Returns a positive integer if there is a region in that direction, a negative integer if not. | ||
1183 | /// </returns> | ||
1184 | public int HaveNeighbor(Cardinals car, ref int[] fix) | ||
1185 | { | ||
1186 | uint neighbourx = RegionInfo.RegionLocX; | ||
1187 | uint neighboury = RegionInfo.RegionLocY; | ||
1188 | |||
1189 | int dir = (int)car; | ||
1190 | |||
1191 | if (dir > 1 && dir < 5) //Heading East | ||
1192 | neighbourx++; | ||
1193 | else if (dir > 5) // Heading West | ||
1194 | neighbourx--; | ||
1195 | |||
1196 | if (dir < 3 || dir == 8) // Heading North | ||
1197 | neighboury++; | ||
1198 | else if (dir > 3 && dir < 7) // Heading Sout | ||
1199 | neighboury--; | ||
1200 | |||
1201 | int x = (int)(neighbourx * Constants.RegionSize); | ||
1202 | int y = (int)(neighboury * Constants.RegionSize); | ||
1203 | GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); | ||
1204 | |||
1205 | if (neighbourRegion == null) | ||
1206 | { | ||
1207 | fix[0] = (int)(RegionInfo.RegionLocX - neighbourx); | ||
1208 | fix[1] = (int)(RegionInfo.RegionLocY - neighboury); | ||
1209 | return dir * (-1); | ||
1210 | } | ||
1211 | else | ||
1212 | return dir; | ||
1213 | } | ||
1214 | |||
1215 | // Alias IncomingHelloNeighbour OtherRegionUp, for now | 1176 | // Alias IncomingHelloNeighbour OtherRegionUp, for now |
1216 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) | 1177 | public GridRegion IncomingHelloNeighbour(RegionInfo neighbour) |
1217 | { | 1178 | { |
@@ -1894,7 +1855,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1894 | { | 1855 | { |
1895 | try | 1856 | try |
1896 | { | 1857 | { |
1897 | double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); | 1858 | TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); |
1898 | if (map == null) | 1859 | if (map == null) |
1899 | { | 1860 | { |
1900 | // This should be in the Terrain module, but it isn't because | 1861 | // This should be in the Terrain module, but it isn't because |
@@ -1905,7 +1866,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1905 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); | 1866 | m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); |
1906 | 1867 | ||
1907 | m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); | 1868 | m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); |
1908 | Heightmap = new TerrainChannel(m_InitialTerrain); | 1869 | Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); |
1909 | 1870 | ||
1910 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); | 1871 | SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); |
1911 | } | 1872 | } |
@@ -1953,6 +1914,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1953 | 1914 | ||
1954 | GridRegion region = new GridRegion(RegionInfo); | 1915 | GridRegion region = new GridRegion(RegionInfo); |
1955 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); | 1916 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); |
1917 | m_log.DebugFormat("{0} RegisterRegionWithGrid. name={1},id={2},loc=<{3},{4}>,size=<{5},{6}>", | ||
1918 | LogHeader, m_regionName, | ||
1919 | RegionInfo.RegionID, | ||
1920 | RegionInfo.RegionLocX, RegionInfo.RegionLocY, | ||
1921 | RegionInfo.RegionSizeX, RegionInfo.RegionSizeY); | ||
1956 | if (error != String.Empty) | 1922 | if (error != String.Empty) |
1957 | throw new Exception(error); | 1923 | throw new Exception(error); |
1958 | } | 1924 | } |
@@ -2478,6 +2444,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2478 | EntityTransferModule.Cross(grp, attemptedPosition, silent); | 2444 | EntityTransferModule.Cross(grp, attemptedPosition, silent); |
2479 | } | 2445 | } |
2480 | 2446 | ||
2447 | // Simple test to see if a position is in the current region. | ||
2448 | // Resuming the position is relative to the region so anything outside its bounds. | ||
2449 | // Return 'true' if position inside region. | ||
2450 | public bool PositionIsInCurrentRegion(Vector3 pos) | ||
2451 | { | ||
2452 | bool ret = true; | ||
2453 | int xx = (int)Math.Floor(pos.X); | ||
2454 | int yy = (int)Math.Floor(pos.Y); | ||
2455 | if (xx < 0 | ||
2456 | || xx >= RegionInfo.RegionSizeX | ||
2457 | || yy < 0 | ||
2458 | || yy >= RegionInfo.RegionSizeY) | ||
2459 | ret = false; | ||
2460 | return ret; | ||
2461 | |||
2462 | } | ||
2463 | |||
2481 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2464 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
2482 | { | 2465 | { |
2483 | if (BordersLocked) | 2466 | if (BordersLocked) |
@@ -3895,6 +3878,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3895 | { | 3878 | { |
3896 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); | 3879 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); |
3897 | acd.startpos.X = crossedBorder.BorderLine.Z - 1; | 3880 | acd.startpos.X = crossedBorder.BorderLine.Z - 1; |
3881 | m_log.DebugFormat("{0} NewUserConnection Adjusted border E. startpos={1}", LogHeader, acd.startpos); | ||
3898 | } | 3882 | } |
3899 | 3883 | ||
3900 | if (TestBorderCross(acd.startpos, Cardinals.N)) | 3884 | if (TestBorderCross(acd.startpos, Cardinals.N)) |
@@ -3994,12 +3978,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3994 | { | 3978 | { |
3995 | if (posX < 0) | 3979 | if (posX < 0) |
3996 | posX = 0; | 3980 | posX = 0; |
3997 | else if (posX >= 256) | 3981 | else if (posX >= (float)RegionInfo.RegionSizeX) |
3998 | posX = 255.999f; | 3982 | posX = (float)RegionInfo.RegionSizeX - 0.001f; |
3999 | if (posY < 0) | 3983 | if (posY < 0) |
4000 | posY = 0; | 3984 | posY = 0; |
4001 | else if (posY >= 256) | 3985 | else if (posY >= (float)RegionInfo.RegionSizeY) |
4002 | posY = 255.999f; | 3986 | posY = (float)RegionInfo.RegionSizeY - 0.001f; |
4003 | 3987 | ||
4004 | reason = String.Empty; | 3988 | reason = String.Empty; |
4005 | if (Permissions.IsGod(agentID)) | 3989 | if (Permissions.IsGod(agentID)) |
@@ -4293,7 +4277,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4293 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4277 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4294 | 4278 | ||
4295 | // TODO: This check should probably be in QueryAccess(). | 4279 | // TODO: This check should probably be in QueryAccess(). |
4296 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4280 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); |
4297 | if (nearestParcel == null) | 4281 | if (nearestParcel == null) |
4298 | { | 4282 | { |
4299 | m_log.InfoFormat( | 4283 | m_log.InfoFormat( |
@@ -4600,44 +4584,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4600 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | 4584 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
4601 | if (sp != null) | 4585 | if (sp != null) |
4602 | { | 4586 | { |
4603 | uint regionX = RegionInfo.RegionLocX; | ||
4604 | uint regionY = RegionInfo.RegionLocY; | ||
4605 | |||
4606 | Utils.LongToUInts(regionHandle, out regionX, out regionY); | ||
4607 | |||
4608 | int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; | ||
4609 | int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; | ||
4610 | |||
4611 | position.X += shiftx; | ||
4612 | position.Y += shifty; | ||
4613 | |||
4614 | bool result = false; | ||
4615 | |||
4616 | if (TestBorderCross(position,Cardinals.N)) | ||
4617 | result = true; | ||
4618 | |||
4619 | if (TestBorderCross(position, Cardinals.S)) | ||
4620 | result = true; | ||
4621 | |||
4622 | if (TestBorderCross(position, Cardinals.E)) | ||
4623 | result = true; | ||
4624 | |||
4625 | if (TestBorderCross(position, Cardinals.W)) | ||
4626 | result = true; | ||
4627 | |||
4628 | // bordercross if position is outside of region | ||
4629 | |||
4630 | if (!result) | ||
4631 | { | ||
4632 | regionHandle = RegionInfo.RegionHandle; | ||
4633 | } | ||
4634 | else | ||
4635 | { | ||
4636 | // not in this region, undo the shift! | ||
4637 | position.X -= shiftx; | ||
4638 | position.Y -= shifty; | ||
4639 | } | ||
4640 | |||
4641 | if (EntityTransferModule != null) | 4587 | if (EntityTransferModule != null) |
4642 | { | 4588 | { |
4643 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | 4589 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); |
@@ -4817,7 +4763,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4817 | else | 4763 | else |
4818 | { | 4764 | { |
4819 | 4765 | ||
4820 | if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) | 4766 | if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) |
4821 | { | 4767 | { |
4822 | // The only time parcel != null when an object is inside a region is when | 4768 | // The only time parcel != null when an object is inside a region is when |
4823 | // there is nothing behind the landchannel. IE, no land plugin loaded. | 4769 | // there is nothing behind the landchannel. IE, no land plugin loaded. |
@@ -5478,7 +5424,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5478 | { | 5424 | { |
5479 | Vector3 unitDirection = Vector3.Normalize(direction); | 5425 | Vector3 unitDirection = Vector3.Normalize(direction); |
5480 | //Making distance to search go through some sane limit of distance | 5426 | //Making distance to search go through some sane limit of distance |
5481 | for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) | 5427 | for (float distance = 0; distance < Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY) * 2; distance += .5f) |
5482 | { | 5428 | { |
5483 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); | 5429 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); |
5484 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) | 5430 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) |
@@ -5532,9 +5478,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
5532 | int count = 0; | 5478 | int count = 0; |
5533 | int avgx = 0; | 5479 | int avgx = 0; |
5534 | int avgy = 0; | 5480 | int avgy = 0; |
5535 | for (int x = 0; x < Constants.RegionSize; x++) | 5481 | for (int x = 0; x < RegionInfo.RegionSizeX; x++) |
5536 | { | 5482 | { |
5537 | for (int y = 0; y < Constants.RegionSize; y++) | 5483 | for (int y = 0; y < RegionInfo.RegionSizeY; y++) |
5538 | { | 5484 | { |
5539 | //Just keep a running average as we check if all the points are inside or not | 5485 | //Just keep a running average as we check if all the points are inside or not |
5540 | if (parcel.ContainsPoint(x, y)) | 5486 | if (parcel.ContainsPoint(x, y)) |
@@ -5558,31 +5504,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
5558 | 5504 | ||
5559 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) | 5505 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) |
5560 | { | 5506 | { |
5561 | float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; | 5507 | float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2 |
5562 | float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; | 5508 | ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X; |
5509 | float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2 | ||
5510 | ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y; | ||
5563 | 5511 | ||
5564 | //find out what vertical edge to go to | 5512 | //find out what vertical edge to go to |
5565 | if (xdistance < ydistance) | 5513 | if (xdistance < ydistance) |
5566 | { | 5514 | { |
5567 | if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) | 5515 | if (avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2) |
5568 | { | 5516 | { |
5569 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); | 5517 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); |
5570 | } | 5518 | } |
5571 | else | 5519 | else |
5572 | { | 5520 | { |
5573 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); | 5521 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, RegionInfo.RegionSizeY, avatar.AbsolutePosition.Y); |
5574 | } | 5522 | } |
5575 | } | 5523 | } |
5576 | //find out what horizontal edge to go to | 5524 | //find out what horizontal edge to go to |
5577 | else | 5525 | else |
5578 | { | 5526 | { |
5579 | if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) | 5527 | if (avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2) |
5580 | { | 5528 | { |
5581 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); | 5529 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); |
5582 | } | 5530 | } |
5583 | else | 5531 | else |
5584 | { | 5532 | { |
5585 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); | 5533 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, RegionInfo.RegionSizeY); |
5586 | } | 5534 | } |
5587 | } | 5535 | } |
5588 | } | 5536 | } |