diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/IRegionData.cs | 22 |
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 | } |