varregion: elimination of Constants.RegionSize from all over OpenSimulator.

Routines in Util to compute region world coordinates from region coordinates
as well as the conversion to and from region handles. These routines have
replaced a lot of math scattered throughout the simulator.
Should be no functional changes.
varregion
Robert Adams 2013-11-08 20:53:37 -08:00
parent a7a837550e
commit beeec1c467
24 changed files with 156 additions and 90 deletions

View File

@ -54,12 +54,12 @@ namespace OpenSim.Data
/// <summary>
/// Return the x-coordinate of this region.
/// </summary>
public int coordX { get { return posX / (int)Constants.RegionSize; } }
public int coordX { get { return (int)Util.WorldToRegionLoc((uint)posX); } }
/// <summary>
/// Return the y-coordinate of this region.
/// </summary>
public int coordY { get { return posY / (int)Constants.RegionSize; } }
public int coordY { get { return (int)Util.WorldToRegionLoc((uint)posY); } }
public Dictionary<string, object> Data;
}

View File

@ -408,8 +408,8 @@ namespace OpenSim.Framework
}
ClearTaint();
m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size={<{3},{4}>. CompFact={5}", LogHeader,
hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
m_log.InfoFormat("{0} Read compressed 2d heightmap. Heightmap size=<{1},{2}>. Region size=<{3},{4}>. CompFact={5}",
LogHeader, hmSizeX, hmSizeY, SizeX, SizeY, hmCompressionFactor);
}
}
}

View File

@ -161,14 +161,18 @@ namespace OpenSim.Framework
{
get
{
return Utils.UIntsToLong(
m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize);
return Util.RegionWorldLocToHandle(Util.RegionToWorldLoc(m_homeRegionX), Util.RegionToWorldLoc(m_homeRegionY));
// return Utils.UIntsToLong( m_homeRegionX * (uint)Constants.RegionSize, m_homeRegionY * (uint)Constants.RegionSize);
}
set
{
m_homeRegionX = (uint) (value >> 40);
m_homeRegionY = (((uint) (value)) >> 8);
uint regionWorldLocX, regionWorldLocY;
Util.RegionHandleToWorldLoc(value, out regionWorldLocX, out regionWorldLocY);
m_homeRegionX = Util.WorldToRegionLoc(regionWorldLocX);
m_homeRegionY = Util.WorldToRegionLoc(regionWorldLocY);
// m_homeRegionX = (uint) (value >> 40);
// m_homeRegionY = (((uint) (value)) >> 8);
}
}

View File

@ -333,6 +333,43 @@ namespace OpenSim.Framework
return Utils.UIntsToLong(X, Y);
}
// Regions are identified with a 'handle' made up of its region coordinates packed into a ulong.
// Several places rely on the ability to extract a region's location from its handle.
// Note the location is in 'world coordinates' (see below).
public static ulong RegionWorldLocToHandle(uint X, uint Y)
{
return Utils.UIntsToLong(X, Y);
}
public static void RegionHandleToWorldLoc(ulong handle, out uint X, out uint Y)
{
X = (uint)(handle >> 32);
Y = (uint)(handle & (ulong)uint.MaxValue);
}
public static void RegionHandleToRegionLoc(ulong handle, out uint X, out uint Y)
{
uint worldX, worldY;
RegionHandleToWorldLoc(handle, out worldX, out worldY);
X = WorldToRegionLoc(worldX);
Y = WorldToRegionLoc(worldY);
}
// A region location can be 'world coordinates' (meters from zero) or 'region coordinates'
// (number of regions from zero). This measurement of regions relies on the legacy 256 region size.
// These routines exist to make what is being converted explicit so the next person knows what was meant.
// Convert a region's 'world coordinate' to its 'region coordinate'.
public static uint WorldToRegionLoc(uint worldCoord)
{
return worldCoord / Constants.RegionSize;
}
// Convert a region's 'region coordinate' to its 'world coordinate'.
public static uint RegionToWorldLoc(uint regionCoord)
{
return regionCoord * Constants.RegionSize;
}
public static T Clamp<T>(T x, T min, T max)
where T : IComparable<T>
{

View File

@ -269,9 +269,7 @@ namespace OpenSim.Region.CoreModules.Framework
foreach (KeyValuePair<ulong, string> kvp in m_childrenSeeds[agentID])
{
uint x, y;
Utils.LongToUInts(kvp.Key, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
}
}

View File

@ -268,7 +268,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions)
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, r.RegionLocX / Constants.RegionSize, r.RegionLocY / Constants.RegionSize);
caps.AppendFormat(" {0} @ {1}-{2}\n", r.RegionName, Util.WorldToRegionLoc((uint)r.RegionLocX), Util.WorldToRegionLoc((uint)r.RegionLocY));
}
}

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return;
m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}",
m_scene.RegionInfo.RegionName, otherRegion.RegionName, otherRegion.RegionLocX / Constants.RegionSize, otherRegion.RegionLocY / Constants.RegionSize);
m_scene.RegionInfo.RegionName, otherRegion.RegionName, Util.WorldToRegionLoc((uint)otherRegion.RegionLocX), Util.WorldToRegionLoc((uint)otherRegion.RegionLocY));
m_neighbours[otherRegion.RegionHandle] = otherRegion;
}
@ -86,7 +86,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
{
uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
uint ysnap = (uint)(y / Constants.RegionSize) * Constants.RegionSize;
ulong handle = Utils.UIntsToLong(xsnap, ysnap);
ulong handle = Util.RegionWorldLocToHandle(xsnap, ysnap);
if (m_neighbours.ContainsKey(handle))
return m_neighbours[handle];

View File

@ -1571,10 +1571,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions
float X = position.X;
float Y = position.Y;
if (X > ((int)Constants.RegionSize - 1))
X = ((int)Constants.RegionSize - 1);
if (Y > ((int)Constants.RegionSize - 1))
Y = ((int)Constants.RegionSize - 1);
if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1))
X = ((int)m_scene.RegionInfo.RegionSizeX - 1);
if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1))
Y = ((int)m_scene.RegionInfo.RegionSizeY - 1);
if (X < 0)
X = 0;
if (Y < 0)

View File

@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
for (y = 0; y < map.Height; y++)
{
map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10;
double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01;
double spherFac = TerrainUtil.SphericalFactor(x, y, map.Width / 2, map.Height / 2, 50) * 0.01;
if (map[x, y] < spherFac)
{
map[x, y] = spherFac;

View File

@ -1099,8 +1099,11 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>True after all operations complete, throws exceptions otherwise.</returns>
public override void OtherRegionUp(GridRegion otherRegion)
{
uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
// uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
// uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
uint xcell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocX);
uint ycell = Util.WorldToRegionLoc((uint)otherRegion.RegionLocY);
//m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
// RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
@ -1198,9 +1201,11 @@ namespace OpenSim.Region.Framework.Scenes
else if (dir > 3 && dir < 7) // Heading Sout
neighboury--;
int x = (int)(neighbourx * Constants.RegionSize);
int y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, x, y);
// int x = (int)(neighbourx * Constants.RegionSize);
// int y = (int)(neighboury * Constants.RegionSize);
uint x = Util.RegionToWorldLoc(neighbourx);
uint y = Util.RegionToWorldLoc(neighboury);
GridRegion neighbourRegion = GridService.GetRegionByPosition(RegionInfo.ScopeID, (int)x, (int)y);
if (neighbourRegion == null)
{
@ -4293,7 +4298,7 @@ namespace OpenSim.Region.Framework.Scenes
"[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
// TODO: This check should probably be in QueryAccess().
ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, Constants.RegionSize / 2, Constants.RegionSize / 2);
ILandObject nearestParcel = GetNearestAllowedParcel(cAgentData.AgentID, RegionInfo.RegionSizeX / 2, RegionInfo.RegionSizeY / 2);
if (nearestParcel == null)
{
m_log.InfoFormat(
@ -4600,13 +4605,22 @@ namespace OpenSim.Region.Framework.Scenes
ScenePresence sp = GetScenePresence(remoteClient.AgentId);
if (sp != null)
{
/*
uint regionX = RegionInfo.LegacyRegionLocX;
uint regionY = RegionInfo.LegacyRegionLocY;
Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
Utils.LongToUInts(regionHandle, out regionX, out regionY);
int shiftx = (int) regionX - (int) RegionInfo.LegacyRegionLocX * (int)Constants.RegionSize;
int shifty = (int) regionY - (int) RegionInfo.LegacyRegionLocY * (int)Constants.RegionSize;
*/
uint regionX, regionY;
Util.RegionHandleToWorldLoc(regionHandle, out regionX, out regionY);
int shiftx = (int) regionX - (int)RegionInfo.RegionWorldLocX;
int shifty = (int) regionY - (int)RegionInfo.RegionWorldLocY;
position.X += shiftx;
position.Y += shifty;
@ -4817,7 +4831,7 @@ namespace OpenSim.Region.Framework.Scenes
else
{
if (pos.X > 0f && pos.X < Constants.RegionSize && pos.Y > 0f && pos.Y < Constants.RegionSize)
if (pos.X > 0f && pos.X < RegionInfo.RegionSizeX && pos.Y > 0f && pos.Y < RegionInfo.RegionSizeY)
{
// The only time parcel != null when an object is inside a region is when
// there is nothing behind the landchannel. IE, no land plugin loaded.
@ -5478,7 +5492,7 @@ namespace OpenSim.Region.Framework.Scenes
{
Vector3 unitDirection = Vector3.Normalize(direction);
//Making distance to search go through some sane limit of distance
for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f)
for (float distance = 0; distance < Math.Max(RegionInfo.RegionSizeX, RegionInfo.RegionSizeY) * 2; distance += .5f)
{
Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance));
if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y))
@ -5532,9 +5546,9 @@ namespace OpenSim.Region.Framework.Scenes
int count = 0;
int avgx = 0;
int avgy = 0;
for (int x = 0; x < Constants.RegionSize; x++)
for (int x = 0; x < RegionInfo.RegionSizeX; x++)
{
for (int y = 0; y < Constants.RegionSize; y++)
for (int y = 0; y < RegionInfo.RegionSizeY; y++)
{
//Just keep a running average as we check if all the points are inside or not
if (parcel.ContainsPoint(x, y))
@ -5558,31 +5572,33 @@ namespace OpenSim.Region.Framework.Scenes
private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar)
{
float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X;
float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y;
float xdistance = avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2
? avatar.AbsolutePosition.X : RegionInfo.RegionSizeX - avatar.AbsolutePosition.X;
float ydistance = avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2
? avatar.AbsolutePosition.Y : RegionInfo.RegionSizeY - avatar.AbsolutePosition.Y;
//find out what vertical edge to go to
if (xdistance < ydistance)
{
if (avatar.AbsolutePosition.X < Constants.RegionSize / 2)
if (avatar.AbsolutePosition.X < RegionInfo.RegionSizeX / 2)
{
return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y);
}
else
{
return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y);
return GetPositionAtAvatarHeightOrGroundHeight(avatar, RegionInfo.RegionSizeY, avatar.AbsolutePosition.Y);
}
}
//find out what horizontal edge to go to
else
{
if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2)
if (avatar.AbsolutePosition.Y < RegionInfo.RegionSizeY / 2)
{
return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f);
}
else
{
return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize);
return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, RegionInfo.RegionSizeY);
}
}
}

View File

@ -92,7 +92,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.DebugFormat(
"[SCENE COMMUNICATION SERVICE]: Region {0} successfully informed neighbour {1} at {2}-{3} that it is up",
m_scene.Name, neighbour.RegionName, x / Constants.RegionSize, y / Constants.RegionSize);
m_scene.Name, neighbour.RegionName, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
m_scene.EventManager.TriggerOnRegionUp(neighbour);
}
@ -100,7 +100,7 @@ namespace OpenSim.Region.Framework.Scenes
{
m_log.WarnFormat(
"[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.",
m_scene.Name, x / Constants.RegionSize, y / Constants.RegionSize);
m_scene.Name, Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
}
}

View File

@ -707,9 +707,8 @@ namespace OpenSim.Region.Framework.Scenes
foreach (ulong handle in seeds.Keys)
{
uint x, y;
Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Util.RegionHandleToRegionLoc(handle, out x, out y);
if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.LegacyRegionLocX, y, Scene.RegionInfo.LegacyRegionLocY))
{
old.Add(handle);
@ -731,9 +730,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
{
uint x, y;
Utils.LongToUInts(kvp.Key, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
}
}
@ -971,7 +968,7 @@ namespace OpenSim.Region.Framework.Scenes
float posZLimit = 0;
if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize)
if (pos.X < m_scene.RegionInfo.RegionSizeX && pos.Y < m_scene.RegionInfo.RegionSizeY)
posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
float newPosZ = posZLimit + localAVHeight / 2;
@ -2076,7 +2073,7 @@ namespace OpenSim.Region.Framework.Scenes
if (regionCombinerModule != null)
regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
else
regionSize = new Vector2(Constants.RegionSize);
regionSize = new Vector2(m_scene.RegionInfo.RegionSizeX, m_scene.RegionInfo.RegionSizeY);
if (pos.X < 0 || pos.X >= regionSize.X
|| pos.Y < 0 || pos.Y >= regionSize.Y
@ -2106,7 +2103,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
targetScene = m_scene;
float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % Constants.RegionSize), (int)(pos.Y % Constants.RegionSize)];
float terrainHeight = (float)targetScene.Heightmap[(int)(pos.X % regionSize.X), (int)(pos.Y % regionSize.Y)];
pos.Z = Math.Max(terrainHeight, pos.Z);
// Fudge factor. It appears that if one clicks "go here" on a piece of ground, the go here request is
@ -3199,11 +3196,11 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 pos = AbsolutePosition;
if (AbsolutePosition.X < 0)
pos.X += Velocity.X * 2;
else if (AbsolutePosition.X > Constants.RegionSize)
else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
pos.X -= Velocity.X * 2;
if (AbsolutePosition.Y < 0)
pos.Y += Velocity.Y * 2;
else if (AbsolutePosition.Y > Constants.RegionSize)
else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
pos.Y -= Velocity.Y * 2;
Velocity = Vector3.Zero;
AbsolutePosition = pos;
@ -3226,11 +3223,11 @@ namespace OpenSim.Region.Framework.Scenes
Vector3 pos = AbsolutePosition;
if (AbsolutePosition.X < 0)
pos.X += Velocity.X * 2;
else if (AbsolutePosition.X > Constants.RegionSize)
else if (AbsolutePosition.X > m_scene.RegionInfo.RegionSizeX)
pos.X -= Velocity.X * 2;
if (AbsolutePosition.Y < 0)
pos.Y += Velocity.Y * 2;
else if (AbsolutePosition.Y > Constants.RegionSize)
else if (AbsolutePosition.Y > m_scene.RegionInfo.RegionSizeY)
pos.Y -= Velocity.Y * 2;
Velocity = Vector3.Zero;
AbsolutePosition = pos;
@ -3279,7 +3276,7 @@ namespace OpenSim.Region.Framework.Scenes
// Put the child agent back at the center
AbsolutePosition
= new Vector3(((float)Constants.RegionSize * 0.5f), ((float)Constants.RegionSize * 0.5f), 70);
= new Vector3(((float)m_scene.RegionInfo.RegionSizeX * 0.5f), ((float)m_scene.RegionInfo.RegionSizeY * 0.5f), 70);
Animator.ResetAnimations();
}
@ -3306,9 +3303,7 @@ namespace OpenSim.Region.Framework.Scenes
if (handle != Scene.RegionInfo.RegionHandle)
{
uint x, y;
Utils.LongToUInts(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
Util.RegionHandleToRegionLoc(handle, out x, out y);
// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX)));
// m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));
@ -3389,8 +3384,9 @@ namespace OpenSim.Region.Framework.Scenes
return;
//m_log.Debug(" >>> ChildAgentPositionUpdate <<< " + rRegionX + "-" + rRegionY);
int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize;
int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize;
// Find the distance (in meters) between the two regions
uint shiftx = Util.RegionToWorldLoc(rRegionX - tRegionX);
uint shifty = Util.RegionToWorldLoc(rRegionY - tRegionY);
Vector3 offset = new Vector3(shiftx, shifty, 0f);

View File

@ -264,7 +264,7 @@ namespace OpenSim.Region.Framework.Scenes
byte[] dataArray = (byte[])serializer.Deserialize(xmlReader);
int index = 0;
m_terrainData = new HeightmapTerrainData((int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight);
m_terrainData = new HeightmapTerrainData(Height, Width, (int)Constants.RegionHeight);
for (int y = 0; y < Height; y++)
{

View File

@ -194,7 +194,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
int wbits;
int[] patch = CompressPatch(patchData, header, 10, out wbits);
wbits = EncodePatchHeader(output, header, patch, Constants.RegionSize, Constants.RegionSize, wbits);
wbits = EncodePatchHeader(output, header, patch, (uint)pRegionSizeX, (uint)pRegionSizeY, wbits);
EncodePatch(output, patch, 0, wbits);
}

View File

@ -169,6 +169,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
c.Channel = m_channelNotify;
c.Message += numScriptsFailed.ToString() + "," + message;
c.Type = ChatTypeEnum.Region;
if (m_scene != null)
c.Position = new Vector3((m_scene.RegionInfo.RegionSizeX * 0.5f), (m_scene.RegionInfo.RegionSizeY * 0.5f), 30);
else
c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30);
c.Sender = null;
c.SenderUUID = UUID.Zero;

View File

@ -748,8 +748,8 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
position.X = s_tree.AbsolutePosition.X + (float)randX;
position.Y = s_tree.AbsolutePosition.Y + (float)randY;
if (position.X <= ((int)Constants.RegionSize - 1) && position.X >= 0 &&
position.Y <= ((int)Constants.RegionSize - 1) && position.Y >= 0 &&
if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 &&
position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 &&
Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range)
{
UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;

View File

@ -64,12 +64,12 @@ namespace OpenSim.Region.RegionCombinerModule
/// <summary>
/// The X meters position of this connection.
/// </summary>
public uint PosX { get { return X * Constants.RegionSize; } }
public uint PosX { get { return Util.RegionToWorldLoc(X); } }
/// <summary>
/// The Y meters co-ordinate of this connection.
/// </summary>
public uint PosY { get { return Y * Constants.RegionSize; } }
public uint PosY { get { return Util.RegionToWorldLoc(Y); } }
/// <summary>
/// The size of the megaregion in meters.

View File

@ -2107,7 +2107,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//
// This workaround is to prevent silent failure of this function.
// According to the specification on the SL Wiki, providing a position outside of the
if (pos.x < 0 || pos.x > Constants.RegionSize || pos.y < 0 || pos.y > Constants.RegionSize)
if (pos.x < 0 || pos.x > World.RegionInfo.RegionSizeX || pos.y < 0 || pos.y > World.RegionInfo.RegionSizeY)
{
return 0;
}
@ -2117,9 +2117,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.ParentGroup.IsAttachment || // return FALSE if attachment
(
pos.x < -10.0 || // return FALSE if more than 10 meters into a west-adjacent region.
pos.x > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
pos.x > (World.RegionInfo.RegionSizeX + 10) || // return FALSE if more than 10 meters into a east-adjacent region.
pos.y < -10.0 || // return FALSE if more than 10 meters into a south-adjacent region.
pos.y > (Constants.RegionSize + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
pos.y > (World.RegionInfo.RegionSizeY + 10) || // return FALSE if more than 10 meters into a north-adjacent region.
pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m
)
)
@ -5625,7 +5625,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Float mag;
if (dir.x > 0)
{
mag = (Constants.RegionSize - pos.x) / dir.x;
mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x;
}
else
{
@ -5636,7 +5636,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
edge.y = pos.y + (dir.y * mag);
if (edge.y > Constants.RegionSize || edge.y < 0)
if (edge.y > World.RegionInfo.RegionSizeY || edge.y < 0)
{
// Y goes out of bounds first
edge.y = dir.y / Math.Abs(dir.y);

View File

@ -450,7 +450,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
OSSLError("osSetTerrainHeight: Coordinate out of bounds");
if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
@ -480,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private LSL_Float GetTerrainHeight(int x, int y)
{
m_host.AddScriptLPS(1);
if (x > ((int)Constants.RegionSize - 1) || x < 0 || y > ((int)Constants.RegionSize - 1) || y < 0)
if (x > (World.RegionInfo.RegionSizeX - 1) || x < 0 || y > (World.RegionInfo.RegionSizeY - 1) || y < 0)
OSSLError("osGetTerrainHeight: Coordinate out of bounds");
return World.Heightmap[x, y];
@ -814,7 +814,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private void TeleportAgent(string agent, int regionX, int regionY,
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions)
{
ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
// ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
ulong regionHandle = Util.RegionWorldLocToHandle(Util.RegionToWorldLoc((uint)regionX), Util.RegionToWorldLoc((uint)regionY));
m_host.AddScriptLPS(1);
UUID agentId = new UUID();

View File

@ -721,8 +721,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
Position.y = ((int)Constants.RegionSize - 1);
if (Position.y < 0)
Position.y = 0;
if (Position.z > 768)
Position.z = 768;
if (Position.z > Constants.RegionHeight)
Position.z = Constants.RegionHeight;
if (Position.z < 0)
Position.z = 0;
prim.OSSL.llSetPos(Position);

View File

@ -168,12 +168,12 @@ namespace OpenSim.Services.Interfaces
/// <summary>
/// The co-ordinate of this region.
/// </summary>
public int RegionCoordX { get { return RegionLocX / (int)Constants.RegionSize; } }
public int RegionCoordX { get { return (int)Util.WorldToRegionLoc((uint)RegionLocX); } }
/// <summary>
/// The co-ordinate of this region
/// </summary>
public int RegionCoordY { get { return RegionLocY / (int)Constants.RegionSize; } }
public int RegionCoordY { get { return (int)Util.WorldToRegionLoc((uint)RegionLocY); } }
/// <summary>
/// The location of this region in meters.
@ -246,8 +246,8 @@ namespace OpenSim.Services.Interfaces
public GridRegion(uint xcell, uint ycell)
{
m_regionLocX = (int)(xcell * Constants.RegionSize);
m_regionLocY = (int)(ycell * Constants.RegionSize);
m_regionLocX = (int)Util.RegionToWorldLoc(xcell);
m_regionLocY = (int)Util.RegionToWorldLoc(ycell);
RegionSizeX = (int)Constants.RegionSize;
RegionSizeY = (int)Constants.RegionSize;
}

View File

@ -362,7 +362,9 @@ namespace OpenSim.Services.LLLoginService
private void FillOutHomeData(GridUserInfo pinfo, GridRegion home)
{
int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
// int x = 1000 * (int)Constants.RegionSize, y = 1000 * (int)Constants.RegionSize;
int x = (int)Util.RegionToWorldLoc(1000);
int y = (int)Util.RegionToWorldLoc(1000);
if (home != null)
{
x = home.RegionLocX;
@ -436,10 +438,23 @@ namespace OpenSim.Services.LLLoginService
ErrorReason = "key";
welcomeMessage = "Welcome to OpenSim!";
seedCapability = String.Empty;
home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" +
userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" +
userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" +
userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.ToString() + "]}";
home = "{'region_handle':[r"
+ Util.RegionToWorldLoc(1000).ToString()
+ ",r"
+ Util.RegionToWorldLoc(1000).ToString()
+ "], 'position':[r"
+ userProfile.homepos.X.ToString()
+ ",r"
+ userProfile.homepos.Y.ToString()
+ ",r"
+ userProfile.homepos.Z.ToString()
+ "], 'look_at':[r"
+ userProfile.homelookat.X.ToString()
+ ",r"
+ userProfile.homelookat.Y.ToString()
+ ",r"
+ userProfile.homelookat.Z.ToString()
+ "]}";
lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
RegionX = (uint) 255232;
RegionY = (uint) 254976;

View File

@ -684,7 +684,7 @@ namespace OpenSim.Services.LLLoginService
private GridRegion FindAlternativeRegion(UUID scopeID)
{
List<GridRegion> hyperlinks = null;
List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize);
List<GridRegion> regions = m_GridService.GetFallbackRegions(scopeID, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
if (regions != null && regions.Count > 0)
{
hyperlinks = m_GridService.GetHyperlinks(scopeID);

View File

@ -69,9 +69,7 @@ namespace OpenSim.Tests.Common
tc.OnTestClientInformClientOfNeighbour += (neighbourHandle, neighbourExternalEndPoint) =>
{
uint x, y;
Utils.LongToUInts(neighbourHandle, out x, out y);
x /= Constants.RegionSize;
y /= Constants.RegionSize;
Util.RegionHandleToRegionLoc(neighbourHandle, out x, out y);
m_log.DebugFormat(
"[TEST CLIENT]: Processing inform client of neighbour located at {0},{1} at {2}",
@ -104,9 +102,7 @@ namespace OpenSim.Tests.Common
+= (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) =>
{
uint x, y;
Utils.LongToUInts(regionHandle, out x, out y);
x /= Constants.RegionSize;
y /= Constants.RegionSize;
Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
m_log.DebugFormat(
"[TEST CLIENT]: Processing send region teleport for destination at {0},{1} at {2}",