diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 141 |
1 files changed, 42 insertions, 99 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index c3110a2..2f666c0 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 | } |
@@ -2483,6 +2444,23 @@ namespace OpenSim.Region.Framework.Scenes | |||
2483 | EntityTransferModule.Cross(grp, attemptedPosition, silent); | 2444 | EntityTransferModule.Cross(grp, attemptedPosition, silent); |
2484 | } | 2445 | } |
2485 | 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 | |||
2486 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2464 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
2487 | { | 2465 | { |
2488 | if (BordersLocked) | 2466 | if (BordersLocked) |
@@ -3900,6 +3878,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3900 | { | 3878 | { |
3901 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); | 3879 | Border crossedBorder = GetCrossedBorder(acd.startpos, Cardinals.E); |
3902 | 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); | ||
3903 | } | 3882 | } |
3904 | 3883 | ||
3905 | if (TestBorderCross(acd.startpos, Cardinals.N)) | 3884 | if (TestBorderCross(acd.startpos, Cardinals.N)) |
@@ -4019,12 +3998,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4019 | { | 3998 | { |
4020 | if (posX < 0) | 3999 | if (posX < 0) |
4021 | posX = 0; | 4000 | posX = 0; |
4022 | else if (posX >= 256) | 4001 | else if (posX >= (float)RegionInfo.RegionSizeX) |
4023 | posX = 255.999f; | 4002 | posX = (float)RegionInfo.RegionSizeX - 0.001f; |
4024 | if (posY < 0) | 4003 | if (posY < 0) |
4025 | posY = 0; | 4004 | posY = 0; |
4026 | else if (posY >= 256) | 4005 | else if (posY >= (float)RegionInfo.RegionSizeY) |
4027 | posY = 255.999f; | 4006 | posY = (float)RegionInfo.RegionSizeY - 0.001f; |
4028 | 4007 | ||
4029 | reason = String.Empty; | 4008 | reason = String.Empty; |
4030 | if (Permissions.IsGod(agentID)) | 4009 | if (Permissions.IsGod(agentID)) |
@@ -4318,7 +4297,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4318 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 4297 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
4319 | 4298 | ||
4320 | // TODO: This check should probably be in QueryAccess(). | 4299 | // TODO: This check should probably be in QueryAccess(). |
4321 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); | 4300 | ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2); |
4322 | if (nearestParcel == null) | 4301 | if (nearestParcel == null) |
4323 | { | 4302 | { |
4324 | m_log.InfoFormat( | 4303 | m_log.InfoFormat( |
@@ -4613,44 +4592,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4613 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); | 4592 | ScenePresence sp = GetScenePresence(remoteClient.AgentId); |
4614 | if (sp != null) | 4593 | if (sp != null) |
4615 | { | 4594 | { |
4616 | uint regionX = RegionInfo.RegionLocX; | ||
4617 | uint regionY = RegionInfo.RegionLocY; | ||
4618 | |||
4619 | Utils.LongToUInts(regionHandle, out regionX, out regionY); | ||
4620 | |||
4621 | int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; | ||
4622 | int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; | ||
4623 | |||
4624 | position.X += shiftx; | ||
4625 | position.Y += shifty; | ||
4626 | |||
4627 | bool result = false; | ||
4628 | |||
4629 | if (TestBorderCross(position,Cardinals.N)) | ||
4630 | result = true; | ||
4631 | |||
4632 | if (TestBorderCross(position, Cardinals.S)) | ||
4633 | result = true; | ||
4634 | |||
4635 | if (TestBorderCross(position, Cardinals.E)) | ||
4636 | result = true; | ||
4637 | |||
4638 | if (TestBorderCross(position, Cardinals.W)) | ||
4639 | result = true; | ||
4640 | |||
4641 | // bordercross if position is outside of region | ||
4642 | |||
4643 | if (!result) | ||
4644 | { | ||
4645 | regionHandle = RegionInfo.RegionHandle; | ||
4646 | } | ||
4647 | else | ||
4648 | { | ||
4649 | // not in this region, undo the shift! | ||
4650 | position.X -= shiftx; | ||
4651 | position.Y -= shifty; | ||
4652 | } | ||
4653 | |||
4654 | if (EntityTransferModule != null) | 4595 | if (EntityTransferModule != null) |
4655 | { | 4596 | { |
4656 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); | 4597 | EntityTransferModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); |
@@ -4830,7 +4771,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4830 | else | 4771 | else |
4831 | { | 4772 | { |
4832 | 4773 | ||
4833 | if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) | 4774 | if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY) |
4834 | { | 4775 | { |
4835 | // The only time parcel != null when an object is inside a region is when | 4776 | // The only time parcel != null when an object is inside a region is when |
4836 | // there is nothing behind the landchannel. IE, no land plugin loaded. | 4777 | // there is nothing behind the landchannel. IE, no land plugin loaded. |
@@ -5491,7 +5432,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
5491 | { | 5432 | { |
5492 | Vector3 unitDirection = Vector3.Normalize(direction); | 5433 | Vector3 unitDirection = Vector3.Normalize(direction); |
5493 | //Making distance to search go through some sane limit of distance | 5434 | //Making distance to search go through some sane limit of distance |
5494 | for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) | 5435 | for (float distance = 0; distance < Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY) * 2; distance += .5f) |
5495 | { | 5436 | { |
5496 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); | 5437 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); |
5497 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) | 5438 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) |
@@ -5545,9 +5486,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
5545 | int count = 0; | 5486 | int count = 0; |
5546 | int avgx = 0; | 5487 | int avgx = 0; |
5547 | int avgy = 0; | 5488 | int avgy = 0; |
5548 | for (int x = 0; x < Constants.RegionSize; x++) | 5489 | for (int x = 0; x < RegionInfo.RegionSizeX; x++) |
5549 | { | 5490 | { |
5550 | for (int y = 0; y < Constants.RegionSize; y++) | 5491 | for (int y = 0; y < RegionInfo.RegionSizeY; y++) |
5551 | { | 5492 | { |
5552 | //Just keep a running average as we check if all the points are inside or not | 5493 | //Just keep a running average as we check if all the points are inside or not |
5553 | if (parcel.ContainsPoint(x, y)) | 5494 | if (parcel.ContainsPoint(x, y)) |
@@ -5571,31 +5512,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
5571 | 5512 | ||
5572 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) | 5513 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) |
5573 | { | 5514 | { |
5574 | float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; | 5515 | float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2 |
5575 | float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; | 5516 | ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X; |
5517 | float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2 | ||
5518 | ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y; | ||
5576 | 5519 | ||
5577 | //find out what vertical edge to go to | 5520 | //find out what vertical edge to go to |
5578 | if (xdistance < ydistance) | 5521 | if (xdistance < ydistance) |
5579 | { | 5522 | { |
5580 | if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) | 5523 | if (avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2) |
5581 | { | 5524 | { |
5582 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); | 5525 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); |
5583 | } | 5526 | } |
5584 | else | 5527 | else |
5585 | { | 5528 | { |
5586 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); | 5529 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, RegionInfo.RegionSizeY, avatar.AbsolutePosition.Y); |
5587 | } | 5530 | } |
5588 | } | 5531 | } |
5589 | //find out what horizontal edge to go to | 5532 | //find out what horizontal edge to go to |
5590 | else | 5533 | else |
5591 | { | 5534 | { |
5592 | if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) | 5535 | if (avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2) |
5593 | { | 5536 | { |
5594 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); | 5537 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); |
5595 | } | 5538 | } |
5596 | else | 5539 | else |
5597 | { | 5540 | { |
5598 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); | 5541 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, RegionInfo.RegionSizeY); |
5599 | } | 5542 | } |
5600 | } | 5543 | } |
5601 | } | 5544 | } |