mirror of
https://github.com/opensim/opensim.git
synced 2026-07-31 13:55:35 +08:00
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.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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++)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -169,7 +169,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
|
||||
c.Channel = m_channelNotify;
|
||||
c.Message += numScriptsFailed.ToString() + "," + message;
|
||||
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.SenderUUID = UUID.Zero;
|
||||
c.Scene = m_scene;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user