diff options
author | Adam Frisby | 2008-02-14 12:16:33 +0000 |
---|---|---|
committer | Adam Frisby | 2008-02-14 12:16:33 +0000 |
commit | f3afa68a2af6ad5999e6efe3e4725cb17293108d (patch) | |
tree | 4253a44bee39976d6b3dd6813439f5966cf12632 /OpenSim/Region/Environment | |
parent | * Exposed AddHandlers in response to mantis #534. Thanks, kmeisthax! (diff) | |
download | opensim-SC-f3afa68a2af6ad5999e6efe3e4725cb17293108d.zip opensim-SC-f3afa68a2af6ad5999e6efe3e4725cb17293108d.tar.gz opensim-SC-f3afa68a2af6ad5999e6efe3e4725cb17293108d.tar.bz2 opensim-SC-f3afa68a2af6ad5999e6efe3e4725cb17293108d.tar.xz |
* 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.
Diffstat (limited to 'OpenSim/Region/Environment')
9 files changed, 170 insertions, 34 deletions
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs new file mode 100644 index 0000000..9f70b98 --- /dev/null +++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs | |||
@@ -0,0 +1,10 @@ | |||
1 | using System; | ||
2 | namespace OpenSim.Region.Environment.Interfaces | ||
3 | { | ||
4 | interface ITerrainChannel | ||
5 | { | ||
6 | int Height { get; } | ||
7 | double this[int x, int y] { get; set; } | ||
8 | int Width { get; } | ||
9 | } | ||
10 | } | ||
diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index 7cc8519..fec8899 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs | |||
@@ -78,7 +78,7 @@ namespace OpenSim.Region.Environment.LandManagement | |||
78 | /// <returns>Returns true if the piece of land contains the specified point</returns> | 78 | /// <returns>Returns true if the piece of land contains the specified point</returns> |
79 | public bool containsPoint(int x, int y) | 79 | public bool containsPoint(int x, int y) |
80 | { | 80 | { |
81 | if (x >= 0 && y >= 0 && x <= 256 && x <= 256) | 81 | if (x >= 0 && y >= 0 && x <= Constants.RegionSize && x <= Constants.RegionSize) |
82 | { | 82 | { |
83 | return (landBitmap[x/4, y/4] == true); | 83 | return (landBitmap[x/4, y/4] == true); |
84 | } | 84 | } |
@@ -545,7 +545,7 @@ namespace OpenSim.Region.Environment.LandManagement | |||
545 | /// <returns></returns> | 545 | /// <returns></returns> |
546 | public static bool[,] basicFullRegionLandBitmap() | 546 | public static bool[,] basicFullRegionLandBitmap() |
547 | { | 547 | { |
548 | return getSquareLandBitmap(0, 0, 256, 256); | 548 | return getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize); |
549 | } | 549 | } |
550 | 550 | ||
551 | /// <summary> | 551 | /// <summary> |
diff --git a/OpenSim/Region/Environment/LandManagement/LandManager.cs b/OpenSim/Region/Environment/LandManagement/LandManager.cs index a4d8868..f5e2a3e 100644 --- a/OpenSim/Region/Environment/LandManagement/LandManager.cs +++ b/OpenSim/Region/Environment/LandManagement/LandManager.cs | |||
@@ -281,7 +281,7 @@ namespace OpenSim.Region.Environment.LandManagement | |||
281 | 281 | ||
282 | public Land getLandObject(int x, int y) | 282 | public Land getLandObject(int x, int y) |
283 | { | 283 | { |
284 | if (x >= 256 || y >= 256 || x < 0 || y < 0) | 284 | if (x >= Constants.RegionSize || y >= Constants.RegionSize || x < 0 || y < 0) |
285 | { | 285 | { |
286 | // These exceptions here will cause a lot of complaints from the users specifically because | 286 | // These exceptions here will cause a lot of complaints from the users specifically because |
287 | // they happen every time at border crossings | 287 | // they happen every time at border crossings |
@@ -614,7 +614,7 @@ namespace OpenSim.Region.Environment.LandManagement | |||
614 | 614 | ||
615 | Land fullSimParcel = new Land(LLUUID.Zero, false, m_scene); | 615 | Land fullSimParcel = new Land(LLUUID.Zero, false, m_scene); |
616 | 616 | ||
617 | fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, 256, 256)); | 617 | fullSimParcel.setLandBitmap(Land.getSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize)); |
618 | fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID; | 618 | fullSimParcel.landData.ownerID = m_regInfo.MasterAvatarAssignedUUID; |
619 | 619 | ||
620 | addLandObject(fullSimParcel); | 620 | addLandObject(fullSimParcel); |
diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 82bd2ec..a34bd96 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs | |||
@@ -223,7 +223,7 @@ namespace OpenSim.Region.Environment.Modules | |||
223 | 223 | ||
224 | // Filled in since it's easier than rewriting right now. | 224 | // Filled in since it's easier than rewriting right now. |
225 | LLVector3 fromPos = e.Position; | 225 | LLVector3 fromPos = e.Position; |
226 | LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); | 226 | LLVector3 regionPos = new LLVector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
227 | 227 | ||
228 | string fromName = e.From; | 228 | string fromName = e.From; |
229 | string message = e.Message; | 229 | string message = e.Message; |
@@ -237,7 +237,7 @@ namespace OpenSim.Region.Environment.Modules | |||
237 | if (avatar != null) | 237 | if (avatar != null) |
238 | { | 238 | { |
239 | fromPos = avatar.AbsolutePosition; | 239 | fromPos = avatar.AbsolutePosition; |
240 | regionPos = new LLVector3(scene.RegionInfo.RegionLocX*256, scene.RegionInfo.RegionLocY*256, 0); | 240 | regionPos = new LLVector3(scene.RegionInfo.RegionLocX * Constants.RegionSize, scene.RegionInfo.RegionLocY * Constants.RegionSize, 0); |
241 | fromName = avatar.Firstname + " " + avatar.Lastname; | 241 | fromName = avatar.Firstname + " " + avatar.Lastname; |
242 | fromAgentID = e.Sender.AgentId; | 242 | fromAgentID = e.Sender.AgentId; |
243 | } | 243 | } |
diff --git a/OpenSim/Region/Environment/Modules/TerrainModule.cs b/OpenSim/Region/Environment/Modules/TerrainModule.cs new file mode 100644 index 0000000..7e163a3 --- /dev/null +++ b/OpenSim/Region/Environment/Modules/TerrainModule.cs | |||
@@ -0,0 +1,131 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | |||
29 | using Nini.Config; | ||
30 | using System; | ||
31 | using System.Collections; | ||
32 | using System.Collections.Generic; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Region.Environment.Interfaces; | ||
36 | using OpenSim.Region.Environment.Scenes; | ||
37 | using libsecondlife; | ||
38 | |||
39 | namespace OpenSim.Region.Environment.Modules | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// A new version of the old Channel class, simplified | ||
43 | /// </summary> | ||
44 | public class TerrainChannel : ITerrainChannel | ||
45 | { | ||
46 | private double[,] map; | ||
47 | |||
48 | public int Width | ||
49 | { | ||
50 | get { return map.GetLength(0); } | ||
51 | } | ||
52 | |||
53 | public int Height | ||
54 | { | ||
55 | get { return map.GetLength(1); } | ||
56 | } | ||
57 | |||
58 | public TerrainChannel Copy() | ||
59 | { | ||
60 | TerrainChannel copy = new TerrainChannel(false); | ||
61 | copy.map = (double[,])this.map.Clone(); | ||
62 | |||
63 | return copy; | ||
64 | } | ||
65 | |||
66 | public double this[int x, int y] | ||
67 | { | ||
68 | get | ||
69 | { | ||
70 | return map[x, y]; | ||
71 | } | ||
72 | set | ||
73 | { | ||
74 | map[x, y] = value; | ||
75 | } | ||
76 | } | ||
77 | |||
78 | public TerrainChannel() | ||
79 | { | ||
80 | map = new double[Constants.RegionSize, Constants.RegionSize]; | ||
81 | } | ||
82 | |||
83 | public TerrainChannel(bool createMap) | ||
84 | { | ||
85 | if (createMap) | ||
86 | map = new double[Constants.RegionSize, Constants.RegionSize]; | ||
87 | } | ||
88 | |||
89 | public TerrainChannel(int w, int h) | ||
90 | { | ||
91 | map = new double[w, h]; | ||
92 | } | ||
93 | } | ||
94 | |||
95 | public class TerrainModule : IRegionModule | ||
96 | { | ||
97 | private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | ||
98 | |||
99 | Scene m_scene; | ||
100 | |||
101 | private IConfigSource m_gConfig; | ||
102 | |||
103 | public void Initialise(Scene scene, IConfigSource config) | ||
104 | { | ||
105 | m_scene = scene; | ||
106 | m_gConfig = config; | ||
107 | } | ||
108 | |||
109 | public void Close() | ||
110 | { | ||
111 | |||
112 | } | ||
113 | |||
114 | public string Name | ||
115 | { | ||
116 | get { return "TerrainModule"; } | ||
117 | } | ||
118 | |||
119 | public bool IsSharedModule | ||
120 | { | ||
121 | get { return false; } | ||
122 | } | ||
123 | |||
124 | public void PostInitialise() | ||
125 | { | ||
126 | |||
127 | } | ||
128 | |||
129 | } | ||
130 | |||
131 | } | ||
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 | |||
81 | m_parentScene = parent; | 81 | m_parentScene = parent; |
82 | m_regInfo = regInfo; | 82 | m_regInfo = regInfo; |
83 | PermissionsMngr = permissionsMngr; | 83 | PermissionsMngr = permissionsMngr; |
84 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, 256, 256); | 84 | QuadTree = new BasicQuadTreeNode(null, "/0/", 0, 0, (short)Constants.RegionSize, (short)Constants.RegionSize); |
85 | QuadTree.Subdivide(); | 85 | QuadTree.Subdivide(); |
86 | QuadTree.Subdivide(); | 86 | QuadTree.Subdivide(); |
87 | } | 87 | } |
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 | |||
1232 | ulong newRegionHandle = 0; | 1232 | ulong newRegionHandle = 0; |
1233 | LLVector3 pos = position; | 1233 | LLVector3 pos = position; |
1234 | 1234 | ||
1235 | if (position.X > 257f) | 1235 | if (position.X > Constants.RegionSize + 0.1f) |
1236 | { | 1236 | { |
1237 | pos.X = ((pos.X - 256)); | 1237 | pos.X = ((pos.X - Constants.RegionSize)); |
1238 | 1238 | ||
1239 | newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * 256), (uint)(thisy * 256)); | 1239 | newRegionHandle = Util.UIntsToLong((uint)((thisx + 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); |
1240 | 1240 | ||
1241 | // x + 1 | 1241 | // x + 1 |
1242 | } | 1242 | } |
1243 | else if (position.X < -1f) | 1243 | else if (position.X < -0.1f) |
1244 | { | 1244 | { |
1245 | pos.X = ((pos.X + 256)); | 1245 | pos.X = ((pos.X + Constants.RegionSize)); |
1246 | newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * 256), (uint)(thisy * 256)); | 1246 | newRegionHandle = Util.UIntsToLong((uint)((thisx - 1) * Constants.RegionSize), (uint)(thisy * Constants.RegionSize)); |
1247 | // x - 1 | 1247 | // x - 1 |
1248 | } | 1248 | } |
1249 | 1249 | ||
1250 | if (position.Y > 257f) | 1250 | if (position.Y > Constants.RegionSize + 0.1f) |
1251 | { | 1251 | { |
1252 | pos.Y = ((pos.Y - 256)); | 1252 | pos.Y = ((pos.Y - Constants.RegionSize)); |
1253 | newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy + 1) * 256)); | 1253 | newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + 1) * Constants.RegionSize)); |
1254 | // y + 1 | 1254 | // y + 1 |
1255 | } | 1255 | } |
1256 | else if (position.Y < -1f) | 1256 | else if (position.Y < -1f) |
1257 | { | 1257 | { |
1258 | pos.Y = ((pos.Y + 256)); | 1258 | pos.Y = ((pos.Y + Constants.RegionSize)); |
1259 | newRegionHandle = Util.UIntsToLong((uint)(thisx * 256), (uint)((thisy - 1) * 256)); | 1259 | newRegionHandle = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - 1) * Constants.RegionSize)); |
1260 | // y - 1 | 1260 | // y - 1 |
1261 | } | 1261 | } |
1262 | 1262 | ||
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 | |||
387 | // This may need to be updated to the maximum draw distance possible.. | 387 | // This may need to be updated to the maximum draw distance possible.. |
388 | // We might (and probably will) be checking for prim creation from other sims | 388 | // We might (and probably will) be checking for prim creation from other sims |
389 | // when the camera crosses the border. | 389 | // when the camera crosses the border. |
390 | float idist = 256f; | 390 | float idist = (float)Constants.RegionSize; |
391 | 391 | ||
392 | 392 | ||
393 | if (inter.HitTF) | 393 | 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 | |||
1514 | pos2.Y = pos2.Y + (vel.Y*timeStep); | 1514 | pos2.Y = pos2.Y + (vel.Y*timeStep); |
1515 | pos2.Z = pos2.Z + (vel.Z*timeStep); | 1515 | pos2.Z = pos2.Z + (vel.Z*timeStep); |
1516 | 1516 | ||
1517 | if ((pos2.X < 0) || (pos2.X > 256)) | 1517 | if ((pos2.X < 0) || (pos2.X > Constants.RegionSize)) |
1518 | { | 1518 | { |
1519 | CrossToNewRegion(); | 1519 | CrossToNewRegion(); |
1520 | } | 1520 | } |
1521 | 1521 | ||
1522 | if ((pos2.Y < 0) || (pos2.Y > 256)) | 1522 | if ((pos2.Y < 0) || (pos2.Y > Constants.RegionSize)) |
1523 | { | 1523 | { |
1524 | CrossToNewRegion(); | 1524 | CrossToNewRegion(); |
1525 | } | 1525 | } |
@@ -1544,17 +1544,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
1544 | // distance into new region to place avatar | 1544 | // distance into new region to place avatar |
1545 | const float enterDistance = 0.1f; | 1545 | const float enterDistance = 0.1f; |
1546 | 1546 | ||
1547 | // region size | ||
1548 | // TODO: this should be hard-coded in some common place | ||
1549 | const float regionWidth = 256; | ||
1550 | const float regionHeight = 256; | ||
1551 | |||
1552 | if (pos.X < boundaryDistance) | 1547 | if (pos.X < boundaryDistance) |
1553 | { | 1548 | { |
1554 | neighbourx--; | 1549 | neighbourx--; |
1555 | newpos.X = regionWidth - enterDistance; | 1550 | newpos.X = Constants.RegionSize - enterDistance; |
1556 | } | 1551 | } |
1557 | else if (pos.X > regionWidth - boundaryDistance) | 1552 | else if (pos.X > Constants.RegionSize - boundaryDistance) |
1558 | { | 1553 | { |
1559 | neighbourx++; | 1554 | neighbourx++; |
1560 | newpos.X = enterDistance; | 1555 | newpos.X = enterDistance; |
@@ -1563,16 +1558,16 @@ namespace OpenSim.Region.Environment.Scenes | |||
1563 | if (pos.Y < boundaryDistance) | 1558 | if (pos.Y < boundaryDistance) |
1564 | { | 1559 | { |
1565 | neighboury--; | 1560 | neighboury--; |
1566 | newpos.Y = regionHeight - enterDistance; | 1561 | newpos.Y = Constants.RegionSize - enterDistance; |
1567 | } | 1562 | } |
1568 | else if (pos.Y > regionHeight - boundaryDistance) | 1563 | else if (pos.Y > Constants.RegionSize - boundaryDistance) |
1569 | { | 1564 | { |
1570 | neighboury++; | 1565 | neighboury++; |
1571 | newpos.Y = enterDistance; | 1566 | newpos.Y = enterDistance; |
1572 | } | 1567 | } |
1573 | 1568 | ||
1574 | LLVector3 vel = m_velocity; | 1569 | LLVector3 vel = m_velocity; |
1575 | ulong neighbourHandle = Helpers.UIntsToLong((uint) (neighbourx*256), (uint) (neighboury*256)); | 1570 | ulong neighbourHandle = Helpers.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); |
1576 | SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); | 1571 | SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); |
1577 | if (neighbourRegion != null) | 1572 | if (neighbourRegion != null) |
1578 | { | 1573 | { |
@@ -1622,8 +1617,8 @@ namespace OpenSim.Region.Environment.Scenes | |||
1622 | public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) | 1617 | public void ChildAgentDataUpdate(ChildAgentDataUpdate cAgentData, uint tRegionX, uint tRegionY, uint rRegionX, uint rRegionY) |
1623 | { | 1618 | { |
1624 | // | 1619 | // |
1625 | int shiftx = ((int)rRegionX - (int)tRegionX) * 256; | 1620 | int shiftx = ((int)rRegionX - (int)tRegionX) * (int)Constants.RegionSize; |
1626 | int shifty = ((int)rRegionY - (int)tRegionY) * 256; | 1621 | int shifty = ((int)rRegionY - (int)tRegionY) * (int)Constants.RegionSize; |
1627 | 1622 | ||
1628 | m_DrawDistance = cAgentData.drawdistance; | 1623 | m_DrawDistance = cAgentData.drawdistance; |
1629 | m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z); | 1624 | m_pos = new LLVector3(cAgentData.Position.x + shiftx, cAgentData.Position.y + shifty, cAgentData.Position.z); |