aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/IRegionData.cs
diff options
context:
space:
mode:
authorMelanie Thielker2010-08-08 17:51:43 +0200
committerMelanie2010-08-08 17:37:50 +0100
commit1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3 (patch)
treef779307b0abfa3be35871ea86e06da9a9922cf68 /OpenSim/Data/IRegionData.cs
parentIn my crusade against facelights, I am striking the killing blow. Add a (diff)
downloadopensim-SC_OLD-1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3.zip
opensim-SC_OLD-1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3.tar.gz
opensim-SC_OLD-1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3.tar.bz2
opensim-SC_OLD-1f25b9e8dbf500d22df55fa2a8f7f9b7bf873aa3.tar.xz
Thank you, Marck00, for a patch that implemented region distance sorting
for fallback regions. Applied with changes.
Diffstat (limited to 'OpenSim/Data/IRegionData.cs')
-rw-r--r--OpenSim/Data/IRegionData.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/OpenSim/Data/IRegionData.cs b/OpenSim/Data/IRegionData.cs
index 42533c6..46dc4fb 100644
--- a/OpenSim/Data/IRegionData.cs
+++ b/OpenSim/Data/IRegionData.cs
@@ -79,4 +79,26 @@ namespace OpenSim.Data
79 Authenticate = 256, // Require authentication 79 Authenticate = 256, // Require authentication
80 Hyperlink = 512 // Record represents a HG link 80 Hyperlink = 512 // Record represents a HG link
81 } 81 }
82
83 public class RegionDataDistanceCompare : IComparer<RegionData>
84 {
85 private Vector2 m_origin;
86
87 public RegionDataDistanceCompare(int x, int y)
88 {
89 m_origin = new Vector2(x, y);
90 }
91
92 public int Compare(RegionData regionA, RegionData regionB)
93 {
94 Vector2 vectorA = new Vector2(regionA.posX, regionA.posY);
95 Vector2 vectorB = new Vector2(regionB.posX, regionB.posY);
96 return Math.Sign(VectorDistance(m_origin, vectorA) - VectorDistance(m_origin, vectorB));
97 }
98
99 private float VectorDistance(Vector2 x, Vector2 y)
100 {
101 return (x - y).Length();
102 }
103 }
82} 104}