aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2013-03-28 00:57:43 +0000
committerJustin Clark-Casey (justincc)2013-03-28 00:57:43 +0000
commitcfb20f09a967ede0a64e7151c3430f74362aec99 (patch)
tree84de083cd3c0d67ca5bbd39943b6a66975d3d4a4 /OpenSim
parentFix problem with megaregions where teleporting into a different region which ... (diff)
downloadopensim-SC_OLD-cfb20f09a967ede0a64e7151c3430f74362aec99.zip
opensim-SC_OLD-cfb20f09a967ede0a64e7151c3430f74362aec99.tar.gz
opensim-SC_OLD-cfb20f09a967ede0a64e7151c3430f74362aec99.tar.bz2
opensim-SC_OLD-cfb20f09a967ede0a64e7151c3430f74362aec99.tar.xz
refactor: combine the checks for megaregion view range into a single place.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs102
1 files changed, 51 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
index 8af236e..f5ffef2 100644
--- a/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
+++ b/OpenSim/Region/CoreModules/Framework/EntityTransfer/EntityTransferModule.cs
@@ -117,6 +117,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
117 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>(); 117 new ExpiringCache<UUID, ExpiringCache<ulong, DateTime>>();
118 118
119 private IEventQueue m_eqModule; 119 private IEventQueue m_eqModule;
120 private IRegionCombinerModule m_regionCombinerModule;
120 121
121 #region ISharedRegionModule 122 #region ISharedRegionModule
122 123
@@ -267,6 +268,7 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
267 return; 268 return;
268 269
269 m_eqModule = Scene.RequestModuleInterface<IEventQueue>(); 270 m_eqModule = Scene.RequestModuleInterface<IEventQueue>();
271 m_regionCombinerModule = Scene.RequestModuleInterface<IRegionCombinerModule>();
270 } 272 }
271 273
272 #endregion 274 #endregion
@@ -1005,41 +1007,16 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1005 1007
1006 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY) 1008 protected virtual bool NeedsNewAgent(float drawdist, uint oldRegionX, uint newRegionX, uint oldRegionY, uint newRegionY)
1007 { 1009 {
1008 Border[] northBorders = Scene.NorthBorders.ToArray(); 1010 if (m_regionCombinerModule != null && m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
1009 Border[] southBorders = Scene.SouthBorders.ToArray();
1010 Border[] eastBorders = Scene.EastBorders.ToArray();
1011 Border[] westBorders = Scene.WestBorders.ToArray();
1012
1013 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
1014 // clear what should be done with a "far view" given that megaregions already extended the
1015 // view to include everything in the megaregion
1016 if (northBorders.Length > 1 || southBorders.Length > 1 || eastBorders.Length > 1 || westBorders.Length > 1)
1017 { 1011 {
1018 Vector2 extent = Vector2.Zero; 1012 Vector2 swCorner, neCorner;
1019 for (int i = 0; i < eastBorders.Length; i++) 1013 GetMegaregionViewRange(out swCorner, out neCorner);
1020 {
1021 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
1022 }
1023 for (int i = 0; i < northBorders.Length; i++)
1024 {
1025 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
1026 }
1027
1028 // Loss of fraction on purpose
1029 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
1030 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
1031
1032 uint startX = oldRegionX - 1;
1033 uint startY = oldRegionY - 1;
1034
1035 uint endX = oldRegionX + (uint)extent.X;
1036 uint endY = oldRegionY + (uint)extent.Y;
1037 1014
1038 m_log.DebugFormat( 1015 m_log.DebugFormat(
1039 "[ENTITY TRANSFER MODULE]: Megaregion view of {0} is from {1},{2} to {3},{4} with new agent check for {5},{6}", 1016 "[ENTITY TRANSFER MODULE]: Megaregion view of {0} is from {1} to {2} with new agent check for {3},{4}",
1040 Scene.Name, startX, startY, endX, endY, newRegionX, newRegionY); 1017 Scene.Name, swCorner, neCorner, newRegionX, newRegionY);
1041 1018
1042 return !(newRegionX >= startX && newRegionX <= endX && newRegionY >= startY && newRegionY <= endY); 1019 return !(newRegionX >= swCorner.X && newRegionX <= neCorner.X && newRegionY >= swCorner.Y && newRegionY <= neCorner.Y);
1043 } 1020 }
1044 else 1021 else
1045 { 1022 {
@@ -1903,6 +1880,37 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1903 } 1880 }
1904 1881
1905 /// <summary> 1882 /// <summary>
1883 /// Gets the range considered in view of this megaregion (assuming this is a megaregion).
1884 /// </summary>
1885 /// <remarks>Expressed in 256m units</remarks>
1886 /// <param name='swCorner'></param>
1887 /// <param name='neCorner'></param>
1888 private void GetMegaregionViewRange(out Vector2 swCorner, out Vector2 neCorner)
1889 {
1890 Border[] northBorders = Scene.NorthBorders.ToArray();
1891 Border[] eastBorders = Scene.EastBorders.ToArray();
1892
1893 Vector2 extent = Vector2.Zero;
1894 for (int i = 0; i < eastBorders.Length; i++)
1895 {
1896 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
1897 }
1898 for (int i = 0; i < northBorders.Length; i++)
1899 {
1900 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
1901 }
1902
1903 // Loss of fraction on purpose
1904 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
1905 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
1906
1907 swCorner.X = Scene.RegionInfo.RegionLocX - 1;
1908 swCorner.Y = Scene.RegionInfo.RegionLocY - 1;
1909 neCorner.X = Scene.RegionInfo.RegionLocX + extent.X;
1910 neCorner.Y = Scene.RegionInfo.RegionLocY + extent.Y;
1911 }
1912
1913 /// <summary>
1906 /// Return the list of regions that are considered to be neighbours to the given scene. 1914 /// Return the list of regions that are considered to be neighbours to the given scene.
1907 /// </summary> 1915 /// </summary>
1908 /// <param name="pScene"></param> 1916 /// <param name="pScene"></param>
@@ -1922,8 +1930,9 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1922 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't 1930 // Leaving this as a "megaregions" computation vs "non-megaregions" computation; it isn't
1923 // clear what should be done with a "far view" given that megaregions already extended the 1931 // clear what should be done with a "far view" given that megaregions already extended the
1924 // view to include everything in the megaregion 1932 // view to include everything in the megaregion
1925 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 1933 if (m_regionCombinerModule == null || !m_regionCombinerModule.IsRootForMegaregion(Scene.RegionInfo.RegionID))
1926 { 1934 {
1935 Console.WriteLine("NOT MEGA");
1927 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance; 1936 int dd = avatar.DrawDistance < Constants.RegionSize ? (int)Constants.RegionSize : (int)avatar.DrawDistance;
1928 1937
1929 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2); 1938 int startX = (int)pRegionLocX * (int)Constants.RegionSize - dd + (int)(Constants.RegionSize/2);
@@ -1940,27 +1949,18 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
1940 } 1949 }
1941 else 1950 else
1942 { 1951 {
1943 Vector2 extent = Vector2.Zero; 1952 Console.WriteLine("MEGA");
1944 for (int i = 0; i < eastBorders.Length; i++) 1953 Vector2 swCorner, neCorner;
1945 { 1954 GetMegaregionViewRange(out swCorner, out neCorner);
1946 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
1947 }
1948 for (int i = 0; i < northBorders.Length; i++)
1949 {
1950 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
1951 }
1952
1953 // Loss of fraction on purpose
1954 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
1955 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
1956
1957 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
1958 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
1959 1955
1960 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; 1956 List<GridRegion> neighbours
1961 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; 1957 = pScene.GridService.GetRegionRange(
1958 m_regionInfo.ScopeID,
1959 (int)swCorner.X * (int)Constants.RegionSize,
1960 (int)neCorner.X * (int)Constants.RegionSize,
1961 (int)swCorner.Y * (int)Constants.RegionSize,
1962 (int)neCorner.Y * (int)Constants.RegionSize);
1962 1963
1963 List<GridRegion> neighbours = pScene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
1964 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); 1964 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
1965 1965
1966 return neighbours; 1966 return neighbours;