From f3afa68a2af6ad5999e6efe3e4725cb17293108d Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 14 Feb 2008 12:16:33 +0000 Subject: * 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. --- OpenSim/Region/Environment/Scenes/InnerScene.cs | 2 +- OpenSim/Region/Environment/Scenes/Scene.cs | 24 +++++++++++----------- .../Region/Environment/Scenes/SceneObjectGroup.cs | 2 +- OpenSim/Region/Environment/Scenes/ScenePresence.cs | 23 ++++++++------------- 4 files changed, 23 insertions(+), 28 deletions(-) (limited to 'OpenSim/Region/Environment/Scenes') diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 7698127..48fa3dc 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -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(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5842932..eec51e6 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -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 } diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index aa2f2d0..e8d4766 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -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) diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs index 61fce39..2b02ab9 100644 --- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs @@ -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); -- cgit v1.1