aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.cs
diff options
context:
space:
mode:
authorTeravus Ovares (Dan Olivares)2009-08-20 19:24:31 -0400
committerTeravus Ovares (Dan Olivares)2009-08-20 19:24:31 -0400
commit66c40dd3debf240f88d87feda42e9a48a4ed0ce7 (patch)
treec21d455710c3445006497e1fc56dfacfe18e9275 /OpenSim/Region/Framework/Scenes/Scene.cs
parentMerge branch 'master' of ssh://MyConnection/var/git/opensim (diff)
downloadopensim-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.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs107
1 files changed, 103 insertions, 4 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>