* Made new Framework.Constants class, added RegionSize member.

* Converted all instances of "256" spotted to use RegionSize instead. Some approximations used for border crossings (ie 255.9f) are still using that value, but should be updated to use something based on RegionSize.
* Moving Terrain to a RegionModule, implemented ITerrainChannel and TerrainModule - nonfunctional, but will be soon.
This commit is contained in:
Adam Frisby
2008-02-14 12:16:33 +00:00
parent c0d411f427
commit f3afa68a2a
26 changed files with 276 additions and 111 deletions

View File

@@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Scenes
m_parentScene = parent;
m_regInfo = regInfo;
PermissionsMngr = permissionsMngr;
QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256);
QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize);
QuadTree.Subdivide();
QuadTree.Subdivide();
}

View File

@@ -1232,31 +1232,31 @@ namespace OpenSim.Region.Environment.Scenes
ulong newRegionHandle = 0;
LLVector3 pos = position;
if (position.X > 257f)
if (position.X > Constants.RegionSize + 0.1f)
{
pos.X = ((pos.X - 256));
newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256));
pos.X = ((pos.X - Constants.RegionSize));
newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize));
// x + 1
}
else if (position.X < -1f)
else if (position.X < -0.1f)
{
pos.X = ((pos.X + 256));
newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256));
pos.X = ((pos.X + Constants.RegionSize));
newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize));
// x - 1
}
if (position.Y > 257f)
if (position.Y > Constants.RegionSize + 0.1f)
{
pos.Y = ((pos.Y - 256));
newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256));
pos.Y = ((pos.Y - Constants.RegionSize));
newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize));
// y + 1
}
else if (position.Y < -1f)
{
pos.Y = ((pos.Y + 256));
newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256));
pos.Y = ((pos.Y + Constants.RegionSize));
newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize));
// y - 1
}

View File

@@ -387,7 +387,7 @@ namespace OpenSim.Region.Environment.Scenes
// This may need to be updated to the maximum draw distance possible..
// We might (and probably will) be checking for prim creation from other sims
// when the camera crosses the border.
float idist = 256f;
float idist = (float)Constants.RegionSize;
if (inter.HitTF)

View File

@@ -1514,12 +1514,12 @@ namespace OpenSim.Region.Environment.Scenes
pos2.Y = pos2.Y + (vel.Y*timeStep);
pos2.Z = pos2.Z + (vel.Z*timeStep);
if ((pos2.X < 0) || (pos2.X > 256))
if ((pos2.X < 0) || (pos2.X > Constants.RegionSize))
{
CrossToNewRegion();
}
if ((pos2.Y < 0) || (pos2.Y > 256))
if ((pos2.Y < 0) || (pos2.Y > Constants.RegionSize))
{
CrossToNewRegion();
}
@@ -1544,17 +1544,12 @@ namespace OpenSim.Region.Environment.Scenes
// distance into new region to place avatar
const float enterDistance = 0.1f;
// region size
// TODO: this should be hard-coded in some common place
const float regionWidth = 256;
const float regionHeight = 256;
if (pos.X < boundaryDistance)
{
neighbourx--;
newpos.X = regionWidth - enterDistance;
newpos.X = Constants.RegionSize - enterDistance;
}
else if (pos.X > regionWidth - boundaryDistance)
else if (pos.X > Constants.RegionSize - boundaryDistance)
{
neighbourx++;
newpos.X = enterDistance;
@@ -1563,16 +1558,16 @@ namespace OpenSim.Region.Environment.Scenes
if (pos.Y < boundaryDistance)
{
neighboury--;
newpos.Y = regionHeight - enterDistance;
newpos.Y = Constants.RegionSize - enterDistance;
}
else if (pos.Y > regionHeight - boundaryDistance)
else if (pos.Y > Constants.RegionSize - boundaryDistance)
{
neighboury++;
newpos.Y = enterDistance;
}
LLVector3 vel = m_velocity;
ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256));
ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
if (neighbourRegion != null)
{
@@ -1622,8 +1617,8 @@ namespace OpenSim.Region.Environment.Scenes
public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY)
{
//
int shiftx = ((int)rRegionX - (int)tRegionX) * 256;
int shifty = ((int)rRegionY - (int)tRegionY) * 256;
int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize;
int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize;
m_DrawDistance = cAgentData.drawdistance;
m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z);