aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data/IRegionData.cs
diff options
context:
space:
mode:
authorMelanie Thielker2010-08-08 17:51:43 +0200
committerMelanie Thielker2010-08-08 17:51:43 +0200
commit1cde77293e993c3a7329ea8e1fa013c8d7b898e5 (patch)
treeba9a009f1ceafe93dd0808d9c316f52164704a1a /OpenSim/Data/IRegionData.cs
parentMerge branch 'careminster-presence-refactor' of ssh://3dhosting.de/var/git/ca... (diff)
downloadopensim-SC-1cde77293e993c3a7329ea8e1fa013c8d7b898e5.zip
opensim-SC-1cde77293e993c3a7329ea8e1fa013c8d7b898e5.tar.gz
opensim-SC-1cde77293e993c3a7329ea8e1fa013c8d7b898e5.tar.bz2
opensim-SC-1cde77293e993c3a7329ea8e1fa013c8d7b898e5.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}