diff options
author | Robert Adams | 2015-03-29 14:25:12 -0700 |
---|---|---|
committer | Robert Adams | 2015-03-29 14:25:12 -0700 |
commit | 07dead7dcb8b0f2a27a50748e4a460d9669903fc (patch) | |
tree | b61c3d892e83d36fece40e7735c5d97e64b9020f /OpenSim/Region/CoreModules/World | |
parent | varregion: add varregion and TerrainData use in LLClientView. (diff) | |
download | opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.zip opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.gz opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.bz2 opensim-SC_OLD-07dead7dcb8b0f2a27a50748e4a460d9669903fc.tar.xz |
varregion: any conversions of use of Constants.RegionSize converted into
Util.cs routines to convert region coords to and from world coords or handles.
Diffstat (limited to 'OpenSim/Region/CoreModules/World')
8 files changed, 47 insertions, 51 deletions
diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs index 7a844f4..cd95ee9 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveWriteRequest.cs | |||
@@ -533,7 +533,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver | |||
533 | if (isMegaregion) | 533 | if (isMegaregion) |
534 | size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID); | 534 | size = rcMod.GetSizeOfMegaregion(scene.RegionInfo.RegionID); |
535 | else | 535 | else |
536 | size = new Vector2((float)Constants.RegionSize, (float)Constants.RegionSize); | 536 | size = new Vector2((float)scene.RegionInfo.RegionSizeX, (float)scene.RegionInfo.RegionSizeY); |
537 | 537 | ||
538 | xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); | 538 | xtw.WriteElementString("is_megaregion", isMegaregion.ToString()); |
539 | xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); | 539 | xtw.WriteElementString("size_in_meters", string.Format("{0},{1}", size.X, size.Y)); |
diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index d4e4c25..014c845 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs | |||
@@ -151,14 +151,9 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell | |||
151 | break; | 151 | break; |
152 | 152 | ||
153 | case 2: // Sell a copy | 153 | case 2: // Sell a copy |
154 | Vector3 inventoryStoredPosition = new Vector3 | 154 | Vector3 inventoryStoredPosition = new Vector3( |
155 | (((group.AbsolutePosition.X > (int)Constants.RegionSize) | 155 | Math.Min(group.AbsolutePosition.X, m_scene.RegionInfo.RegionSizeX - 6), |
156 | ? 250 | 156 | Math.Min(group.AbsolutePosition.Y, m_scene.RegionInfo.RegionSizeY - 6), |
157 | : group.AbsolutePosition.X) | ||
158 | , | ||
159 | (group.AbsolutePosition.X > (int)Constants.RegionSize) | ||
160 | ? 250 | ||
161 | : group.AbsolutePosition.X, | ||
162 | group.AbsolutePosition.Z); | 157 | group.AbsolutePosition.Z); |
163 | 158 | ||
164 | Vector3 originalPosition = group.AbsolutePosition; | 159 | Vector3 originalPosition = group.AbsolutePosition; |
diff --git a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs index 616fe98..928755d 100644 --- a/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs +++ b/OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs | |||
@@ -1571,10 +1571,10 @@ namespace OpenSim.Region.CoreModules.World.Permissions | |||
1571 | float X = position.X; | 1571 | float X = position.X; |
1572 | float Y = position.Y; | 1572 | float Y = position.Y; |
1573 | 1573 | ||
1574 | if (X > ((int)Constants.RegionSize - 1)) | 1574 | if (X > ((int)m_scene.RegionInfo.RegionSizeX - 1)) |
1575 | X = ((int)Constants.RegionSize - 1); | 1575 | X = ((int)m_scene.RegionInfo.RegionSizeX - 1); |
1576 | if (Y > ((int)Constants.RegionSize - 1)) | 1576 | if (Y > ((int)m_scene.RegionInfo.RegionSizeY - 1)) |
1577 | Y = ((int)Constants.RegionSize - 1); | 1577 | Y = ((int)m_scene.RegionInfo.RegionSizeY - 1); |
1578 | if (X < 0) | 1578 | if (X < 0) |
1579 | X = 0; | 1579 | X = 0; |
1580 | if (Y < 0) | 1580 | if (Y < 0) |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs index 7186dd7..80396c4 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects | |||
42 | for (y = 0; y < map.Height; y++) | 42 | for (y = 0; y < map.Height; y++) |
43 | { | 43 | { |
44 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; | 44 | map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 3, 0.25) * 10; |
45 | double spherFac = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2, Constants.RegionSize / 2, 50) * 0.01; | 45 | double spherFac = TerrainUtil.SphericalFactor(x, y, map.Width / 2, map.Height / 2, 50) * 0.01; |
46 | if (map[x, y] < spherFac) | 46 | if (map[x, y] < spherFac) |
47 | { | 47 | { |
48 | map[x, y] = spherFac; | 48 | map[x, y] = spherFac; |
@@ -53,4 +53,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects | |||
53 | 53 | ||
54 | #endregion | 54 | #endregion |
55 | } | 55 | } |
56 | } \ No newline at end of file | 56 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs index b5c7d33..a7e4d9f 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FileLoaders/Terragen.cs | |||
@@ -154,10 +154,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
154 | 154 | ||
155 | public ITerrainChannel LoadStream(Stream s) | 155 | public ITerrainChannel LoadStream(Stream s) |
156 | { | 156 | { |
157 | 157 | // Set to default size | |
158 | int w = (int)Constants.RegionSize; | 158 | int w = (int)Constants.RegionSize; |
159 | int h = (int)Constants.RegionSize; | 159 | int h = (int)Constants.RegionSize; |
160 | 160 | ||
161 | // create a dummy channel (in case data is bad) | ||
161 | TerrainChannel retval = new TerrainChannel(w, h); | 162 | TerrainChannel retval = new TerrainChannel(w, h); |
162 | 163 | ||
163 | BinaryReader bs = new BinaryReader(s); | 164 | BinaryReader bs = new BinaryReader(s); |
@@ -165,8 +166,6 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
165 | bool eof = false; | 166 | bool eof = false; |
166 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") | 167 | if (Encoding.ASCII.GetString(bs.ReadBytes(16)) == "TERRAGENTERRAIN ") |
167 | { | 168 | { |
168 | // int fileWidth = w; | ||
169 | // int fileHeight = h; | ||
170 | 169 | ||
171 | // Terragen file | 170 | // Terragen file |
172 | while (eof == false) | 171 | while (eof == false) |
@@ -175,31 +174,29 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
175 | switch (tmp) | 174 | switch (tmp) |
176 | { | 175 | { |
177 | case "SIZE": | 176 | case "SIZE": |
178 | // int sztmp = bs.ReadInt16() + 1; | 177 | w = bs.ReadInt16() + 1; |
179 | // fileWidth = sztmp; | 178 | h = w; |
180 | // fileHeight = sztmp; | ||
181 | bs.ReadInt16(); | ||
182 | bs.ReadInt16(); | 179 | bs.ReadInt16(); |
183 | break; | 180 | break; |
184 | case "XPTS": | 181 | case "XPTS": |
185 | // fileWidth = bs.ReadInt16(); | 182 | w = bs.ReadInt16(); |
186 | bs.ReadInt16(); | ||
187 | bs.ReadInt16(); | 183 | bs.ReadInt16(); |
188 | break; | 184 | break; |
189 | case "YPTS": | 185 | case "YPTS": |
190 | // fileHeight = bs.ReadInt16(); | 186 | h = bs.ReadInt16(); |
191 | bs.ReadInt16(); | ||
192 | bs.ReadInt16(); | 187 | bs.ReadInt16(); |
193 | break; | 188 | break; |
194 | case "ALTW": | 189 | case "ALTW": |
195 | eof = true; | 190 | eof = true; |
196 | Int16 heightScale = bs.ReadInt16(); | 191 | // create new channel of proper size (now that we know it) |
197 | Int16 baseHeight = bs.ReadInt16(); | 192 | retval = new TerrainChannel(w, h); |
193 | double heightScale = (double)bs.ReadInt16() / 65536.0; | ||
194 | double baseHeight = (double)bs.ReadInt16(); | ||
198 | for (int y = 0; y < h; y++) | 195 | for (int y = 0; y < h; y++) |
199 | { | 196 | { |
200 | for (int x = 0; x < w; x++) | 197 | for (int x = 0; x < w; x++) |
201 | { | 198 | { |
202 | retval[x, y] = baseHeight + bs.ReadInt16() * (double)heightScale / 65536.0; | 199 | retval[x, y] = baseHeight + (double)bs.ReadInt16() * heightScale; |
203 | } | 200 | } |
204 | } | 201 | } |
205 | break; | 202 | break; |
@@ -257,17 +254,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
257 | bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); | 254 | bs.Write(enc.GetBytes("TERRAGENTERRAIN ")); |
258 | 255 | ||
259 | bs.Write(enc.GetBytes("SIZE")); | 256 | bs.Write(enc.GetBytes("SIZE")); |
260 | bs.Write(Convert.ToInt16(Constants.RegionSize)); | 257 | bs.Write(Convert.ToInt16(map.Width)); |
261 | bs.Write(Convert.ToInt16(0)); // necessary padding | 258 | bs.Write(Convert.ToInt16(0)); // necessary padding |
262 | 259 | ||
263 | //The XPTS and YPTS chunks are not needed for square regions | 260 | //The XPTS and YPTS chunks are not needed for square regions |
264 | //but L3DT won't load the terrain file properly without them. | 261 | //but L3DT won't load the terrain file properly without them. |
265 | bs.Write(enc.GetBytes("XPTS")); | 262 | bs.Write(enc.GetBytes("XPTS")); |
266 | bs.Write(Convert.ToInt16(Constants.RegionSize)); | 263 | bs.Write(Convert.ToInt16(map.Width)); |
267 | bs.Write(Convert.ToInt16(0)); // necessary padding | 264 | bs.Write(Convert.ToInt16(0)); // necessary padding |
268 | 265 | ||
269 | bs.Write(enc.GetBytes("YPTS")); | 266 | bs.Write(enc.GetBytes("YPTS")); |
270 | bs.Write(Convert.ToInt16(Constants.RegionSize)); | 267 | bs.Write(Convert.ToInt16(map.Height)); |
271 | bs.Write(Convert.ToInt16(0)); // necessary padding | 268 | bs.Write(Convert.ToInt16(0)); // necessary padding |
272 | 269 | ||
273 | bs.Write(enc.GetBytes("SCAL")); | 270 | bs.Write(enc.GetBytes("SCAL")); |
@@ -283,11 +280,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FileLoaders | |||
283 | bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min | 280 | bs.Write(Convert.ToInt16(horizontalScale)); // range between max and min |
284 | bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point | 281 | bs.Write(Convert.ToInt16(baseHeight)); // base height or mid point |
285 | 282 | ||
283 | double factor = 65536.0 / horizontalScale; // avoid computing this on each iteration | ||
284 | |||
286 | for (int y = 0; y < map.Height; y++) | 285 | for (int y = 0; y < map.Height; y++) |
287 | { | 286 | { |
288 | for (int x = 0; x < map.Width; x++) | 287 | for (int x = 0; x < map.Width; x++) |
289 | { | 288 | { |
290 | float elevation = (float)((map[x,y] - baseHeight) * 65536 ) / (float)horizontalScale; // see LoadStream for inverse | 289 | float elevation = (float)((map[x,y] - baseHeight) * factor); // see LoadStream for inverse |
291 | 290 | ||
292 | // clamp rounding issues | 291 | // clamp rounding issues |
293 | if (elevation > Int16.MaxValue) | 292 | if (elevation > Int16.MaxValue) |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs index 630473e..d3e2533 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs | |||
@@ -45,7 +45,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
45 | { | 45 | { |
46 | if (fillArea[x, y]) | 46 | if (fillArea[x, y]) |
47 | { | 47 | { |
48 | double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0); | 48 | double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0); |
49 | 49 | ||
50 | map[x, y] += noise * strength; | 50 | map[x, y] += noise * strength; |
51 | } | 51 | } |
@@ -55,4 +55,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes | |||
55 | 55 | ||
56 | #endregion | 56 | #endregion |
57 | } | 57 | } |
58 | } \ No newline at end of file | 58 | } |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs index 989b7d8..e7df3f8 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes | |||
53 | z *= z; | 53 | z *= z; |
54 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 54 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
55 | 55 | ||
56 | double noise = TerrainUtil.PerlinNoise2D(x / (double) Constants.RegionSize, y / (double) Constants.RegionSize, 8, 1.0); | 56 | double noise = TerrainUtil.PerlinNoise2D(x / (double) map.Width, y / (double) map.Height, 8, 1.0); |
57 | 57 | ||
58 | if (z > 0.0) | 58 | if (z > 0.0) |
59 | map[x, y] += noise * z * duration; | 59 | map[x, y] += noise * z * duration; |
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs index be719ea..062d7ff 100644 --- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs +++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs | |||
@@ -40,10 +40,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests | |||
40 | [Test] | 40 | [Test] |
41 | public void BrushTest() | 41 | public void BrushTest() |
42 | { | 42 | { |
43 | int midRegion = (int)Constants.RegionSize / 2; | ||
44 | |||
45 | // Create a mask that covers only the left half of the region | ||
43 | bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; | 46 | bool[,] allowMask = new bool[(int)Constants.RegionSize, 256]; |
44 | int x; | 47 | int x; |
45 | int y; | 48 | int y; |
46 | for (x = 0; x < (int)((int)Constants.RegionSize * 0.5f); x++) | 49 | for (x = 0; x < midRegion; x++) |
47 | { | 50 | { |
48 | for (y = 0; y < (int)Constants.RegionSize; y++) | 51 | for (y = 0; y < (int)Constants.RegionSize; y++) |
49 | { | 52 | { |
@@ -57,13 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests | |||
57 | TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); | 60 | TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); |
58 | ITerrainPaintableEffect effect = new RaiseSphere(); | 61 | ITerrainPaintableEffect effect = new RaiseSphere(); |
59 | 62 | ||
60 | effect.PaintEffect(map, allowMask, (int)Constants.RegionSize * 0.5f, (int)Constants.RegionSize * 0.5f, -1.0, 2, 0.1); | 63 | effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); |
61 | Assert.That(map[127, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (127,128)."); | 64 | Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128)."); |
62 | Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] > 0.0, "Raise brush should raising value at this point (124,128)."); | 65 | Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128)."); |
63 | Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (123,128)."); | 66 | Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128)."); |
64 | Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (128,128)."); | 67 | Assert.That(map[128, midRegion] == 0.0, "Raise brush should not change value at this point (128,128)."); |
65 | Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 0.0, "Raise brush should not change value at this point (0,128)."); | 68 | Assert.That(map[0, midRegion] == 0.0, "Raise brush should not change value at this point (0,128)."); |
66 | |||
67 | // | 69 | // |
68 | // Test LowerSphere | 70 | // Test LowerSphere |
69 | // | 71 | // |
@@ -77,13 +79,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests | |||
77 | } | 79 | } |
78 | effect = new LowerSphere(); | 80 | effect = new LowerSphere(); |
79 | 81 | ||
80 | effect.PaintEffect(map, allowMask, ((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), -1.0, 2, 6.0); | 82 | effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); |
81 | 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)."); | 83 | Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); |
82 | 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)."); | 84 | Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128)."); |
83 | Assert.That(map[124, (int)((int)Constants.RegionSize * 0.5f)] < 1.0, "Lower brush should lowering value at this point (124,128)."); | 85 | Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128)."); |
84 | Assert.That(map[123, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (123,128)."); | 86 | Assert.That(map[120, midRegion] == 1.0, "Lower brush should not change value at this point (120,128)."); |
85 | Assert.That(map[128, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (128,128)."); | 87 | Assert.That(map[128, midRegion] == 1.0, "Lower brush should not change value at this point (128,128)."); |
86 | Assert.That(map[0, (int)((int)Constants.RegionSize * 0.5f)] == 1.0, "Lower brush should not change value at this point (0,128)."); | 88 | Assert.That(map[0, midRegion] == 1.0, "Lower brush should not change value at this point (0,128)."); |
87 | } | 89 | } |
88 | 90 | ||
89 | [Test] | 91 | [Test] |