aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs89
1 files changed, 61 insertions, 28 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 7772f94..3a5aa0f 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,11 @@ 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 = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
1103 uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize); 1103 // uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
1104 uint xcell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocX);
1105 uint ycell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocY);
1106
1104 //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}", 1107 //m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
1105 // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell); 1108 // RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
1106 1109
@@ -1198,9 +1201,11 @@ namespace OpenSim.Region.Framework.Scenes
1198 else if (dir > 3 && dir < 7) // Heading Sout 1201 else if (dir > 3 && dir < 7) // Heading Sout
1199 neighboury--; 1202 neighboury--;
1200 1203
1201 int x = (int)(neighbourx * Constants.RegionSize); 1204 // int x = (int)(neighbourx * Constants.RegionSize);
1202 int y = (int)(neighboury * Constants.RegionSize); 1205 // int y = (int)(neighboury * Constants.RegionSize);
1203 GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y); 1206 uint x = Util.RegionToWorldLoc(neighbourx);
1207 uint y = Util.RegionToWorldLoc(neighboury);
1208 GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, (int)x, (int)y);
1204 1209
1205 if (neighbourRegion == null) 1210 if (neighbourRegion == null)
1206 { 1211 {
@@ -1894,7 +1899,7 @@ namespace OpenSim.Region.Framework.Scenes
1894 { 1899 {
1895 try 1900 try
1896 { 1901 {
1897 double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); 1902 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
1898 if (map == null) 1903 if (map == null)
1899 { 1904 {
1900 // This should be in the Terrain module, but it isn't because 1905 // This should be in the Terrain module, but it isn't because
@@ -1905,7 +1910,7 @@ namespace OpenSim.Region.Framework.Scenes
1905 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); 1910 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
1906 1911
1907 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); 1912 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
1908 Heightmap = new TerrainChannel(m_InitialTerrain); 1913 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
1909 1914
1910 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 1915 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
1911 } 1916 }
@@ -2478,6 +2483,23 @@ namespace OpenSim.Region.Framework.Scenes
2478 EntityTransferModule.Cross(grp, attemptedPosition, silent); 2483 EntityTransferModule.Cross(grp, attemptedPosition, silent);
2479 } 2484 }
2480 2485
2486 // Simple test to see if a position is in the current region.
2487 // Resuming the position is relative to the region so anything outside its bounds.
2488 // Return 'true' if position inside region.
2489 public bool PositionIsInCurrentRegion(Vector3 pos)
2490 {
2491 bool ret = true;
2492 int xx = (int)Math.Floor(pos.X);
2493 int yy = (int)Math.Floor(pos.Y);
2494 if (xx < 0
2495 || xx > RegionInfo.RegionSizeX
2496 || yy < 0
2497 || yy > RegionInfo.RegionSizeY)
2498 ret = false;
2499 return ret;
2500
2501 }
2502
2481 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2503 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
2482 { 2504 {
2483 if (BordersLocked) 2505 if (BordersLocked)
@@ -3994,12 +4016,12 @@ namespace OpenSim.Region.Framework.Scenes
3994 { 4016 {
3995 if (posX < 0) 4017 if (posX < 0)
3996 posX = 0; 4018 posX = 0;
3997 else if (posX >= 256) 4019 else if (posX >= (float)RegionInfo.RegionSizeX)
3998 posX = 255.999f; 4020 posX = (float)RegionInfo.RegionSizeX - 0.001f;
3999 if (posY < 0) 4021 if (posY < 0)
4000 posY = 0; 4022 posY = 0;
4001 else if (posY >= 256) 4023 else if (posY >= (float)RegionInfo.RegionSizeY)
4002 posY = 255.999f; 4024 posY = (float)RegionInfo.RegionSizeY - 0.001f;
4003 4025
4004 reason = String.Empty; 4026 reason = String.Empty;
4005 if (Permissions.IsGod(agentID)) 4027 if (Permissions.IsGod(agentID))
@@ -4293,7 +4315,7 @@ namespace OpenSim.Region.Framework.Scenes
4293 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 4315 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
4294 4316
4295 // TODO: This check should probably be in QueryAccess(). 4317 // TODO: This check should probably be in QueryAccess().
4296 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2); 4318 ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2);
4297 if (nearestParcel == null) 4319 if (nearestParcel == null)
4298 { 4320 {
4299 m_log.InfoFormat( 4321 m_log.InfoFormat(
@@ -4600,13 +4622,22 @@ namespace OpenSim.Region.Framework.Scenes
4600 ScenePresence sp = GetScenePresence(remoteClient.AgentId); 4622 ScenePresence sp = GetScenePresence(remoteClient.AgentId);
4601 if (sp != null) 4623 if (sp != null)
4602 { 4624 {
4603 uint regionX = RegionInfo.RegionLocX; 4625 /*
4604 uint regionY = RegionInfo.RegionLocY; 4626 uint regionX = RegionInfo.LegacyRegionLocX;
4627 uint regionY = RegionInfo.LegacyRegionLocY;
4605 4628
4629 Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
4606 Utils.LongToUInts(regionHandle, out regionX, out regionY); 4630 Utils.LongToUInts(regionHandle, out regionX, out regionY);
4607 4631
4608 int shiftx = (int) regionX - (int) RegionInfo.RegionLocX * (int)Constants.RegionSize; 4632 int shiftx = (int) regionX - (int) RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize;
4609 int shifty = (int) regionY - (int) RegionInfo.RegionLocY * (int)Constants.RegionSize; 4633 int shifty = (int) regionY - (int) RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize;
4634 */
4635
4636 uint regionX, regionY;
4637 Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
4638
4639 int shiftx = (int) regionX - (int)RegionInfo.WorldLocX;
4640 int shifty = (int) regionY - (int)RegionInfo.WorldLocY;
4610 4641
4611 position.X += shiftx; 4642 position.X += shiftx;
4612 position.Y += shifty; 4643 position.Y += shifty;
@@ -4817,7 +4848,7 @@ namespace OpenSim.Region.Framework.Scenes
4817 else 4848 else
4818 { 4849 {
4819 4850
4820 if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize) 4851 if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY)
4821 { 4852 {
4822 // The only time parcel != null when an object is inside a region is when 4853 // 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. 4854 // there is nothing behind the landchannel. IE, no land plugin loaded.
@@ -5478,7 +5509,7 @@ namespace OpenSim.Region.Framework.Scenes
5478 { 5509 {
5479 Vector3 unitDirection = Vector3.Normalize(direction); 5510 Vector3 unitDirection = Vector3.Normalize(direction);
5480 //Making distance to search go through some sane limit of distance 5511 //Making distance to search go through some sane limit of distance
5481 for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) 5512 for (float distance = 0; distance < Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY) * 2; distance += .5f)
5482 { 5513 {
5483 Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); 5514 Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
5484 if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) 5515 if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
@@ -5532,9 +5563,9 @@ namespace OpenSim.Region.Framework.Scenes
5532 int count = 0; 5563 int count = 0;
5533 int avgx = 0; 5564 int avgx = 0;
5534 int avgy = 0; 5565 int avgy = 0;
5535 for (int x = 0; x < Constants.RegionSize; x++) 5566 for (int x = 0; x < RegionInfo.RegionSizeX; x++)
5536 { 5567 {
5537 for (int y = 0; y < Constants.RegionSize; y++) 5568 for (int y = 0; y < RegionInfo.RegionSizeY; y++)
5538 { 5569 {
5539 //Just keep a running average as we check if all the points are inside or not 5570 //Just keep a running average as we check if all the points are inside or not
5540 if (parcel.ContainsPoint(x, y)) 5571 if (parcel.ContainsPoint(x, y))
@@ -5558,31 +5589,33 @@ namespace OpenSim.Region.Framework.Scenes
5558 5589
5559 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) 5590 private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
5560 { 5591 {
5561 float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; 5592 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; 5593 ? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X;
5594 float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2
5595 ? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y;
5563 5596
5564 //find out what vertical edge to go to 5597 //find out what vertical edge to go to
5565 if (xdistance < ydistance) 5598 if (xdistance < ydistance)
5566 { 5599 {
5567 if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) 5600 if (avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2)
5568 { 5601 {
5569 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); 5602 return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
5570 } 5603 }
5571 else 5604 else
5572 { 5605 {
5573 return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); 5606 return GetPositionAtAvatarHeightOrGroundHeight(avatar, RegionInfo.RegionSizeY, avatar.AbsolutePosition.Y);
5574 } 5607 }
5575 } 5608 }
5576 //find out what horizontal edge to go to 5609 //find out what horizontal edge to go to
5577 else 5610 else
5578 { 5611 {
5579 if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) 5612 if (avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2)
5580 { 5613 {
5581 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); 5614 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
5582 } 5615 }
5583 else 5616 else
5584 { 5617 {
5585 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); 5618 return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, RegionInfo.RegionSizeY);
5586 } 5619 }
5587 } 5620 }
5588 } 5621 }