diff options
author | Teravus Ovares (Dan Olivares) | 2009-08-20 19:24:31 -0400 |
---|---|---|
committer | Teravus Ovares (Dan Olivares) | 2009-08-20 19:24:31 -0400 |
commit | 66c40dd3debf240f88d87feda42e9a48a4ed0ce7 (patch) | |
tree | c21d455710c3445006497e1fc56dfacfe18e9275 | |
parent | Merge branch 'master' of ssh://MyConnection/var/git/opensim (diff) | |
download | opensim-SC_OLD-66c40dd3debf240f88d87feda42e9a48a4ed0ce7.zip opensim-SC_OLD-66c40dd3debf240f88d87feda42e9a48a4ed0ce7.tar.gz opensim-SC_OLD-66c40dd3debf240f88d87feda42e9a48a4ed0ce7.tar.bz2 opensim-SC_OLD-66c40dd3debf240f88d87feda42e9a48a4ed0ce7.tar.xz |
* Switch border cross tests over to the new Border class.
* Use List<Border> for each cardinal to allow for irregular regions.
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.cs | 107 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/ScenePresence.cs | 17 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | 2 |
4 files changed, 116 insertions, 14 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index d1f7a4b..cb4e443 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -81,6 +81,11 @@ 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 List<Border> NorthBorders = new List<Border>(); | ||
85 | public List<Border> EastBorders = new List<Border>(); | ||
86 | public List<Border> SouthBorders = new List<Border>(); | ||
87 | public List<Border> WestBorders = new List<Border>(); | ||
88 | |||
84 | /// <value> | 89 | /// <value> |
85 | /// The scene graph for this scene | 90 | /// The scene graph for this scene |
86 | /// </value> | 91 | /// </value> |
@@ -326,6 +331,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
326 | m_config = config; | 331 | m_config = config; |
327 | 332 | ||
328 | Random random = new Random(); | 333 | Random random = new Random(); |
334 | |||
335 | Border northBorder = new Border(); | ||
336 | northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- | ||
337 | northBorder.CrossDirection = Cardinals.N; | ||
338 | NorthBorders.Add(northBorder); | ||
339 | |||
340 | Border southBorder = new Border(); | ||
341 | southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> | ||
342 | southBorder.CrossDirection = Cardinals.S; | ||
343 | SouthBorders.Add(southBorder); | ||
344 | |||
345 | Border eastBorder = new Border(); | ||
346 | eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- | ||
347 | eastBorder.CrossDirection = Cardinals.E; | ||
348 | EastBorders.Add(eastBorder); | ||
349 | |||
350 | Border westBorder = new Border(); | ||
351 | westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> | ||
352 | westBorder.CrossDirection = Cardinals.W; | ||
353 | WestBorders.Add(westBorder); | ||
354 | |||
355 | |||
329 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); | 356 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); |
330 | m_moduleLoader = moduleLoader; | 357 | m_moduleLoader = moduleLoader; |
331 | m_authenticateHandler = authen; | 358 | m_authenticateHandler = authen; |
@@ -455,6 +482,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | /// <param name="regInfo"></param> | 482 | /// <param name="regInfo"></param> |
456 | public Scene(RegionInfo regInfo) | 483 | public Scene(RegionInfo regInfo) |
457 | { | 484 | { |
485 | Border northBorder = new Border(); | ||
486 | northBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- | ||
487 | northBorder.CrossDirection = Cardinals.N; | ||
488 | NorthBorders.Add(northBorder); | ||
489 | |||
490 | Border southBorder = new Border(); | ||
491 | southBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> | ||
492 | southBorder.CrossDirection = Cardinals.S; | ||
493 | SouthBorders.Add(southBorder); | ||
494 | |||
495 | Border eastBorder = new Border(); | ||
496 | eastBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, (int)Constants.RegionSize); //<--- | ||
497 | eastBorder.CrossDirection = Cardinals.E; | ||
498 | EastBorders.Add(eastBorder); | ||
499 | |||
500 | Border westBorder = new Border(); | ||
501 | westBorder.BorderLine = new Vector3(0, (int)Constants.RegionSize, 0); //---> | ||
502 | westBorder.CrossDirection = Cardinals.W; | ||
503 | WestBorders.Add(westBorder); | ||
504 | |||
458 | m_regInfo = regInfo; | 505 | m_regInfo = regInfo; |
459 | m_eventManager = new EventManager(); | 506 | m_eventManager = new EventManager(); |
460 | } | 507 | } |
@@ -1659,14 +1706,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
1659 | ulong newRegionHandle = 0; | 1706 | ulong newRegionHandle = 0; |
1660 | Vector3 pos = attemptedPosition; | 1707 | Vector3 pos = attemptedPosition; |
1661 | 1708 | ||
1662 | if (attemptedPosition.X > Constants.RegionSize + 0.1f) | 1709 | |
1710 | |||
1711 | if (TestBorderCross(attemptedPosition, Cardinals.E)) | ||
1663 | { | 1712 | { |
1664 | pos.X = ((pos.X - Constants.RegionSize)); | 1713 | pos.X = ((pos.X - Constants.RegionSize)); |
1665 | newRegionHandle | 1714 | newRegionHandle |
1666 | = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); | 1715 | = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); |
1667 | // x + 1 | 1716 | // x + 1 |
1668 | } | 1717 | } |
1669 | else if (attemptedPosition.X < -0.1f) | 1718 | else if (TestBorderCross(attemptedPosition, Cardinals.W)) |
1670 | { | 1719 | { |
1671 | pos.X = ((pos.X + Constants.RegionSize)); | 1720 | pos.X = ((pos.X + Constants.RegionSize)); |
1672 | newRegionHandle | 1721 | newRegionHandle |
@@ -1674,14 +1723,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
1674 | // x - 1 | 1723 | // x - 1 |
1675 | } | 1724 | } |
1676 | 1725 | ||
1677 | if (attemptedPosition.Y > Constants.RegionSize + 0.1f) | 1726 | if (TestBorderCross(attemptedPosition, Cardinals.N)) |
1678 | { | 1727 | { |
1679 | pos.Y = ((pos.Y - Constants.RegionSize)); | 1728 | pos.Y = ((pos.Y - Constants.RegionSize)); |
1680 | newRegionHandle | 1729 | newRegionHandle |
1681 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); | 1730 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); |
1682 | // y + 1 | 1731 | // y + 1 |
1683 | } | 1732 | } |
1684 | else if (attemptedPosition.Y < -0.1f) | 1733 | else if (TestBorderCross(attemptedPosition, Cardinals.S)) |
1685 | { | 1734 | { |
1686 | pos.Y = ((pos.Y + Constants.RegionSize)); | 1735 | pos.Y = ((pos.Y + Constants.RegionSize)); |
1687 | newRegionHandle | 1736 | newRegionHandle |
@@ -1701,6 +1750,56 @@ namespace OpenSim.Region.Framework.Scenes | |||
1701 | } | 1750 | } |
1702 | } | 1751 | } |
1703 | 1752 | ||
1753 | public bool TestBorderCross(Vector3 position, Cardinals border) | ||
1754 | { | ||
1755 | switch (border) | ||
1756 | { | ||
1757 | case Cardinals.N: | ||
1758 | lock (NorthBorders) | ||
1759 | { | ||
1760 | foreach(Border b in NorthBorders) | ||
1761 | { | ||
1762 | if (b.TestCross(position)) | ||
1763 | return true; | ||
1764 | } | ||
1765 | } | ||
1766 | break; | ||
1767 | case Cardinals.E: | ||
1768 | lock (EastBorders) | ||
1769 | { | ||
1770 | foreach (Border b in EastBorders) | ||
1771 | { | ||
1772 | if (b.TestCross(position)) | ||
1773 | return true; | ||
1774 | } | ||
1775 | } | ||
1776 | break; | ||
1777 | case Cardinals.S: | ||
1778 | lock (SouthBorders) | ||
1779 | { | ||
1780 | foreach (Border b in SouthBorders) | ||
1781 | { | ||
1782 | if (b.TestCross(position)) | ||
1783 | return true; | ||
1784 | } | ||
1785 | } | ||
1786 | break; | ||
1787 | case Cardinals.W: | ||
1788 | lock (WestBorders) | ||
1789 | { | ||
1790 | foreach (Border b in WestBorders) | ||
1791 | { | ||
1792 | if (b.TestCross(position)) | ||
1793 | return true; | ||
1794 | } | ||
1795 | } | ||
1796 | break; | ||
1797 | |||
1798 | } | ||
1799 | return false; | ||
1800 | } | ||
1801 | |||
1802 | |||
1704 | /// <summary> | 1803 | /// <summary> |
1705 | /// Move the given scene object into a new region | 1804 | /// Move the given scene object into a new region |
1706 | /// </summary> | 1805 | /// </summary> |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 1b541c4..e5c6bf1 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -264,7 +264,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
264 | { | 264 | { |
265 | Vector3 val = value; | 265 | Vector3 val = value; |
266 | 266 | ||
267 | if ((val.X > 257f || val.X < -1f || val.Y > 257f || val.Y < -1f) && !IsAttachment) | 267 | if ((m_scene.TestBorderCross(val,Cardinals.E) || m_scene.TestBorderCross(val,Cardinals.W) |
268 | || m_scene.TestBorderCross(val, Cardinals.N) || m_scene.TestBorderCross(val, Cardinals.S)) | ||
269 | && !IsAttachment) | ||
268 | { | 270 | { |
269 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); | 271 | m_scene.CrossPrimGroupIntoNewRegion(val, this, true); |
270 | } | 272 | } |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 5281c4f..aae1823 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2830,27 +2830,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2830 | if (!IsInTransit) | 2830 | if (!IsInTransit) |
2831 | { | 2831 | { |
2832 | // Checks if where it's headed exists a region | 2832 | // Checks if where it's headed exists a region |
2833 | if (pos2.X < 0) | 2833 | |
2834 | if (m_scene.TestBorderCross(pos2, Cardinals.W)) | ||
2834 | { | 2835 | { |
2835 | if (pos2.Y < 0) | 2836 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2836 | neighbor = HaveNeighbor(Cardinals.SW, ref fix); | 2837 | neighbor = HaveNeighbor(Cardinals.SW, ref fix); |
2837 | else if (pos2.Y > Constants.RegionSize) | 2838 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2838 | neighbor = HaveNeighbor(Cardinals.NW, ref fix); | 2839 | neighbor = HaveNeighbor(Cardinals.NW, ref fix); |
2839 | else | 2840 | else |
2840 | neighbor = HaveNeighbor(Cardinals.W, ref fix); | 2841 | neighbor = HaveNeighbor(Cardinals.W, ref fix); |
2841 | } | 2842 | } |
2842 | else if (pos2.X > Constants.RegionSize) | 2843 | else if (m_scene.TestBorderCross(pos2, Cardinals.E)) |
2843 | { | 2844 | { |
2844 | if (pos2.Y < 0) | 2845 | if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2845 | neighbor = HaveNeighbor(Cardinals.SE, ref fix); | 2846 | neighbor = HaveNeighbor(Cardinals.SE, ref fix); |
2846 | else if (pos2.Y > Constants.RegionSize) | 2847 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2847 | neighbor = HaveNeighbor(Cardinals.NE, ref fix); | 2848 | neighbor = HaveNeighbor(Cardinals.NE, ref fix); |
2848 | else | 2849 | else |
2849 | neighbor = HaveNeighbor(Cardinals.E, ref fix); | 2850 | neighbor = HaveNeighbor(Cardinals.E, ref fix); |
2850 | } | 2851 | } |
2851 | else if (pos2.Y < 0) | 2852 | else if (m_scene.TestBorderCross(pos2, Cardinals.S)) |
2852 | neighbor = HaveNeighbor(Cardinals.S, ref fix); | 2853 | neighbor = HaveNeighbor(Cardinals.S, ref fix); |
2853 | else if (pos2.Y > Constants.RegionSize) | 2854 | else if (m_scene.TestBorderCross(pos2, Cardinals.N)) |
2854 | neighbor = HaveNeighbor(Cardinals.N, ref fix); | 2855 | neighbor = HaveNeighbor(Cardinals.N, ref fix); |
2855 | 2856 | ||
2856 | // Makes sure avatar does not end up outside region | 2857 | // Makes sure avatar does not end up outside region |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs index 6f77062..272c96e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/BorderTests.cs | |||
@@ -6,7 +6,7 @@ using OpenSim.Region.Framework.Scenes; | |||
6 | 6 | ||
7 | using NUnit.Framework; | 7 | using NUnit.Framework; |
8 | 8 | ||
9 | namespace OpenSim.Region.Framework.Tests | 9 | namespace OpenSim.Region.Framework.Scenes.Tests |
10 | { | 10 | { |
11 | [TestFixture] | 11 | [TestFixture] |
12 | public class BorderTests | 12 | public class BorderTests |