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.cs354
1 files changed, 335 insertions, 19 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 6118a70..3e573cf 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -81,6 +81,13 @@ namespace OpenSim.Region.Framework.Scenes
81 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>(); 81 protected List<RegionInfo> m_regionRestartNotifyList = new List<RegionInfo>();
82 protected List<RegionInfo> m_neighbours = new List<RegionInfo>(); 82 protected List<RegionInfo> m_neighbours = new List<RegionInfo>();
83 83
84 public volatile bool BordersLocked = false;
85
86 public List<Border> NorthBorders = new List<Border>();
87 public List<Border> EastBorders = new List<Border>();
88 public List<Border> SouthBorders = new List<Border>();
89 public List<Border> WestBorders = new List<Border>();
90
84 /// <value> 91 /// <value>
85 /// The scene graph for this scene 92 /// The scene graph for this scene
86 /// </value> 93 /// </value>
@@ -326,6 +333,31 @@ namespace OpenSim.Region.Framework.Scenes
326 m_config = config; 333 m_config = config;
327 334
328 Random random = new Random(); 335 Random random = new Random();
336
337 BordersLocked = true;
338
339 Border northBorder = new Border();
340 northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
341 northBorder.CrossDirection = Cardinals.N;
342 NorthBorders.Add(northBorder);
343
344 Border southBorder = new Border();
345 southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
346 southBorder.CrossDirection = Cardinals.S;
347 SouthBorders.Add(southBorder);
348
349 Border eastBorder = new Border();
350 eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
351 eastBorder.CrossDirection = Cardinals.E;
352 EastBorders.Add(eastBorder);
353
354 Border westBorder = new Border();
355 westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
356 westBorder.CrossDirection = Cardinals.W;
357 WestBorders.Add(westBorder);
358
359 BordersLocked = false;
360
329 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 361 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
330 m_moduleLoader = moduleLoader; 362 m_moduleLoader = moduleLoader;
331 m_authenticateHandler = authen; 363 m_authenticateHandler = authen;
@@ -455,6 +487,28 @@ namespace OpenSim.Region.Framework.Scenes
455 /// <param name="regInfo"></param> 487 /// <param name="regInfo"></param>
456 public Scene(RegionInfo regInfo) 488 public Scene(RegionInfo regInfo)
457 { 489 {
490 BordersLocked = true;
491 Border northBorder = new Border();
492 northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
493 northBorder.CrossDirection = Cardinals.N;
494 NorthBorders.Add(northBorder);
495
496 Border southBorder = new Border();
497 southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
498 southBorder.CrossDirection = Cardinals.S;
499 SouthBorders.Add(southBorder);
500
501 Border eastBorder = new Border();
502 eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<---
503 eastBorder.CrossDirection = Cardinals.E;
504 EastBorders.Add(eastBorder);
505
506 Border westBorder = new Border();
507 westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //--->
508 westBorder.CrossDirection = Cardinals.W;
509 WestBorders.Add(westBorder);
510 BordersLocked = false;
511
458 m_regInfo = regInfo; 512 m_regInfo = regInfo;
459 m_eventManager = new EventManager(); 513 m_eventManager = new EventManager();
460 } 514 }
@@ -1659,35 +1713,86 @@ namespace OpenSim.Region.Framework.Scenes
1659 ulong newRegionHandle = 0; 1713 ulong newRegionHandle = 0;
1660 Vector3 pos = attemptedPosition; 1714 Vector3 pos = attemptedPosition;
1661 1715
1662 if (attemptedPosition.X > Constants.RegionSize + 0.1f) 1716 if (TestBorderCross(attemptedPosition, Cardinals.W))
1663 { 1717 {
1664 pos.X = ((pos.X - Constants.RegionSize)); 1718 if (TestBorderCross(attemptedPosition, Cardinals.S))
1665 newRegionHandle 1719 {
1666 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1720 //Border crossedBorderx = GetCrossedBorder(attemptedPosition,Cardinals.W);
1667 // x + 1 1721 //Border crossedBordery = GetCrossedBorder(attemptedPosition, Cardinals.S);
1722 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
1723 pos.X = ((pos.X + Constants.RegionSize));
1724 pos.Y = ((pos.Y + Constants.RegionSize));
1725 newRegionHandle
1726 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize),
1727 (uint)((thisy - 1) * Constants.RegionSize));
1728 // x - 1
1729 // y - 1
1730 }
1731 else if (TestBorderCross(attemptedPosition, Cardinals.N))
1732 {
1733 pos.X = ((pos.X + Constants.RegionSize));
1734 pos.Y = ((pos.Y - Constants.RegionSize));
1735 newRegionHandle
1736 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize),
1737 (uint)((thisy + 1) * Constants.RegionSize));
1738 // x - 1
1739 // y + 1
1740 }
1741 else
1742 {
1743 pos.X = ((pos.X + Constants.RegionSize));
1744 newRegionHandle
1745 = Util.UIntsToLong((uint) ((thisx - 1)*Constants.RegionSize),
1746 (uint) (thisy*Constants.RegionSize));
1747 // x - 1
1748 }
1668 } 1749 }
1669 else if (attemptedPosition.X < -0.1f) 1750 else if (TestBorderCross(attemptedPosition, Cardinals.E))
1751 {
1752 if (TestBorderCross(attemptedPosition, Cardinals.S))
1753 {
1754 pos.X = ((pos.X - Constants.RegionSize));
1755 pos.Y = ((pos.Y + Constants.RegionSize));
1756 newRegionHandle
1757 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize),
1758 (uint)((thisy - 1) * Constants.RegionSize));
1759 // x + 1
1760 // y - 1
1761 }
1762 else if (TestBorderCross(attemptedPosition, Cardinals.N))
1763 {
1764 pos.X = ((pos.X - Constants.RegionSize));
1765 pos.Y = ((pos.Y - Constants.RegionSize));
1766 newRegionHandle
1767 = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize),
1768 (uint)((thisy + 1) * Constants.RegionSize));
1769 // x + 1
1770 // y + 1
1771 }
1772 else
1773 {
1774 pos.X = ((pos.X - Constants.RegionSize));
1775 newRegionHandle
1776 = Util.UIntsToLong((uint) ((thisx + 1)*Constants.RegionSize),
1777 (uint) (thisy*Constants.RegionSize));
1778 // x + 1
1779 }
1780 }
1781 else if (TestBorderCross(attemptedPosition, Cardinals.S))
1670 { 1782 {
1671 pos.X = ((pos.X + Constants.RegionSize)); 1783 pos.Y = ((pos.Y + Constants.RegionSize));
1672 newRegionHandle 1784 newRegionHandle
1673 = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); 1785 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize));
1674 // x - 1 1786 // y - 1
1675 } 1787 }
1676 1788 else if (TestBorderCross(attemptedPosition, Cardinals.N))
1677 if (attemptedPosition.Y > Constants.RegionSize + 0.1f)
1678 { 1789 {
1790
1679 pos.Y = ((pos.Y - Constants.RegionSize)); 1791 pos.Y = ((pos.Y - Constants.RegionSize));
1680 newRegionHandle 1792 newRegionHandle
1681 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); 1793 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize));
1682 // y + 1 1794 // y + 1
1683 } 1795 }
1684 else if (attemptedPosition.Y < -0.1f)
1685 {
1686 pos.Y = ((pos.Y + Constants.RegionSize));
1687 newRegionHandle
1688 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize));
1689 // y - 1
1690 }
1691 1796
1692 // Offset the positions for the new region across the border 1797 // Offset the positions for the new region across the border
1693 Vector3 oldGroupPosition = grp.RootPart.GroupPosition; 1798 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
@@ -1701,6 +1806,186 @@ namespace OpenSim.Region.Framework.Scenes
1701 } 1806 }
1702 } 1807 }
1703 1808
1809 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
1810 {
1811 if (BordersLocked)
1812 {
1813 switch (gridline)
1814 {
1815 case Cardinals.N:
1816 lock (NorthBorders)
1817 {
1818 foreach (Border b in NorthBorders)
1819 {
1820 if (b.TestCross(position))
1821 return b;
1822 }
1823 }
1824 break;
1825 case Cardinals.S:
1826 lock (SouthBorders)
1827 {
1828 foreach (Border b in SouthBorders)
1829 {
1830 if (b.TestCross(position))
1831 return b;
1832 }
1833 }
1834
1835 break;
1836 case Cardinals.E:
1837 lock (EastBorders)
1838 {
1839 foreach (Border b in EastBorders)
1840 {
1841 if (b.TestCross(position))
1842 return b;
1843 }
1844 }
1845
1846 break;
1847 case Cardinals.W:
1848
1849 lock (WestBorders)
1850 {
1851 foreach (Border b in WestBorders)
1852 {
1853 if (b.TestCross(position))
1854 return b;
1855 }
1856 }
1857 break;
1858
1859 }
1860 }
1861 else
1862 {
1863 switch (gridline)
1864 {
1865 case Cardinals.N:
1866 foreach (Border b in NorthBorders)
1867 {
1868 if (b.TestCross(position))
1869 return b;
1870 }
1871
1872 break;
1873 case Cardinals.S:
1874 foreach (Border b in SouthBorders)
1875 {
1876 if (b.TestCross(position))
1877 return b;
1878 }
1879 break;
1880 case Cardinals.E:
1881 foreach (Border b in EastBorders)
1882 {
1883 if (b.TestCross(position))
1884 return b;
1885 }
1886
1887 break;
1888 case Cardinals.W:
1889 foreach (Border b in WestBorders)
1890 {
1891 if (b.TestCross(position))
1892 return b;
1893 }
1894 break;
1895
1896 }
1897 }
1898
1899
1900 return null;
1901 }
1902
1903 public bool TestBorderCross(Vector3 position, Cardinals border)
1904 {
1905 if (BordersLocked)
1906 {
1907 switch (border)
1908 {
1909 case Cardinals.N:
1910 lock (NorthBorders)
1911 {
1912 foreach (Border b in NorthBorders)
1913 {
1914 if (b.TestCross(position))
1915 return true;
1916 }
1917 }
1918 break;
1919 case Cardinals.E:
1920 lock (EastBorders)
1921 {
1922 foreach (Border b in EastBorders)
1923 {
1924 if (b.TestCross(position))
1925 return true;
1926 }
1927 }
1928 break;
1929 case Cardinals.S:
1930 lock (SouthBorders)
1931 {
1932 foreach (Border b in SouthBorders)
1933 {
1934 if (b.TestCross(position))
1935 return true;
1936 }
1937 }
1938 break;
1939 case Cardinals.W:
1940 lock (WestBorders)
1941 {
1942 foreach (Border b in WestBorders)
1943 {
1944 if (b.TestCross(position))
1945 return true;
1946 }
1947 }
1948 break;
1949 }
1950 }
1951 else
1952 {
1953 switch (border)
1954 {
1955 case Cardinals.N:
1956 foreach (Border b in NorthBorders)
1957 {
1958 if (b.TestCross(position))
1959 return true;
1960 }
1961 break;
1962 case Cardinals.E:
1963 foreach (Border b in EastBorders)
1964 {
1965 if (b.TestCross(position))
1966 return true;
1967 }
1968 break;
1969 case Cardinals.S:
1970 foreach (Border b in SouthBorders)
1971 {
1972 if (b.TestCross(position))
1973 return true;
1974 }
1975 break;
1976 case Cardinals.W:
1977 foreach (Border b in WestBorders)
1978 {
1979 if (b.TestCross(position))
1980 return true;
1981 }
1982 break;
1983 }
1984 }
1985 return false;
1986 }
1987
1988
1704 /// <summary> 1989 /// <summary>
1705 /// Move the given scene object into a new region 1990 /// Move the given scene object into a new region
1706 /// </summary> 1991 /// </summary>
@@ -3063,16 +3348,47 @@ namespace OpenSim.Region.Framework.Scenes
3063 3348
3064 if (sp != null) 3349 if (sp != null)
3065 { 3350 {
3351 uint regionX = m_regInfo.RegionLocX;
3352 uint regionY = m_regInfo.RegionLocY;
3353
3354 Utils.LongToUInts(regionHandle, out regionX, out regionY);
3355
3356 int shiftx = (int) regionX - (int) m_regInfo.RegionLocX * (int)Constants.RegionSize;
3357 int shifty = (int)regionY - (int)m_regInfo.RegionLocY * (int)Constants.RegionSize;
3358
3359 position.X += shiftx;
3360 position.Y += shifty;
3361
3362 bool result = false;
3363
3364 if (TestBorderCross(position,Cardinals.N))
3365 result = true;
3366
3367 if (TestBorderCross(position, Cardinals.S))
3368 result = true;
3369
3370 if (TestBorderCross(position, Cardinals.E))
3371 result = true;
3372
3373 if (TestBorderCross(position, Cardinals.W))
3374 result = true;
3375
3376 // bordercross if position is outside of region
3377
3378 if (!result)
3379 regionHandle = m_regInfo.RegionHandle;
3380
3066 if (m_teleportModule != null) 3381 if (m_teleportModule != null)
3067 { 3382 {
3068 m_teleportModule.RequestTeleportToLocation(sp, regionHandle, 3383 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
3069 position, lookAt, teleportFlags); 3384 position, lookAt, teleportFlags);
3070 } 3385 }
3071 else 3386 else
3072 { 3387 {
3073 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3388 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle,
3074 position, lookAt, teleportFlags); 3389 position, lookAt, teleportFlags);
3075 } 3390 }
3391
3076 } 3392 }
3077 } 3393 }
3078 3394