varregion: any conversions of use of Constants.RegionSize converted into

Util.cs routines to convert region coords to and from world coords or handles.
avinationmerge
Robert Adams 2015-03-29 14:25:12 -07:00
parent c5a7bf6601
commit 07dead7dcb
45 changed files with 258 additions and 197 deletions

View File

@ -213,8 +213,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
IScene scene = c.Scene; IScene scene = c.Scene;
UUID destination = c.Destination; UUID destination = c.Destination;
Vector3 fromPos = c.Position; Vector3 fromPos = c.Position;
Vector3 regionPos = new Vector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, Vector3 regionPos = new Vector3(scene.RegionInfo.WorldLocX, scene.RegionInfo.WorldLocY, 0);
scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
bool checkParcelHide = false; bool checkParcelHide = false;
UUID sourceParcelID = UUID.Zero; UUID sourceParcelID = UUID.Zero;
@ -424,8 +423,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
{ {
Vector3 fromRegionPos = fromPos + regionPos; Vector3 fromRegionPos = fromPos + regionPos;
Vector3 toRegionPos = presence.AbsolutePosition + Vector3 toRegionPos = presence.AbsolutePosition +
new Vector3(presence.Scene.RegionInfo.RegionLocX * Constants.RegionSize, new Vector3(presence.Scene.RegionInfo.WorldLocX, presence.Scene.RegionInfo.WorldLocY, 0);
presence.Scene.RegionInfo.RegionLocY * Constants.RegionSize, 0);
int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos); int dis = (int)Util.GetDistanceTo(toRegionPos, fromRegionPos);

View File

@ -663,8 +663,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
Vector3 avaPos = p.AbsolutePosition; Vector3 avaPos = p.AbsolutePosition;
// Getting the global position for the Avatar // Getting the global position for the Avatar
Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.RegionLocX*Constants.RegionSize + avaPos.X, Vector3 posGlobal = new Vector3(remoteClient.Scene.RegionInfo.WorldLocX + avaPos.X,
remoteClient.Scene.RegionInfo.RegionLocY*Constants.RegionSize + avaPos.Y, remoteClient.Scene.RegionInfo.WorldLocY + avaPos.Y,
avaPos.Z); avaPos.Z);
string landOwnerName = string.Empty; string landOwnerName = string.Empty;
@ -1353,4 +1353,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.UserProfiles
} }
#endregion Web Util #endregion Web Util
} }
} }

View File

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

View File

@ -587,8 +587,8 @@ namespace OpenSim.Region.CoreModules.Framework.EntityTransfer
Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY); Util.RegionHandleToRegionLoc(regionHandle, out regX, out regY);
MapBlockData block = new MapBlockData(); MapBlockData block = new MapBlockData();
block.X = (ushort)(regX / Constants.RegionSize); block.X = (ushort)(regX);
block.Y = (ushort)(regY / Constants.RegionSize); block.Y = (ushort)(regY);
block.Access = (byte)SimAccess.Down; // == not there block.Access = (byte)SimAccess.Down; // == not there
List<MapBlockData> blocks = new List<MapBlockData>(); List<MapBlockData> blocks = new List<MapBlockData>();

View File

@ -213,8 +213,8 @@ namespace OpenSim.Region.CoreModules.Scripting.EmailModules
if (part != null) if (part != null)
{ {
ObjectRegionName = s.RegionInfo.RegionName; ObjectRegionName = s.RegionInfo.RegionName;
uint localX = (s.RegionInfo.RegionLocX * (int)Constants.RegionSize); uint localX = s.RegionInfo.WorldLocX;
uint localY = (s.RegionInfo.RegionLocY * (int)Constants.RegionSize); uint localY = s.RegionInfo.WorldLocY;
ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")"; ObjectRegionName = ObjectRegionName + " (" + localX + ", " + localY + ")";
return part; return part;
} }

View File

@ -268,11 +268,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key); caps.AppendFormat("*** Neighbours of {0} ({1}) ***\n", kvp.Value.RegionName, kvp.Key);
List<GridRegion> regions = kvp.Value.GetNeighbours(); List<GridRegion> regions = kvp.Value.GetNeighbours();
foreach (GridRegion r in regions) 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));
} }
} }
MainConsole.Instance.Output(caps.ToString()); MainConsole.Instance.Output(caps.ToString());
} }
} }
} }

View File

@ -66,7 +66,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return; return;
m_log.DebugFormat("[REGION CACHE]: (on region {0}) Region {1} is up @ {2}-{3}", 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; m_neighbours[otherRegion.RegionHandle] = otherRegion;
} }
@ -82,11 +82,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
return new List<GridRegion>(m_neighbours.Values); return new List<GridRegion>(m_neighbours.Values);
} }
// Get a region given its base coordinates (in meters).
// NOTE: this is NOT 'get a region by some point in the region'. The coordinate MUST
// be the base coordinate of the region.
// The snapping is technically unnecessary but is harmless because regions are always
// multiples of the legacy region size (256).
public GridRegion GetRegionByPosition(int x, int y) public GridRegion GetRegionByPosition(int x, int y)
{ {
uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize; uint xsnap = (uint)(x / Constants.RegionSize) * Constants.RegionSize;
uint ysnap = (uint)(y / 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)) if (m_neighbours.ContainsKey(handle))
return m_neighbours[handle]; return m_neighbours[handle];

View File

@ -141,7 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null");
Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match");
result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); result = m_LocalConnector.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc(1000), (int)Util.RegionToWorldLoc(1000));
Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null");
Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match");
@ -197,4 +197,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests
Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected"); Assert.That(results.Count, Is.EqualTo(0), "Retrieved linked regions collection is not the number expected");
} }
} }
} }

View File

@ -125,14 +125,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Neighbour
public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion) public OpenSim.Services.Interfaces.GridRegion HelloNeighbour(ulong regionHandle, RegionInfo thisRegion)
{ {
uint x, y; uint x, y;
Utils.LongToUInts(regionHandle, out x, out y); Util.RegionHandleToRegionLoc(regionHandle, out x, out y);
foreach (Scene s in m_Scenes) foreach (Scene s in m_Scenes)
{ {
if (s.RegionInfo.RegionHandle == regionHandle) if (s.RegionInfo.RegionHandle == regionHandle)
{ {
m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}", m_log.DebugFormat("[LOCAL NEIGHBOUR SERVICE CONNECTOR]: HelloNeighbour from region {0} to neighbour {1} at {2}-{3}",
thisRegion.RegionName, s.Name, x / Constants.RegionSize, y / Constants.RegionSize); thisRegion.RegionName, s.Name, x, y );
//m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour"); //m_log.Debug("[NEIGHBOUR CONNECTOR]: Found region to SendHelloNeighbour");
return s.IncomingHelloNeighbour(thisRegion); return s.IncomingHelloNeighbour(thisRegion);

View File

@ -533,7 +533,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
if (isMegaregion) if (isMegaregion)
size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID); size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID);
else else
size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize); size = new Vector2((float)scene.RegionInfo.RegionSizeX, (float)scene.RegionInfo.RegionSizeY);
xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); xtw.WriteElementString("is_megaregion", isMegaregion.ToString());
xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y));

View File

@ -151,14 +151,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell
break; break;
case 2: // Sell a copy case 2: // Sell a copy
Vector3 inventoryStoredPosition = new Vector3 Vector3 inventoryStoredPosition = new Vector3(
(((group.AbsolutePosition.X > (int)Constants.RegionSize) Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6),
? 250 Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6),
: group.AbsolutePosition.X)
,
(group.AbsolutePosition.X > (int)Constants.RegionSize)
? 250
: group.AbsolutePosition.X,
group.AbsolutePosition.Z); group.AbsolutePosition.Z);
Vector3 originalPosition = group.AbsolutePosition; Vector3 originalPosition = group.AbsolutePosition;

View File

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

View File

@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
for (y = 0; y < map.Height; y++) for (y = 0; y < map.Height; y++)
{ {
map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; 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) if (map[x, y] < spherFac)
{ {
map[x, y] = spherFac; map[x, y] = spherFac;
@ -53,4 +53,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
#endregion #endregion
} }
} }

View File

@ -154,10 +154,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
public ITerrainChannel LoadStream(Stream s) public ITerrainChannel LoadStream(Stream s)
{ {
// Set to default size
int w = (int)Constants.RegionSize; int w = (int)Constants.RegionSize;
int h = (int)Constants.RegionSize; int h = (int)Constants.RegionSize;
// create a dummy channel (in case data is bad)
TerrainChannel retval = new TerrainChannel(w, h); TerrainChannel retval = new TerrainChannel(w, h);
BinaryReader bs = new BinaryReader(s); BinaryReader bs = new BinaryReader(s);
@ -165,8 +166,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
bool eof = false; bool eof = false;
if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ")
{ {
// int fileWidth = w;
// int fileHeight = h;
// Terragen file // Terragen file
while (eof == false) while (eof == false)
@ -175,31 +174,29 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
switch (tmp) switch (tmp)
{ {
case "SIZE": case "SIZE":
// int sztmp = bs.ReadInt16() + 1; w = bs.ReadInt16() + 1;
// fileWidth = sztmp; h = w;
// fileHeight = sztmp;
bs.ReadInt16();
bs.ReadInt16(); bs.ReadInt16();
break; break;
case "XPTS": case "XPTS":
// fileWidth = bs.ReadInt16(); w = bs.ReadInt16();
bs.ReadInt16();
bs.ReadInt16(); bs.ReadInt16();
break; break;
case "YPTS": case "YPTS":
// fileHeight = bs.ReadInt16(); h = bs.ReadInt16();
bs.ReadInt16();
bs.ReadInt16(); bs.ReadInt16();
break; break;
case "ALTW": case "ALTW":
eof = true; eof = true;
Int16 heightScale = bs.ReadInt16(); // create new channel of proper size (now that we know it)
Int16 baseHeight = bs.ReadInt16(); retval = new TerrainChannel(w, h);
double heightScale = (double)bs.ReadInt16() / 65536.0;
double baseHeight = (double)bs.ReadInt16();
for (int y = 0; y < h; y++) for (int y = 0; y < h; y++)
{ {
for (int x = 0; x < w; x++) for (int x = 0; x < w; x++)
{ {
retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0; retval[x, y] = baseHeight + (double)bs.ReadInt16() * heightScale;
} }
} }
break; break;
@ -257,17 +254,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); bs.Write(enc.GetBytes("TERRAGENTERRAIN "));
bs.Write(enc.GetBytes("SIZE")); bs.Write(enc.GetBytes("SIZE"));
bs.Write(Convert.ToInt16(Constants.RegionSize)); bs.Write(Convert.ToInt16(map.Width));
bs.Write(Convert.ToInt16(0)); // necessary padding bs.Write(Convert.ToInt16(0)); // necessary padding
//The XPTS and YPTS chunks are not needed for square regions //The XPTS and YPTS chunks are not needed for square regions
//but L3DT won't load the terrain file properly without them. //but L3DT won't load the terrain file properly without them.
bs.Write(enc.GetBytes("XPTS")); bs.Write(enc.GetBytes("XPTS"));
bs.Write(Convert.ToInt16(Constants.RegionSize)); bs.Write(Convert.ToInt16(map.Width));
bs.Write(Convert.ToInt16(0)); // necessary padding bs.Write(Convert.ToInt16(0)); // necessary padding
bs.Write(enc.GetBytes("YPTS")); bs.Write(enc.GetBytes("YPTS"));
bs.Write(Convert.ToInt16(Constants.RegionSize)); bs.Write(Convert.ToInt16(map.Height));
bs.Write(Convert.ToInt16(0)); // necessary padding bs.Write(Convert.ToInt16(0)); // necessary padding
bs.Write(enc.GetBytes("SCAL")); bs.Write(enc.GetBytes("SCAL"));
@ -283,11 +280,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders
bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min
bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point
double factor = 65536.0 / horizontalScale; // avoid computing this on each iteration
for (int y = 0; y < map.Height; y++) for (int y = 0; y < map.Height; y++)
{ {
for (int x = 0; x < map.Width; x++) for (int x = 0; x < map.Width; x++)
{ {
float elevation = (float)((map[x,y] - baseHeight) * 65536 ) / (float)horizontalScale; // see LoadStream for inverse float elevation = (float)((map[x,y] - baseHeight) * factor); // see LoadStream for inverse
// clamp rounding issues // clamp rounding issues
if (elevation > Int16.MaxValue) if (elevation > Int16.MaxValue)

View File

@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
{ {
if (fillArea[x, y]) if (fillArea[x, y])
{ {
double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
map[x, y] += noise * strength; map[x, y] += noise * strength;
} }
@ -55,4 +55,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
#endregion #endregion
} }
} }

View File

@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
z *= z; z *= z;
z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0); double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0);
if (z > 0.0) if (z > 0.0)
map[x, y] += noise * z * duration; map[x, y] += noise * z * duration;

View File

@ -40,10 +40,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
[Test] [Test]
public void BrushTest() public void BrushTest()
{ {
int midRegion = (int)Constants.RegionSize / 2;
// Create a mask that covers only the left half of the region
bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; bool[,] allowMask = new bool[(int)Constants.RegionSize, 256];
int x; int x;
int y; int y;
for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++) for (x = 0; x < midRegion; x++)
{ {
for (y = 0; y < (int)Constants.RegionSize; y++) for (y = 0; y < (int)Constants.RegionSize; y++)
{ {
@ -57,13 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
ITerrainPaintableEffect effect = new RaiseSphere(); ITerrainPaintableEffect effect = new RaiseSphere();
effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1); effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128)."); Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128)."); Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128)."); Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128)."); Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128).");
Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128)."); Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128).");
// //
// Test LowerSphere // Test LowerSphere
// //
@ -77,13 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
} }
effect = new LowerSphere(); effect = new LowerSphere();
effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0); effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128).");
Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128)."); Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");
Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128)."); Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128).");
Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128)."); Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128).");
Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128)."); Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128).");
} }
[Test] [Test]

View File

@ -2221,14 +2221,9 @@ namespace OpenSim.Region.Framework.Scenes
itemID = UUID.Zero; itemID = UUID.Zero;
if (grp != null) if (grp != null)
{ {
Vector3 inventoryStoredPosition = new Vector3 Vector3 inventoryStoredPosition = new Vector3(
(((grp.AbsolutePosition.X > (int)Constants.RegionSize) Math.Min(grp.AbsolutePosition.X, RegionInfo.RegionSizeX - 6),
? 250 Math.Min(grp.AbsolutePosition.Y, RegionInfo.RegionSizeY - 6),
: grp.AbsolutePosition.X)
,
(grp.AbsolutePosition.X > (int)Constants.RegionSize)
? 250
: grp.AbsolutePosition.X,
grp.AbsolutePosition.Z); grp.AbsolutePosition.Z);
Vector3 originalPosition = grp.AbsolutePosition; Vector3 originalPosition = grp.AbsolutePosition;

View File

@ -6,7 +6,7 @@
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright * * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyrightD * * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the * * Neither the name of the OpenSimulator Project nor the
@ -103,7 +103,29 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// If false then physical objects are disabled, though collisions will continue as normal. /// If false then physical objects are disabled, though collisions will continue as normal.
/// </summary> /// </summary>
public bool PhysicsEnabled { get; set; } public bool PhysicsEnabled
{
get
{
return m_physicsEnabled;
}
set
{
m_physicsEnabled = value;
if (PhysicsScene != null)
{
IPhysicsParameters physScene = PhysicsScene as IPhysicsParameters;
if (physScene != null)
physScene.SetPhysicsParameter(
"Active", m_physicsEnabled.ToString(), PhysParameterEntry.APPLY_TO_NONE);
}
}
}
private bool m_physicsEnabled;
/// <summary> /// <summary>
/// If false then scripts are not enabled on the smiulator /// If false then scripts are not enabled on the smiulator
@ -199,15 +221,16 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public int m_linksetCapacity = 0; public int m_linksetCapacity = 0;
public bool m_clampPrimSize;
public bool m_trustBinaries;
public bool m_allowScriptCrossings = true;
/// <summary> /// <summary>
/// Max prims an Physical object will hold /// Max prims an Physical object will hold
/// </summary> /// </summary>
/// ///
public int m_linksetPhysCapacity = 0; public int m_linksetPhysCapacity = 0;
public bool m_clampPrimSize;
public bool m_trustBinaries;
public bool m_allowScriptCrossings;
public bool m_useFlySlow; public bool m_useFlySlow;
public bool m_useTrashOnDelete = true; public bool m_useTrashOnDelete = true;

View File

@ -52,6 +52,7 @@ namespace OpenSim.Region.Framework.Scenes
public class SceneCommunicationService //one instance per region public class SceneCommunicationService //one instance per region
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static string LogHeader = "[SCENE COMMUNICATION SERVICE]";
protected RegionInfo m_regionInfo; protected RegionInfo m_regionInfo;
protected Scene m_scene; protected Scene m_scene;
@ -100,7 +101,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
m_log.WarnFormat( m_log.WarnFormat(
"[SCENE COMMUNICATION SERVICE]: Region {0} failed to inform neighbour at {1}-{2} that it is up.", "[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));
} }
} }
@ -166,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes
// we only want to send one update to each simulator; the simulator will // we only want to send one update to each simulator; the simulator will
// hand it off to the regions where a child agent exists, this does assume // hand it off to the regions where a child agent exists, this does assume
// that the region position is cached or performance will degrade // that the region position is cached or performance will degrade
Utils.LongToUInts(regionHandle, out x, out y); Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); GridRegion dest = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (dest == null) if (dest == null)
continue; continue;
@ -206,7 +207,7 @@ namespace OpenSim.Region.Framework.Scenes
//m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
uint x = 0, y = 0; uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y); Util.RegionHandleToWorldLoc(regionHandle, out x, out y);
GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y); GridRegion destination = m_scene.GridService.GetRegionByPosition(m_regionInfo.ScopeID, (int)x, (int)y);
@ -226,6 +227,8 @@ namespace OpenSim.Region.Framework.Scenes
{ {
foreach (ulong handle in regionslst) foreach (ulong handle in regionslst)
{ {
// We must take a copy here since handle acts like a reference when used in an iterator.
// This leads to race conditions if directly passed to SendCloseChildAgent with more than one neighbour region.
ulong handleCopy = handle; ulong handleCopy = handle;
Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); }); Util.FireAndForget((o) => { SendCloseChildAgent(agentID, handleCopy, auth_code); });
} }

View File

@ -412,7 +412,7 @@ namespace OpenSim.Region.Framework.Scenes
{ {
get get
{ {
Vector3 minScale = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionSize); Vector3 minScale = new Vector3(Constants.MaximumRegionSize, Constants.MaximumRegionSize, Constants.MaximumRegionSize);
Vector3 maxScale = Vector3.Zero; Vector3 maxScale = Vector3.Zero;
Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f); Vector3 finalScale = new Vector3(0.5f, 0.5f, 0.5f);

View File

@ -842,9 +842,8 @@ namespace OpenSim.Region.Framework.Scenes
foreach (ulong handle in seeds.Keys) foreach (ulong handle in seeds.Keys)
{ {
uint x, y; uint x, y;
Utils.LongToUInts(handle, out x, out y); Util.RegionHandleToRegionLoc(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY)) if (Util.IsOutsideView(DrawDistance, x, Scene.RegionInfo.RegionLocX, y, Scene.RegionInfo.RegionLocY))
{ {
old.Add(handle); old.Add(handle);
@ -866,9 +865,7 @@ namespace OpenSim.Region.Framework.Scenes
foreach (KeyValuePair<ulong, string> kvp in KnownRegions) foreach (KeyValuePair<ulong, string> kvp in KnownRegions)
{ {
uint x, y; uint x, y;
Utils.LongToUInts(kvp.Key, out x, out y); Util.RegionHandleToRegionLoc(kvp.Key, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
m_log.Info(" >> "+x+", "+y+": "+kvp.Value); m_log.Info(" >> "+x+", "+y+": "+kvp.Value);
} }
} }
@ -1189,7 +1186,7 @@ namespace OpenSim.Region.Framework.Scenes
float posZLimit = 0; 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]; posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y];
float newPosZ = posZLimit + localAVHeight / 2; float newPosZ = posZLimit + localAVHeight / 2;
@ -2595,7 +2592,7 @@ namespace OpenSim.Region.Framework.Scenes
if (regionCombinerModule != null) if (regionCombinerModule != null)
regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID); regionSize = regionCombinerModule.GetSizeOfMegaregion(m_scene.RegionInfo.RegionID);
else 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 if (pos.X < 0 || pos.X >= regionSize.X
|| pos.Y < 0 || pos.Y >= regionSize.Y || pos.Y < 0 || pos.Y >= regionSize.Y
@ -2613,8 +2610,8 @@ namespace OpenSim.Region.Framework.Scenes
// } // }
// Get terrain height for sub-region in a megaregion if necessary // Get terrain height for sub-region in a megaregion if necessary
int X = (int)((m_scene.RegionInfo.RegionLocX * Constants.RegionSize) + pos.X); int X = (int)((m_scene.RegionInfo.WorldLocX) + pos.X);
int Y = (int)((m_scene.RegionInfo.RegionLocY * Constants.RegionSize) + pos.Y); int Y = (int)((m_scene.RegionInfo.WorldLocY) + pos.Y);
GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y); GridRegion target_region = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, X, Y);
// If X and Y is NaN, target_region will be null // If X and Y is NaN, target_region will be null
if (target_region == null) if (target_region == null)
@ -2625,7 +2622,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene)) if (!SceneManager.Instance.TryGetScene(target_regionID, out targetScene))
targetScene = m_scene; 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)];
// dont try to land underground // dont try to land underground
terrainHeight += Appearance.AvatarHeight / 2; terrainHeight += Appearance.AvatarHeight / 2;
pos.Z = Math.Max(terrainHeight, pos.Z); pos.Z = Math.Max(terrainHeight, pos.Z);
@ -3941,7 +3938,7 @@ namespace OpenSim.Region.Framework.Scenes
// Put the child agent back at the center // Put the child agent back at the center
AbsolutePosition 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(); Animator.ResetAnimations();
} }
@ -3968,9 +3965,7 @@ namespace OpenSim.Region.Framework.Scenes
if (handle != Scene.RegionInfo.RegionHandle) if (handle != Scene.RegionInfo.RegionHandle)
{ {
uint x, y; uint x, y;
Utils.LongToUInts(handle, out x, out y); Util.RegionHandleToRegionLoc(handle, out x, out y);
x = x / Constants.RegionSize;
y = y / Constants.RegionSize;
// m_log.Debug("---> x: " + x + "; newx:" + newRegionX + "; Abs:" + (int)Math.Abs((int)(x - newRegionX))); // 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))); // m_log.Debug("---> y: " + y + "; newy:" + newRegionY + "; Abs:" + (int)Math.Abs((int)(y - newRegionY)));

View File

@ -518,7 +518,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
public Vector3 StartPos public Vector3 StartPos
{ {
get { return new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 50); } get { return new Vector3(m_scene.RegionInfo.RegionSizeX * 0.5f, m_scene.RegionInfo.RegionSizeY * 0.5f, 50f); }
set { } set { }
} }

View File

@ -52,6 +52,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
// Local constants // Local constants
// This computation is not the real region center if the region is larger than 256.
// This computation isn't fixed because there is not a handle back to the region.
private static readonly Vector3 CenterOfRegion = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); private static readonly Vector3 CenterOfRegion = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20);
private static readonly char[] CS_SPACE = { ' ' }; private static readonly char[] CS_SPACE = { ' ' };

View File

@ -44,6 +44,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// This computation is not the real region center if the region is larger than 256.
// This computation isn't fixed because there is not a handle back to the region.
private static readonly OpenMetaverse.Vector3 CenterOfRegion = new OpenMetaverse.Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20); private static readonly OpenMetaverse.Vector3 CenterOfRegion = new OpenMetaverse.Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 20);
private const int DEBUG_CHANNEL = 2147483647; private const int DEBUG_CHANNEL = 2147483647;

View File

@ -122,8 +122,8 @@ namespace OpenSim.Region.OptionalModules
private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
{ {
if (newPoint.X < -1f || newPoint.X > (float)(Constants.RegionSize + 1) || if (newPoint.X < -1f || newPoint.X > (scene.RegionInfo.RegionSizeX + 1) ||
newPoint.Y < -1f || newPoint.Y > (float)(Constants.RegionSize + 1)) newPoint.Y < -1f || newPoint.Y > (scene.RegionInfo.RegionSizeY) )
return true; return true;
SceneObjectPart obj = scene.GetSceneObjectPart(objectID); SceneObjectPart obj = scene.GetSceneObjectPart(objectID);

View File

@ -170,7 +170,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
c.Channel = m_channelNotify; c.Channel = m_channelNotify;
c.Message += numScriptsFailed.ToString() + "," + message; c.Message += numScriptsFailed.ToString() + "," + message;
c.Type = ChatTypeEnum.Region; c.Type = ChatTypeEnum.Region;
c.Position = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 30); 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.Sender = null;
c.SenderUUID = UUID.Zero; c.SenderUUID = UUID.Zero;
c.Scene = m_scene; c.Scene = m_scene;

View File

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

View File

@ -46,6 +46,7 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
private List<BasicActor> _actors = new List<BasicActor>(); private List<BasicActor> _actors = new List<BasicActor>();
private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>(); private List<BasicPhysicsPrim> _prims = new List<BasicPhysicsPrim>();
private float[] _heightMap; private float[] _heightMap;
private Vector3 m_regionExtent;
//protected internal string sceneIdentifier; //protected internal string sceneIdentifier;
@ -58,6 +59,12 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
public override void Initialise(IMesher meshmerizer, IConfigSource config) public override void Initialise(IMesher meshmerizer, IConfigSource config)
{ {
throw new Exception("Should not be called.");
}
public override void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
{
m_regionExtent = regionExtent;
} }
public override void Dispose() {} public override void Dispose() {}
@ -121,23 +128,23 @@ namespace OpenSim.Region.Physics.BasicPhysicsPlugin
{ {
actorPosition.Y = 0.1F; actorPosition.Y = 0.1F;
} }
else if (actor.Position.Y >= Constants.RegionSize) else if (actor.Position.Y >= m_regionExtent.Y)
{ {
actorPosition.Y = ((int)Constants.RegionSize - 0.1f); actorPosition.Y = (m_regionExtent.Y - 0.1f);
} }
if (actor.Position.X < 0) if (actor.Position.X < 0)
{ {
actorPosition.X = 0.1F; actorPosition.X = 0.1F;
} }
else if (actor.Position.X >= Constants.RegionSize) else if (actor.Position.X >= m_regionExtent.X)
{ {
actorPosition.X = ((int)Constants.RegionSize - 0.1f); actorPosition.X = (m_regionExtent.X - 0.1f);
} }
float terrainHeight = 0; float terrainHeight = 0;
if (_heightMap != null) if (_heightMap != null)
terrainHeight = _heightMap[(int)actor.Position.Y * Constants.RegionSize + (int)actor.Position.X]; terrainHeight = _heightMap[(int)actor.Position.Y * (int)m_regionExtent.Y + (int)actor.Position.X];
float height = terrainHeight + actor.Size.Z; float height = terrainHeight + actor.Size.Z;

View File

@ -32,6 +32,7 @@ using System.Reflection;
using Nini.Config; using Nini.Config;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
using OpenMetaverse;
namespace OpenSim.Region.Physics.Manager namespace OpenSim.Region.Physics.Manager
{ {
@ -59,6 +60,14 @@ namespace OpenSim.Region.Physics.Manager
m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName()); m_log.Info("[PHYSICS]: Added meshing engine: " + plugHard.GetName());
} }
// Legacy method for simulators before extent was passed
public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
IConfigSource config, string regionName)
{
Vector3 extent = new Vector3(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight);
return GetPhysicsScene(physEngineName, meshEngineName, config, regionName, extent);
}
/// <summary> /// <summary>
/// Get a physics scene for the given physics engine and mesher. /// Get a physics scene for the given physics engine and mesher.
/// </summary> /// </summary>
@ -66,7 +75,8 @@ namespace OpenSim.Region.Physics.Manager
/// <param name="meshEngineName"></param> /// <param name="meshEngineName"></param>
/// <param name="config"></param> /// <param name="config"></param>
/// <returns></returns> /// <returns></returns>
public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName, IConfigSource config, string regionName) public PhysicsScene GetPhysicsScene(string physEngineName, string meshEngineName,
IConfigSource config, string regionName, Vector3 regionExtent)
{ {
if (String.IsNullOrEmpty(physEngineName)) if (String.IsNullOrEmpty(physEngineName))
{ {
@ -94,7 +104,7 @@ namespace OpenSim.Region.Physics.Manager
{ {
m_log.Info("[PHYSICS]: creating " + physEngineName); m_log.Info("[PHYSICS]: creating " + physEngineName);
PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName); PhysicsScene result = _PhysPlugins[physEngineName].GetScene(regionName);
result.Initialise(meshEngine, config); result.Initialise(meshEngine, config, regionExtent);
return result; return result;
} }
else else

View File

@ -132,8 +132,17 @@ namespace OpenSim.Region.Physics.Manager
} }
} }
// Deprecated. Do not use this for new physics engines.
public abstract void Initialise(IMesher meshmerizer, IConfigSource config); public abstract void Initialise(IMesher meshmerizer, IConfigSource config);
// For older physics engines that do not implement non-legacy region sizes.
// If the physics engine handles the region extent feature, it overrides this function.
public virtual void Initialise(IMesher meshmerizer, IConfigSource config, Vector3 regionExtent)
{
// If not overridden, call the old initialization entry.
Initialise(meshmerizer, config);
}
/// <summary> /// <summary>
/// Add an avatar /// Add an avatar
/// </summary> /// </summary>

View File

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

View File

@ -2351,7 +2351,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// //
// This workaround is to prevent silent failure of this function. // This workaround is to prevent silent failure of this function.
// According to the specification on the SL Wiki, providing a position outside of the // 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; return 0;
} }
@ -2361,9 +2361,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.ParentGroup.IsAttachment || // return FALSE if attachment 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 < -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 < -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 pos.z > Constants.RegionHeight // return FALSE if altitude than 4096m
) )
) )
@ -4654,10 +4654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
DataserverPlugin.RegisterRequest(m_host.LocalId, DataserverPlugin.RegisterRequest(m_host.LocalId,
m_item.ItemID, item.AssetID.ToString()); m_item.ItemID, item.AssetID.ToString());
Vector3 region = new Vector3( Vector3 region = new Vector3(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0);
World.RegionInfo.RegionLocX * Constants.RegionSize,
World.RegionInfo.RegionLocY * Constants.RegionSize,
0);
World.AssetService.Get(item.AssetID.ToString(), this, World.AssetService.Get(item.AssetID.ToString(), this,
delegate(string i, object sender, AssetBase a) delegate(string i, object sender, AssetBase a)
@ -5948,7 +5945,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGetRegionCorner() public LSL_Vector llGetRegionCorner()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
return new LSL_Vector(World.RegionInfo.RegionLocX * Constants.RegionSize, World.RegionInfo.RegionLocY * Constants.RegionSize, 0); return new LSL_Vector(World.RegionInfo.WorldLocX, World.RegionInfo.WorldLocY, 0);
} }
/// <summary> /// <summary>
@ -6103,7 +6100,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Float mag; LSL_Float mag;
if (dir.x > 0) if (dir.x > 0)
{ {
mag = (Constants.RegionSize - pos.x) / dir.x; mag = (World.RegionInfo.RegionSizeX - pos.x) / dir.x;
} }
else else
{ {
@ -6114,7 +6111,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
edge.y = pos.y + (dir.y * mag); 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 // Y goes out of bounds first
edge.y = dir.y / Math.Abs(dir.y); edge.y = dir.y / Math.Abs(dir.y);

View File

@ -459,7 +459,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); 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"); OSSLError("osSetTerrainHeight: Coordinate out of bounds");
if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0))) if (World.Permissions.CanTerraformLand(m_host.OwnerID, new Vector3(x, y, 0)))
@ -489,7 +489,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private LSL_Float GetTerrainHeight(int x, int y) private LSL_Float GetTerrainHeight(int x, int y)
{ {
m_host.AddScriptLPS(1); 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"); OSSLError("osGetTerrainHeight: Coordinate out of bounds");
return World.Heightmap[x, y]; return World.Heightmap[x, y];
@ -823,7 +823,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
private void TeleportAgent(string agent, int regionX, int regionY, private void TeleportAgent(string agent, int regionX, int regionY,
LSL_Types.Vector3 position, LSL_Types.Vector3 lookat, bool relaxRestrictions) 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.RegionLocToHandle((uint)regionX, (uint)regionY);
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID agentId = new UUID(); UUID agentId = new UUID();
@ -3024,7 +3024,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
else else
{ {
return new LSL_Vector((float)Constants.RegionSize, (float)Constants.RegionSize, Constants.RegionHeight); return new LSL_Vector((float)World.RegionInfo.RegionSizeX,
(float)World.RegionInfo.RegionSizeY,
(float)World.RegionInfo.RegionSizeZ );
} }
} }

View File

@ -708,18 +708,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
} }
private void Save() private void Save()
{ {
/* Remove temporarily until we have a handle to the region size
if (Position.x > ((int)Constants.RegionSize - 1)) if (Position.x > ((int)Constants.RegionSize - 1))
Position.x = ((int)Constants.RegionSize - 1); Position.x = ((int)Constants.RegionSize - 1);
if (Position.x < 0)
Position.x = 0;
if (Position.y > ((int)Constants.RegionSize - 1)) if (Position.y > ((int)Constants.RegionSize - 1))
Position.y = ((int)Constants.RegionSize - 1); Position.y = ((int)Constants.RegionSize - 1);
*/
if (Position.x < 0)
Position.x = 0;
if (Position.y < 0) if (Position.y < 0)
Position.y = 0; Position.y = 0;
if (Position.z > 768)
Position.z = 768;
if (Position.z < 0) if (Position.z < 0)
Position.z = 0; Position.z = 0;
if (Position.z > Constants.RegionHeight)
Position.z = Constants.RegionHeight;
prim.OSSL.llSetPos(Position); prim.OSSL.llSetPos(Position);
} }

View File

@ -133,7 +133,7 @@ namespace OpenSim.Server.Handlers.MapImage
if (m_GridService != null) if (m_GridService != null)
{ {
System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y));
if (r != null) if (r != null)
{ {
if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())

View File

@ -128,7 +128,7 @@ namespace OpenSim.Server.Handlers.MapImage
if (m_GridService != null) if (m_GridService != null)
{ {
System.Net.IPAddress ipAddr = GetCallerIP(httpRequest); System.Net.IPAddress ipAddr = GetCallerIP(httpRequest);
GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, x * (int)Constants.RegionSize, y * (int)Constants.RegionSize); GridRegion r = m_GridService.GetRegionByPosition(UUID.Zero, (int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y));
if (r != null) if (r != null)
{ {
if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString()) if (r.ExternalEndPoint.Address.ToString() != ipAddr.ToString())

View File

@ -112,7 +112,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
// m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking"); // m_log.Warn("Registering region " + regionInfo.RegionName + " (" + regionInfo.RegionID + ") that we are not tracking");
Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0); Vector3d minPosition = new Vector3d(regionInfo.RegionLocX, regionInfo.RegionLocY, 0.0);
Vector3d maxPosition = minPosition + new Vector3d(Constants.RegionSize, Constants.RegionSize, Constants.RegionHeight); Vector3d maxPosition = minPosition + new Vector3d(regionInfo.RegionSizeX, regionInfo.RegionSizeY, Constants.RegionHeight);
OSDMap extraData = new OSDMap OSDMap extraData = new OSDMap
{ {
@ -174,8 +174,8 @@ namespace OpenSim.Services.Connectors.SimianGrid
if (region != null) if (region != null)
{ {
List<GridRegion> regions = GetRegionRange(scopeID, List<GridRegion> regions = GetRegionRange(scopeID,
region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + (int)Constants.RegionSize + NEIGHBOR_RADIUS, region.RegionLocX - NEIGHBOR_RADIUS, region.RegionLocX + region.RegionSizeX + NEIGHBOR_RADIUS,
region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + (int)Constants.RegionSize + NEIGHBOR_RADIUS); region.RegionLocY - NEIGHBOR_RADIUS, region.RegionLocY + region.RegionSizeY + NEIGHBOR_RADIUS);
for (int i = 0; i < regions.Count; i++) for (int i = 0; i < regions.Count; i++)
{ {
@ -240,7 +240,7 @@ namespace OpenSim.Services.Connectors.SimianGrid
else else
{ {
// m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}", // m_log.InfoFormat("[SIMIAN GRID CONNECTOR]: Grid service did not find a match for region at {0},{1}",
// x / Constants.RegionSize, y / Constants.RegionSize); // Util.WorldToRegionLoc(x), Util.WorldToRegionLoc(y));
return null; return null;
} }
} }

View File

@ -655,7 +655,7 @@ namespace OpenSim.Services.GridService
return; return;
} }
RegionData region = m_Database.Get(x * (int)Constants.RegionSize, y * (int)Constants.RegionSize, UUID.Zero); RegionData region = m_Database.Get((int)Util.RegionToWorldLoc((uint)x), (int)Util.RegionToWorldLoc((uint)y), UUID.Zero);
if (region == null) if (region == null)
{ {
MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y); MainConsole.Instance.OutputFormat("No region found at {0},{1}", x, y);
@ -673,6 +673,7 @@ namespace OpenSim.Services.GridService
dispList.AddRow("Region Name", r.RegionName); dispList.AddRow("Region Name", r.RegionName);
dispList.AddRow("Region ID", r.RegionID); dispList.AddRow("Region ID", r.RegionID);
dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY)); dispList.AddRow("Location", string.Format("{0},{1}", r.coordX, r.coordY));
dispList.AddRow("Size", string.Format("{0}x{1}", r.sizeX, r.sizeY));
dispList.AddRow("URI", r.Data["serverURI"]); dispList.AddRow("URI", r.Data["serverURI"]);
dispList.AddRow("Owner ID", r.Data["owner_uuid"]); dispList.AddRow("Owner ID", r.Data["owner_uuid"]);
dispList.AddRow("Flags", flags); dispList.AddRow("Flags", flags);

View File

@ -183,8 +183,8 @@ namespace OpenSim.Services.GridService
public GridRegion LinkRegion(UUID scopeID, string regionDescriptor) public GridRegion LinkRegion(UUID scopeID, string regionDescriptor)
{ {
string reason = string.Empty; string reason = string.Empty;
int xloc = random.Next(0, Int16.MaxValue) * (int)Constants.RegionSize; uint xloc = Util.RegionToWorldLoc((uint)random.Next(0, Int16.MaxValue));
return TryLinkRegionToCoords(scopeID, regionDescriptor, xloc, 0, out reason); return TryLinkRegionToCoords(scopeID, regionDescriptor, (int)xloc, 0, out reason);
} }
private static Random random = new Random(); private static Random random = new Random();
@ -260,7 +260,7 @@ namespace OpenSim.Services.GridService
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}", m_log.DebugFormat("[HYPERGRID LINKER]: Link to {0} {1}, in {2}-{3}",
((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI), ((serverURI == null) ? (externalHostName + ":" + externalPort) : serverURI),
remoteRegionName, xloc / Constants.RegionSize, yloc / Constants.RegionSize); remoteRegionName, Util.WorldToRegionLoc((uint)xloc), Util.WorldToRegionLoc((uint)yloc));
reason = string.Empty; reason = string.Empty;
Uri uri = null; Uri uri = null;
@ -311,7 +311,7 @@ namespace OpenSim.Services.GridService
if (region != null) if (region != null)
{ {
m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}", m_log.WarnFormat("[HYPERGRID LINKER]: Coordinates {0}-{1} are already occupied by region {2} with uuid {3}",
regInfo.RegionLocX / Constants.RegionSize, regInfo.RegionLocY / Constants.RegionSize, Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY),
region.RegionName, region.RegionID); region.RegionName, region.RegionID);
reason = "Coordinates are already in use"; reason = "Coordinates are already in use";
return false; return false;
@ -347,7 +347,7 @@ namespace OpenSim.Services.GridService
if (region != null) if (region != null)
{ {
m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}", m_log.DebugFormat("[HYPERGRID LINKER]: Region already exists in coordinates {0} {1}",
region.RegionLocX / Constants.RegionSize, region.RegionLocY / Constants.RegionSize); Util.WorldToRegionLoc((uint)regInfo.RegionLocX), Util.WorldToRegionLoc((uint)regInfo.RegionLocY));
regInfo = region; regInfo = region;
return true; return true;
} }
@ -424,10 +424,10 @@ namespace OpenSim.Services.GridService
// { // {
// uint ux = 0, uy = 0; // uint ux = 0, uy = 0;
// Utils.LongToUInts(realHandle, out ux, out uy); // Utils.LongToUInts(realHandle, out ux, out uy);
// x = ux / Constants.RegionSize; // x = Util.WorldToRegionLoc(ux);
// y = uy / Constants.RegionSize; // y = Util.WorldToRegionLoc(uy);
// //
// const uint limit = (4096 - 1) * Constants.RegionSize; // const uint limit = Util.RegionToWorldLoc(4096 - 1);
// uint xmin = ux - limit; // uint xmin = ux - limit;
// uint xmax = ux + limit; // uint xmax = ux + limit;
// uint ymin = uy - limit; // uint ymin = uy - limit;
@ -503,8 +503,9 @@ namespace OpenSim.Services.GridService
foreach (RegionData r in regions) foreach (RegionData r in regions)
{ {
MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n", MainConsole.Instance.Output(String.Format("{0}\n{2,-32} {1}\n",
r.RegionName, r.RegionID, String.Format("{0},{1} ({2},{3})", r.posX, r.posY, r.RegionName, r.RegionID,
r.posX / Constants.RegionSize, r.posY / Constants.RegionSize))); String.Format("{0},{1} ({2},{3})", r.posX, r.posY,
Util.WorldToRegionLoc((uint)r.posX), Util.WorldToRegionLoc((uint)r.posY))) );
} }
return; return;
} }
@ -529,8 +530,8 @@ namespace OpenSim.Services.GridService
int xloc, yloc; int xloc, yloc;
string serverURI; string serverURI;
string remoteName = null; string remoteName = null;
xloc = Convert.ToInt32(cmdparams[0]) * (int)Constants.RegionSize; xloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[0]));
yloc = Convert.ToInt32(cmdparams[1]) * (int)Constants.RegionSize; yloc = (int)Util.RegionToWorldLoc((uint)Convert.ToInt32(cmdparams[1]));
serverURI = cmdparams[2]; serverURI = cmdparams[2];
if (cmdparams.Length > 3) if (cmdparams.Length > 3)
remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3); remoteName = string.Join(" ", cmdparams, 3, cmdparams.Length - 3);
@ -601,13 +602,13 @@ namespace OpenSim.Services.GridService
{ {
// old format // old format
GridRegion regInfo; GridRegion regInfo;
int xloc, yloc; uint xloc, yloc;
uint externalPort; uint externalPort;
string externalHostName; string externalHostName;
try try
{ {
xloc = Convert.ToInt32(cmdparams[0]); xloc = (uint)Convert.ToInt32(cmdparams[0]);
yloc = Convert.ToInt32(cmdparams[1]); yloc = (uint)Convert.ToInt32(cmdparams[1]);
externalPort = Convert.ToUInt32(cmdparams[3]); externalPort = Convert.ToUInt32(cmdparams[3]);
externalHostName = cmdparams[2]; externalHostName = cmdparams[2];
//internalPort = Convert.ToUInt32(cmdparams[4]); //internalPort = Convert.ToUInt32(cmdparams[4]);
@ -621,10 +622,11 @@ namespace OpenSim.Services.GridService
} }
// Convert cell coordinates given by the user to meters // Convert cell coordinates given by the user to meters
xloc = xloc * (int)Constants.RegionSize; xloc = Util.RegionToWorldLoc(xloc);
yloc = yloc * (int)Constants.RegionSize; yloc = Util.RegionToWorldLoc(yloc);
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc,
string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
{ {
// What is this? The GridRegion instance will be discarded anyway, // What is this? The GridRegion instance will be discarded anyway,
// which effectively ignores any local name given with the command. // which effectively ignores any local name given with the command.
@ -704,13 +706,13 @@ namespace OpenSim.Services.GridService
private void ReadLinkFromConfig(IConfig config) private void ReadLinkFromConfig(IConfig config)
{ {
GridRegion regInfo; GridRegion regInfo;
int xloc, yloc; uint xloc, yloc;
uint externalPort; uint externalPort;
string externalHostName; string externalHostName;
uint realXLoc, realYLoc; uint realXLoc, realYLoc;
xloc = Convert.ToInt32(config.GetString("xloc", "0")); xloc = (uint)Convert.ToInt32(config.GetString("xloc", "0"));
yloc = Convert.ToInt32(config.GetString("yloc", "0")); yloc = (uint)Convert.ToInt32(config.GetString("yloc", "0"));
externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); externalPort = Convert.ToUInt32(config.GetString("externalPort", "0"));
externalHostName = config.GetString("externalHostName", ""); externalHostName = config.GetString("externalHostName", "");
realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0"));
@ -718,18 +720,19 @@ namespace OpenSim.Services.GridService
if (m_enableAutoMapping) if (m_enableAutoMapping)
{ {
xloc = (int)((xloc % 100) + m_autoMappingX); xloc = (uint)((xloc % 100) + m_autoMappingX);
yloc = (int)((yloc % 100) + m_autoMappingY); yloc = (uint)((yloc % 100) + m_autoMappingY);
} }
if (((realXLoc == 0) && (realYLoc == 0)) || if (((realXLoc == 0) && (realYLoc == 0)) ||
(((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) &&
((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896))))
{ {
xloc = xloc * (int)Constants.RegionSize; xloc = Util.RegionToWorldLoc(xloc);
yloc = yloc * (int)Constants.RegionSize; yloc = Util.RegionToWorldLoc(yloc);
string reason = string.Empty; string reason = string.Empty;
if (TryCreateLink(UUID.Zero, xloc, yloc, string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason)) if (TryCreateLink(UUID.Zero, (int)xloc, (int)yloc,
string.Empty, externalPort, externalHostName, UUID.Zero, out regInfo, out reason))
{ {
regInfo.RegionName = config.GetString("localName", ""); regInfo.RegionName = config.GetString("localName", "");
} }

View File

@ -179,14 +179,14 @@ namespace OpenSim.Services.Interfaces
protected IPEndPoint m_internalEndPoint; protected IPEndPoint m_internalEndPoint;
/// <summary> /// <summary>
/// The co-ordinate of this region. /// The co-ordinate of this region in region units.
/// </summary> /// </summary>
public int RegionCoordX { get { return RegionLocX / (int)Constants.RegionSize; } } public int RegionCoordX { get { return (int)Util.WorldToRegionLoc((uint)RegionLocX); } }
/// <summary> /// <summary>
/// The co-ordinate of this region /// The co-ordinate of this region in region units
/// </summary> /// </summary>
public int RegionCoordY { get { return RegionLocY / (int)Constants.RegionSize; } } public int RegionCoordY { get { return (int)Util.WorldToRegionLoc((uint)RegionLocY); } }
/// <summary> /// <summary>
/// The location of this region in meters. /// The location of this region in meters.
@ -265,8 +265,8 @@ namespace OpenSim.Services.Interfaces
public GridRegion(uint xcell, uint ycell) public GridRegion(uint xcell, uint ycell)
{ {
m_regionLocX = (int)(xcell * Constants.RegionSize); m_regionLocX = (int)Util.RegionToWorldLoc(xcell);
m_regionLocY = (int)(ycell * Constants.RegionSize); m_regionLocY = (int)Util.RegionToWorldLoc(ycell);
RegionSizeX = (int)Constants.RegionSize; RegionSizeX = (int)Constants.RegionSize;
RegionSizeY = (int)Constants.RegionSize; RegionSizeY = (int)Constants.RegionSize;
} }
@ -274,8 +274,8 @@ namespace OpenSim.Services.Interfaces
public GridRegion(RegionInfo ConvertFrom) public GridRegion(RegionInfo ConvertFrom)
{ {
m_regionName = ConvertFrom.RegionName; m_regionName = ConvertFrom.RegionName;
m_regionLocX = (int)(ConvertFrom.RegionLocX * Constants.RegionSize); m_regionLocX = (int)(ConvertFrom.WorldLocX);
m_regionLocY = (int)(ConvertFrom.RegionLocY * Constants.RegionSize); m_regionLocY = (int)(ConvertFrom.WorldLocY);
RegionSizeX = (int)ConvertFrom.RegionSizeX; RegionSizeX = (int)ConvertFrom.RegionSizeX;
RegionSizeY = (int)ConvertFrom.RegionSizeY; RegionSizeY = (int)ConvertFrom.RegionSizeY;
m_internalEndPoint = ConvertFrom.InternalEndPoint; m_internalEndPoint = ConvertFrom.InternalEndPoint;

View File

@ -368,7 +368,8 @@ namespace OpenSim.Services.LLLoginService
private void FillOutHomeData(GridUserInfo pinfo, GridRegion home) private void FillOutHomeData(GridUserInfo pinfo, GridRegion home)
{ {
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) if (home != null)
{ {
x = home.RegionLocX; x = home.RegionLocX;
@ -443,10 +444,23 @@ namespace OpenSim.Services.LLLoginService
ErrorReason = "key"; ErrorReason = "key";
welcomeMessage = "Welcome to OpenSim!"; welcomeMessage = "Welcome to OpenSim!";
seedCapability = String.Empty; seedCapability = String.Empty;
home = "{'region_handle':[r" + (1000*Constants.RegionSize).ToString() + ",r" + (1000*Constants.RegionSize).ToString() + "], 'position':[r" + home = "{'region_handle':["
userProfile.homepos.X.ToString() + ",r" + userProfile.homepos.Y.ToString() + ",r" + + "r" + Util.RegionToWorldLoc(1000).ToString()
userProfile.homepos.Z.ToString() + "], 'look_at':[r" + userProfile.homelookat.X.ToString() + ",r" + + ","
userProfile.homelookat.Y.ToString() + ",r" + userProfile.homelookat.Z.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]"; lookAt = "[r0.99949799999999999756,r0.03166859999999999814,r0]";
RegionX = (uint) 255232; RegionX = (uint) 255232;
RegionY = (uint) 254976; RegionY = (uint) 254976;

View File

@ -695,7 +695,7 @@ namespace OpenSim.Services.LLLoginService
private GridRegion FindAlternativeRegion(UUID scopeID) private GridRegion FindAlternativeRegion(UUID scopeID)
{ {
List<GridRegion> hyperlinks = null; 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) if (regions != null && regions.Count > 0)
{ {
hyperlinks = m_GridService.GetHyperlinks(scopeID); hyperlinks = m_GridService.GetHyperlinks(scopeID);

View File

@ -150,16 +150,16 @@ namespace OpenSim.Tests.Clients.GridClient
Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)"); Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 2 regions)");
regions = m_Connector.GetRegionRange(UUID.Zero, regions = m_Connector.GetRegionRange(UUID.Zero,
900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize, (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002),
900 * (int)Constants.RegionSize, 1002 * (int) Constants.RegionSize); (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(1002) );
if (regions == null) if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
else else
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions"); Console.WriteLine("[GRID CLIENT]: GetRegionRange returned " + regions.Count + " regions");
Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)"); Console.WriteLine("[GRID CLIENT]: *** GetRegionRange (this should return 0 regions)");
regions = m_Connector.GetRegionRange(UUID.Zero, regions = m_Connector.GetRegionRange(UUID.Zero,
900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize, (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950),
900 * (int)Constants.RegionSize, 950 * (int)Constants.RegionSize); (int)Util.RegionToWorldLoc(900), (int)Util.RegionToWorldLoc(950) );
if (regions == null) if (regions == null)
Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null"); Console.WriteLine("[GRID CLIENT]: GetRegionRange returned null");
else else

View File

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