Thank you, Marck00, for a patch that implemented region distance sorting
for fallback regions. Applied with changes.prebuild-update
parent
cd2c7b9ac9
commit
1f25b9e8db
|
@ -79,4 +79,26 @@ namespace OpenSim.Data
|
||||||
Authenticate = 256, // Require authentication
|
Authenticate = 256, // Require authentication
|
||||||
Hyperlink = 512 // Record represents a HG link
|
Hyperlink = 512 // Record represents a HG link
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class RegionDataDistanceCompare : IComparer<RegionData>
|
||||||
|
{
|
||||||
|
private Vector2 m_origin;
|
||||||
|
|
||||||
|
public RegionDataDistanceCompare(int x, int y)
|
||||||
|
{
|
||||||
|
m_origin = new Vector2(x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Compare(RegionData regionA, RegionData regionB)
|
||||||
|
{
|
||||||
|
Vector2 vectorA = new Vector2(regionA.posX, regionA.posY);
|
||||||
|
Vector2 vectorB = new Vector2(regionB.posX, regionB.posY);
|
||||||
|
return Math.Sign(VectorDistance(m_origin, vectorA) - VectorDistance(m_origin, vectorB));
|
||||||
|
}
|
||||||
|
|
||||||
|
private float VectorDistance(Vector2 x, Vector2 y)
|
||||||
|
{
|
||||||
|
return (x - y).Length();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -315,8 +315,11 @@ namespace OpenSim.Data.MSSQL
|
||||||
|
|
||||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||||
{
|
{
|
||||||
// TODO: distance-sort results
|
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||||
return Get((int)RegionFlags.FallbackRegion, scopeID);
|
RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y);
|
||||||
|
regions.Sort(distanceComparer);
|
||||||
|
|
||||||
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionData> GetHyperlinks(UUID scopeID)
|
public List<RegionData> GetHyperlinks(UUID scopeID)
|
||||||
|
|
|
@ -289,8 +289,10 @@ namespace OpenSim.Data.MySQL
|
||||||
|
|
||||||
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
public List<RegionData> GetFallbackRegions(UUID scopeID, int x, int y)
|
||||||
{
|
{
|
||||||
// TODO: distance-sort results
|
List<RegionData> regions = Get((int)RegionFlags.FallbackRegion, scopeID);
|
||||||
return Get((int)RegionFlags.FallbackRegion, scopeID);
|
RegionDataDistanceCompare distanceComparer = new RegionDataDistanceCompare(x, y);
|
||||||
|
regions.Sort(distanceComparer);
|
||||||
|
return regions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<RegionData> GetHyperlinks(UUID scopeID)
|
public List<RegionData> GetHyperlinks(UUID scopeID)
|
||||||
|
|
Loading…
Reference in New Issue