aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/Constants.cs5
-rw-r--r--OpenSim/Framework/Util.cs43
2 files changed, 47 insertions, 1 deletions
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 3468cea..3ba264c 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -38,7 +38,10 @@ namespace OpenSim.Framework
38 // This could be a parameters but, really, a region of greater than this is pretty unmanageable 38 // This could be a parameters but, really, a region of greater than this is pretty unmanageable
39 public const uint MaximumRegionSize = 8192; 39 public const uint MaximumRegionSize = 8192;
40 40
41 public const byte TerrainPatchSize = 16; 41 // Since terrain is stored in 16x16 heights, regions must be a multiple of this number and that is the minimum
42 public const int MinRegionSize = 16;
43 public const int TerrainPatchSize = 16;
44
42 public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f"; 45 public const string DefaultTexture = "89556747-24cb-43ed-920b-47caed15465f";
43 46
44 public enum EstateAccessCodex : uint 47 public enum EstateAccessCodex : uint
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index e8dfec1..b84673b 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -333,6 +333,49 @@ namespace OpenSim.Framework
333 return Utils.UIntsToLong(X, Y); 333 return Utils.UIntsToLong(X, Y);
334 } 334 }
335 335
336 // Regions are identified with a 'handle' made up of its region coordinates packed into a ulong.
337 // Several places rely on the ability to extract a region's location from its handle.
338 // Note the location is in 'world coordinates' (see below).
339 // Region handles are based on the lowest coordinate of the region so trim the passed x,y to be the regions 0,0.
340 public static ulong RegionWorldLocToHandle(uint X, uint Y)
341 {
342 return Utils.UIntsToLong(X, Y);
343 }
344
345 public static ulong RegionLocToHandle(uint X, uint Y)
346 {
347 return Utils.UIntsToLong(Util.RegionToWorldLoc(X), Util.RegionToWorldLoc(Y));
348 }
349
350 public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y)
351 {
352 X = (uint)(handle >> 32);
353 Y = (uint)(handle & (ulong)uint.MaxValue);
354 }
355
356 public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y)
357 {
358 uint worldX, worldY;
359 RegionHandleToWorldLoc(handle, out worldX, out worldY);
360 X = WorldToRegionLoc(worldX);
361 Y = WorldToRegionLoc(worldY);
362 }
363
364 // A region location can be 'world coordinates' (meters from zero) or 'region coordinates'
365 // (number of regions from zero). This measurement of regions relies on the legacy 256 region size.
366 // These routines exist to make what is being converted explicit so the next person knows what was meant.
367 // Convert a region's 'world coordinate' to its 'region coordinate'.
368 public static uint WorldToRegionLoc(uint worldCoord)
369 {
370 return worldCoord / Constants.RegionSize;
371 }
372
373 // Convert a region's 'region coordinate' to its 'world coordinate'.
374 public static uint RegionToWorldLoc(uint regionCoord)
375 {
376 return regionCoord * Constants.RegionSize;
377 }
378
336 public static T Clamp<T>(T x, T min, T max) 379 public static T Clamp<T>(T x, T min, T max)
337 where T : IComparable<T> 380 where T : IComparable<T>
338 { 381 {