aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/World/Terrain
diff options
context:
space:
mode:
authorUbitUmarov2015-09-01 14:54:35 +0100
committerUbitUmarov2015-09-01 14:54:35 +0100
commit371c9dd2af01a2e7422ec901ee1f80757284a78c (patch)
tree058d2a513cacb12efcce0c0df0ae14ad135dbfe2 /OpenSim/Region/CoreModules/World/Terrain
parentremove lixo (diff)
parentdont change camera on crossings (diff)
downloadopensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.zip
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.gz
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.bz2
opensim-SC_OLD-371c9dd2af01a2e7422ec901ee1f80757284a78c.tar.xz
bad merge?
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Terrain')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs4
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs2
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs15
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs11
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs3
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs29
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs7
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs28
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs13
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs30
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs12
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs16
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs10
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs480
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs10
22 files changed, 591 insertions, 137 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
index 36917e9..b456aa1 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/ChannelDigger.cs
@@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
64 64
65 for (int i = 0; i < rounds; i++) 65 for (int i = 0; i < rounds; i++)
66 { 66 {
67 smoothFunction.FloodEffect(map, bitmap, 1.0); 67 smoothFunction.FloodEffect(map, bitmap, 1.0, 0, map.Width - 1, 0, map.Height - 1);
68 } 68 }
69 } 69 }
70 70
@@ -99,7 +99,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
99 } 99 }
100 } 100 }
101 101
102 raiseFunction.FloodEffect(map, bitmap, height); 102 raiseFunction.FloodEffect(map, bitmap, height, 0, map.Width - 1, 0, map.Height - 1);
103 } 103 }
104 } 104 }
105 } 105 }
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
index dc76ad5..3222524 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/CookieCutter.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Effects
84 for (y = 0; y < map.Height; y++) 84 for (y = 0; y < map.Height; y++)
85 { 85 {
86 if (cliffMask[x, y]) 86 if (cliffMask[x, y])
87 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1); 87 eroder.PaintEffect(map, allowMask, x, y, -1, 4, 0.1,0,map.Width - 1,0,map.Height - 1);
88 } 88 }
89 } 89 }
90 90
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
index 89087b1..80396c4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Effects/DefaultTerrainGenerator.cs
@@ -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/FloodBrushes/FlattenArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
index 774e7b2..0c4171e 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/FlattenArea.cs
@@ -33,15 +33,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 double sum = 0.0; 39 double sum = 0.0;
39 double steps = 0.0; 40 double steps = 0.0;
40 41
41 int x, y; 42 int x, y;
42 for (x = 0; x < map.Width; x++) 43 for (x = startX; x <= endX; x++)
43 { 44 {
44 for (y = 0; y < map.Height; y++) 45 for (y = startY; y <= endY; y++)
45 { 46 {
46 if (fillArea[x, y]) 47 if (fillArea[x, y])
47 { 48 {
@@ -55,9 +56,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
55 56
56 double str = 0.1 * strength; // == 0.2 in the default client 57 double str = 0.1 * strength; // == 0.2 in the default client
57 58
58 for (x = 0; x < map.Width; x++) 59 for (x = startX; x <= endX; x++)
59 { 60 {
60 for (y = 0; y < map.Height; y++) 61 for (y = startY; y <= endY; y++)
61 { 62 {
62 if (fillArea[x, y]) 63 if (fillArea[x, y])
63 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); 64 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
index 3e87390..a275a86 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/LowerArea.cs
@@ -33,13 +33,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 int x; 39 int x,y;
39 for (x = 0; x < map.Width; x++) 40 for (x = startX; x <= endX; x++)
40 { 41 {
41 int y; 42 for (y = startY; y <= endY; y++)
42 for (y = 0; y < map.Height; y++)
43 { 43 {
44 if (fillArea[x, y]) 44 if (fillArea[x, y])
45 { 45 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
index b6c635c..236584a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/NoiseArea.cs
@@ -35,18 +35,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
35 { 35 {
36 #region ITerrainFloodEffect Members 36 #region ITerrainFloodEffect Members
37 37
38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 38 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
39 int startX, int endX, int startY, int endY)
39 { 40 {
40 int x; 41 int x, y;
41 for (x = 0; x < map.Width; x++) 42 for (x = startX; x <= endX; x++)
42 { 43 {
43 int y; 44 for (y = startY; y <= endY; y++)
44 for (y = 0; y < map.Height; y++)
45 { 45 {
46 if (fillArea[x, y]) 46 if (fillArea[x, y])
47 { 47 {
48 double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0); 48 double noise = TerrainUtil.PerlinNoise2D((double) x / map.Width, (double) y / map.Height, 8, 1.0);
49<<<<<<< HEAD
49 50
51=======
52>>>>>>> avn/ubitvar
50 map[x, y] += noise * strength; 53 map[x, y] += noise * strength;
51 } 54 }
52 } 55 }
@@ -55,4 +58,4 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
55 58
56 #endregion 59 #endregion
57 } 60 }
58} \ No newline at end of file 61}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
index 3bdc5e7..6ccd5df 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RaiseArea.cs
@@ -33,13 +33,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 int x; 39 int x,y;
39 for (x = 0; x < map.Width; x++) 40 for (x = startX; x <= endX; x++)
40 { 41 {
41 int y; 42 for (y = startY; y <= endY; y++)
42 for (y = 0; y < map.Height; y++)
43 { 43 {
44 if (fillArea[x, y]) 44 if (fillArea[x, y])
45 { 45 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
index c5527fa..4230133 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/RevertArea.cs
@@ -46,13 +46,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
46 /// <param name="map">the current heightmap</param> 46 /// <param name="map">the current heightmap</param>
47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param> 47 /// <param name="fillArea">array indicating which sections of the map are to be reverted</param>
48 /// <param name="strength">unused</param> 48 /// <param name="strength">unused</param>
49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 49 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
50 int startX, int endX, int startY, int endY)
50 { 51 {
51 int x; 52 int x, y;
52 for (x = 0; x < map.Width; x++) 53 for (x = startX; x <= endX; x++)
53 { 54 {
54 int y; 55 for (y = startY; y <= endY; y++)
55 for (y = 0; y < map.Height; y++)
56 { 56 {
57 if (fillArea[x, y]) 57 if (fillArea[x, y])
58 { 58 {
diff --git a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
index 6b07747..6c0d60d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/FloodBrushes/SmoothArea.cs
@@ -33,16 +33,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
33 { 33 {
34 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength,
37 int startX, int endX, int startY, int endY)
37 { 38 {
38 double area = strength; 39 double area = strength;
39 double step = strength / 4.0; 40 double step = strength / 4.0;
40 41
41 double[,] manipulate = new double[map.Width,map.Height]; 42 double[,] manipulate = new double[map.Width,map.Height];
42 int x, y; 43 int x, y;
43 for (x = 0; x < map.Width; x++) 44 for (x = startX; x <= endX; x++)
44 { 45 {
45 for (y = 0; y < map.Height; y++) 46 for (y = startY; y <= endY; y++)
46 { 47 {
47 if (!fillArea[x, y]) 48 if (!fillArea[x, y])
48 continue; 49 continue;
@@ -64,9 +65,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.FloodBrushes
64 manipulate[x, y] = average / avgsteps; 65 manipulate[x, y] = average / avgsteps;
65 } 66 }
66 } 67 }
67 for (x = 0; x < map.Width; x++) 68 for (x = startX; x <= endX; x++)
68 { 69 {
69 for (y = 0; y < map.Height; y++) 70 for (y = startY; y <= endY; y++)
70 { 71 {
71 if (!fillArea[x, y]) 72 if (!fillArea[x, y])
72 continue; 73 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
index 3984a30..6324aca 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainFloodEffect.cs
@@ -32,6 +32,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
32{ 32{
33 public interface ITerrainFloodEffect 33 public interface ITerrainFloodEffect
34 { 34 {
35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength); 35 void FloodEffect(ITerrainChannel map, Boolean[,] fillArea, double strength,
36 int startX, int endX, int startY, int endY);
36 } 37 }
37} \ No newline at end of file 38} \ No newline at end of file
diff --git a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
index b73defd..d0b05e4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/ITerrainPaintableEffect.cs
@@ -31,6 +31,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
31{ 31{
32 public interface ITerrainPaintableEffect 32 public interface ITerrainPaintableEffect
33 { 33 {
34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z, double strength, double duration); 34 void PaintEffect(ITerrainChannel map, bool[,] allowMask, double x, double y, double z,
35 double strength, double duration, int startX, int endX, int startY, int endY);
35 } 36 }
36} 37}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
index 7a78cd8..7358ba3 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/ErodeSphere.cs
@@ -151,7 +151,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
151 151
152 #region ITerrainPaintableEffect Members 152 #region ITerrainPaintableEffect Members
153 153
154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 154 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
155 double strength, double duration, int startX, int endX, int startY, int endY)
155 { 156 {
156 strength = TerrainUtil.MetersToSphericalStrength(strength); 157 strength = TerrainUtil.MetersToSphericalStrength(strength);
157 158
@@ -163,18 +164,23 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
163 ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height); 164 ITerrainChannel sediment = new TerrainChannel(map.Width, map.Height);
164 165
165 // Fill with rain 166 // Fill with rain
166 for (x = 0; x < water.Width; x++) 167 for (x = startX; x <= endX; x++)
167 for (y = 0; y < water.Height; y++) 168 {
168 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); 169 for (y = startY; y <= endY; y++)
170 {
171 if (mask[x, y])
172 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
173 }
174 }
169 175
170 for (int i = 0; i < rounds; i++) 176 for (int i = 0; i < rounds; i++)
171 { 177 {
172 // Erode underlying terrain 178 // Erode underlying terrain
173 for (x = 0; x < water.Width; x++) 179 for (x = startX; x <= endX; x++)
174 { 180 {
175 for (y = 0; y < water.Height; y++) 181 for (y = startY; y <= endY; y++)
176 { 182 {
177 if (mask[x,y]) 183 if (mask[x, y])
178 { 184 {
179 const double solConst = (1.0 / rounds); 185 const double solConst = (1.0 / rounds);
180 double sedDelta = water[x, y] * solConst; 186 double sedDelta = water[x, y] * solConst;
@@ -185,9 +191,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
185 } 191 }
186 192
187 // Move water 193 // Move water
188 for (x = 0; x < water.Width; x++) 194 for (x = startX; x <= endX; x++)
189 { 195 {
190 for (y = 0; y < water.Height; y++) 196 for (y = startY; y <= endY; y++)
191 { 197 {
192 if (water[x, y] <= 0) 198 if (water[x, y] <= 0)
193 continue; 199 continue;
@@ -296,7 +302,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
296 double sedimentDeposit = sediment[x, y] - waterCapacity; 302 double sedimentDeposit = sediment[x, y] - waterCapacity;
297 if (sedimentDeposit > 0) 303 if (sedimentDeposit > 0)
298 { 304 {
299 if (mask[x,y]) 305 if (mask[x, y])
300 { 306 {
301 sediment[x, y] -= sedimentDeposit; 307 sediment[x, y] -= sedimentDeposit;
302 map[x, y] += sedimentDeposit; 308 map[x, y] += sedimentDeposit;
@@ -309,10 +315,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
309 // Deposit any remainder (should be minimal) 315 // Deposit any remainder (should be minimal)
310 for (x = 0; x < water.Width; x++) 316 for (x = 0; x < water.Width; x++)
311 for (y = 0; y < water.Height; y++) 317 for (y = 0; y < water.Height; y++)
312 if (mask[x,y] && sediment[x, y] > 0) 318 if (mask[x, y] && sediment[x, y] > 0)
313 map[x, y] += sediment[x, y]; 319 map[x, y] += sediment[x, y];
314 } 320 }
315
316 #endregion 321 #endregion
317 } 322 }
318} 323}
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
index 9aa3dff..8937f63 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -35,16 +35,17 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 41 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 42
42 int x, y; 43 int x, y;
43 44
44 // blend in map 45 // blend in map
45 for (x = 0; x < map.Width; x++) 46 for (x = startX; x <= endX; x++)
46 { 47 {
47 for (y = 0; y < map.Height; y++) 48 for (y = startY; y <= endY; y++)
48 { 49 {
49 if (!mask[x,y]) 50 if (!mask[x,y])
50 continue; 51 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
index 68145f2..bbf9407 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/LowerSphere.cs
@@ -34,34 +34,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
38 double strength, double duration, int startX, int endX, int startY, int endY)
38 { 39 {
39 int s = (int) (Math.Pow(2, strength) + 0.5); 40 int s = (int) (Math.Pow(2, strength) + 0.5);
40 41
41 int x; 42 int x, y;
42 int xFrom = (int)(rx-s+0.5);
43 int xTo = (int)(rx+s+0.5) + 1;
44 int yFrom = (int)(ry-s+0.5);
45 int yTo = (int)(ry+s+0.5) + 1;
46 43
47 if (xFrom < 0) 44 for (x = startX; x <= endX; x++)
48 xFrom = 0;
49
50 if (yFrom < 0)
51 yFrom = 0;
52
53 if (xTo > map.Width)
54 xTo = map.Width;
55
56 if (yTo > map.Width)
57 yTo = map.Width;
58
59 for (x = xFrom; x < xTo; x++)
60 { 45 {
61 int y; 46 for (y = startY; y <= endY; y++)
62 for (y = yFrom; y < yTo; y++)
63 { 47 {
64 if (!mask[x,y]) 48 if (!mask[x, y])
65 continue; 49 continue;
66 50
67 // Calculate a cos-sphere and add it to the heighmap 51 // Calculate a cos-sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
index e7df3f8..46d47b4 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/NoiseSphere.cs
@@ -35,17 +35,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 { 35 {
36 #region ITerrainPaintableEffect Members 36 #region ITerrainPaintableEffect Members
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 strength = TerrainUtil.MetersToSphericalStrength(strength); 41 strength = TerrainUtil.MetersToSphericalStrength(strength);
41 42
42 int x; 43 int x, y;
43 for (x = 0; x < map.Width; x++) 44
45 for (x = startX; x <= endX; x++)
44 { 46 {
45 int y; 47 for (y = startY; y <= endY; y++)
46 for (y = 0; y < map.Height; y++)
47 { 48 {
48 if (!mask[x,y]) 49 if (!mask[x, y])
49 continue; 50 continue;
50 51
51 // Calculate a sphere and add it to the heighmap 52 // Calculate a sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
index b199df3..281690d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/OlsenSphere.cs
@@ -152,18 +152,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
152 152
153 #region ITerrainPaintableEffect Members 153 #region ITerrainPaintableEffect Members
154 154
155 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 155 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
156 double strength, double duration, int startX, int endX, int startY, int endY)
156 { 157 {
157 strength = TerrainUtil.MetersToSphericalStrength(strength); 158 strength = TerrainUtil.MetersToSphericalStrength(strength);
158 159
159 int x; 160 int x, y;
160 161
161 for (x = 0; x < map.Width; x++) 162 for (x = startX; x <= endX; x++)
162 { 163 {
163 int y; 164 for (y = startY; y <= endY; y++)
164 for (y = 0; y < map.Height; y++)
165 { 165 {
166 if (!mask[x,y]) 166 if (!mask[x, y])
167 continue; 167 continue;
168 168
169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
index bd9a8a0..1b704bb 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RaiseSphere.cs
@@ -35,38 +35,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 37
38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 38 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
39 double strength, double duration, int startX, int endX, int startY, int endY)
39 { 40 {
40 int s = (int) (Math.Pow(2, strength) + 0.5); 41 int s = (int) (Math.Pow(2, strength) + 0.5);
41 42
42 int x; 43 int x,y;
43 int xFrom = (int)(rx-s+0.5);
44 int xTo = (int)(rx+s+0.5) + 1;
45 int yFrom = (int)(ry-s+0.5);
46 int yTo = (int)(ry+s+0.5) + 1;
47 44
48 if (xFrom < 0) 45 for (x = startX; x <= endX; x++)
49 xFrom = 0;
50
51 if (yFrom < 0)
52 yFrom = 0;
53
54 if (xTo > map.Width)
55 xTo = map.Width;
56
57 if (yTo > map.Width)
58 yTo = map.Width;
59
60 for (x = xFrom; x < xTo; x++)
61 { 46 {
62 int y; 47 for (y = startY; y <= endY; y++)
63 for (y = yFrom; y < yTo; y++)
64 { 48 {
65 if (!mask[x,y]) 49 if (!mask[x, y])
66 continue; 50 continue;
67 51
68 // Calculate a cos-sphere and add it to the heighmap 52 // Calculate a cos-sphere and add it to the heighmap
69 double r = Math.Sqrt((x-rx) * (x-rx) + ((y-ry) * (y-ry))); 53 double r = Math.Sqrt((x - rx) * (x - rx) + ((y - ry) * (y - ry)));
70 double z = Math.Cos(r * Math.PI / (s * 2)); 54 double z = Math.Cos(r * Math.PI / (s * 2));
71 if (z > 0.0) 55 if (z > 0.0)
72 map[x, y] += z * duration; 56 map[x, y] += z * duration;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
index 4b28275..efc5324 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/RevertSphere.cs
@@ -41,7 +41,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
41 41
42 #region ITerrainPaintableEffect Members 42 #region ITerrainPaintableEffect Members
43 43
44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 44 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
45 double strength, double duration, int startX, int endX, int startY, int endY)
45 { 46 {
46 strength = TerrainUtil.MetersToSphericalStrength(strength); 47 strength = TerrainUtil.MetersToSphericalStrength(strength);
47 duration = 0.03; //MCP Should be read from ini file 48 duration = 0.03; //MCP Should be read from ini file
@@ -51,13 +52,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
51 if (duration < 0) 52 if (duration < 0)
52 return; 53 return;
53 54
54 int x; 55 int x,y;
55 for (x = 0; x < map.Width; x++) 56 for (x = startX; x <= endX; x++)
56 { 57 {
57 int y; 58 for (y = startY; y <= endY; y++)
58 for (y = 0; y < map.Height; y++)
59 { 59 {
60 if (!mask[x,y]) 60 if (!mask[x, y])
61 continue; 61 continue;
62 62
63 // Calculate a sphere and add it to the heighmap 63 // Calculate a sphere and add it to the heighmap
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
index 4834c86..65dd0a6 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/SmoothSphere.cs
@@ -34,7 +34,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
34 { 34 {
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
38 double strength, double duration, int startX, int endX, int startY, int endY)
38 { 39 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 40 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 41
@@ -47,10 +48,13 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
47 48
48 49
49 // compute delta map 50 // compute delta map
50 for (x = 0; x < map.Width; x++) 51 for (x = startX; x <= endX; x++)
51 { 52 {
52 for (y = 0; y < map.Height; y++) 53 for (y = startY; y <= endY; y++)
53 { 54 {
55 if (!mask[x, y])
56 continue;
57
54 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 58 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
55 59
56 if (z > 0) // add in non-zero amount 60 if (z > 0) // add in non-zero amount
@@ -73,11 +77,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
73 } 77 }
74 } 78 }
75 // blend in map 79 // blend in map
76 for (x = 0; x < map.Width; x++) 80 for (x = startX; x <= endX; x++)
77 { 81 {
78 for (y = 0; y < map.Height; y++) 82 for (y = startY; y <= endY; y++)
79 { 83 {
80 if (!mask[x,y]) 84 if (!mask[x, y])
81 continue; 85 continue;
82 86
83 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); 87 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
diff --git a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
index f31c8b6..f52fe07 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/PaintBrushes/WeatherSphere.cs
@@ -148,16 +148,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain.PaintBrushes
148 148
149 #region ITerrainPaintableEffect Members 149 #region ITerrainPaintableEffect Members
150 150
151 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration) 151 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz,
152 double strength, double duration, int startX, int endX, int startY, int endY)
152 { 153 {
153 strength = TerrainUtil.MetersToSphericalStrength(strength); 154 strength = TerrainUtil.MetersToSphericalStrength(strength);
154 155
155 int x; 156 int x,y;
156 157
157 for (x = 0; x < map.Width; x++) 158 for (x = startX; x <= endX; x++)
158 { 159 {
159 int y; 160 for (y = startY; y <= endY; y++)
160 for (y = 0; y < map.Height; y++)
161 { 161 {
162 if (!mask[x,y]) 162 if (!mask[x,y])
163 continue; 163 continue;
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 932652c..925de2a 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -75,6 +75,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
75 #endregion 75 #endregion
76 76
77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 77 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
78<<<<<<< HEAD
79=======
80
81#pragma warning disable 414
82 private static readonly string LogHeader = "[TERRAIN MODULE]";
83#pragma warning restore 414
84
85 private readonly Commander m_commander = new Commander("terrain");
86>>>>>>> avn/ubitvar
78 87
79#pragma warning disable 414 88#pragma warning disable 414
80 private static readonly string LogHeader = "[TERRAIN MODULE]"; 89 private static readonly string LogHeader = "[TERRAIN MODULE]";
@@ -86,6 +95,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
86 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); 95 private readonly Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
87 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects = 96 private readonly Dictionary<StandardTerrainEffects, ITerrainPaintableEffect> m_painteffects =
88 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>(); 97 new Dictionary<StandardTerrainEffects, ITerrainPaintableEffect>();
98<<<<<<< HEAD
89 private Dictionary<string, ITerrainEffect> m_plugineffects; 99 private Dictionary<string, ITerrainEffect> m_plugineffects;
90 private Dictionary<string, ITerrainModifier> m_modifyOperations = 100 private Dictionary<string, ITerrainModifier> m_modifyOperations =
91 new Dictionary<string, ITerrainModifier>(); 101 new Dictionary<string, ITerrainModifier>();
@@ -94,6 +104,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
94 private Scene m_scene; 104 private Scene m_scene;
95 private volatile bool m_tainted; 105 private volatile bool m_tainted;
96 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); 106 private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
107=======
108
109 private Dictionary<string, ITerrainEffect> m_plugineffects;
110 private ITerrainChannel m_channel;
111 private ITerrainChannel m_baked;
112 private Scene m_scene;
113 private volatile bool m_tainted;
114
115>>>>>>> avn/ubitvar
97 private String m_InitialTerrain = "pinhead-island"; 116 private String m_InitialTerrain = "pinhead-island";
98 117
99 // If true, send terrain patch updates to clients based on their view distance 118 // If true, send terrain patch updates to clients based on their view distance
@@ -107,13 +126,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
107 private bool[,] updated; // for each patch, whether it needs to be sent to this client 126 private bool[,] updated; // for each patch, whether it needs to be sent to this client
108 private int updateCount; // number of patches that need to be sent 127 private int updateCount; // number of patches that need to be sent
109 public ScenePresence Presence; // a reference to the client to send to 128 public ScenePresence Presence; // a reference to the client to send to
129<<<<<<< HEAD
110 public TerrainData Terrain; // reference to the underlying terrain 130 public TerrainData Terrain; // reference to the underlying terrain
131=======
132>>>>>>> avn/ubitvar
111 public PatchUpdates(TerrainData terrData, ScenePresence pPresence) 133 public PatchUpdates(TerrainData terrData, ScenePresence pPresence)
112 { 134 {
113 updated = new bool[terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize]; 135 updated = new bool[terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize];
114 updateCount = 0; 136 updateCount = 0;
115 Presence = pPresence; 137 Presence = pPresence;
138<<<<<<< HEAD
116 Terrain = terrData; 139 Terrain = terrData;
140=======
141>>>>>>> avn/ubitvar
117 // Initially, send all patches to the client 142 // Initially, send all patches to the client
118 SetAll(true); 143 SetAll(true);
119 } 144 }
@@ -122,17 +147,26 @@ namespace OpenSim.Region.CoreModules.World.Terrain
122 { 147 {
123 return (updateCount > 0); 148 return (updateCount > 0);
124 } 149 }
150<<<<<<< HEAD
125 151
152=======
153>>>>>>> avn/ubitvar
126 public void SetByXY(int x, int y, bool state) 154 public void SetByXY(int x, int y, bool state)
127 { 155 {
128 this.SetByPatch(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, state); 156 this.SetByPatch(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, state);
129 } 157 }
158<<<<<<< HEAD
130 159
160=======
161>>>>>>> avn/ubitvar
131 public bool GetByPatch(int patchX, int patchY) 162 public bool GetByPatch(int patchX, int patchY)
132 { 163 {
133 return updated[patchX, patchY]; 164 return updated[patchX, patchY];
134 } 165 }
166<<<<<<< HEAD
135 167
168=======
169>>>>>>> avn/ubitvar
136 public void SetByPatch(int patchX, int patchY, bool state) 170 public void SetByPatch(int patchX, int patchY, bool state)
137 { 171 {
138 bool prevState = updated[patchX, patchY]; 172 bool prevState = updated[patchX, patchY];
@@ -142,12 +176,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
142 updateCount--; 176 updateCount--;
143 updated[patchX, patchY] = state; 177 updated[patchX, patchY] = state;
144 } 178 }
179<<<<<<< HEAD
145 180
146 public void SetAll(bool state) 181 public void SetAll(bool state)
147 { 182 {
148 updateCount = 0; 183 updateCount = 0;
149 for(int xx = 0; xx < updated.GetLength(0); xx++) 184 for(int xx = 0; xx < updated.GetLength(0); xx++)
150 for(int yy = 0; yy < updated.GetLength(1); yy++) 185 for(int yy = 0; yy < updated.GetLength(1); yy++)
186=======
187 public void SetAll(bool state)
188 {
189 updateCount = 0;
190 for (int xx = 0; xx < updated.GetLength(0); xx++)
191 for (int yy = 0; yy < updated.GetLength(1); yy++)
192>>>>>>> avn/ubitvar
151 updated[xx, yy] = state; 193 updated[xx, yy] = state;
152 if (state) 194 if (state)
153 updateCount = updated.GetLength(0) * updated.GetLength(1); 195 updateCount = updated.GetLength(0) * updated.GetLength(1);
@@ -164,9 +206,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
164 terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize) 206 terrData.SizeX / Constants.TerrainPatchSize, terrData.SizeY / Constants.TerrainPatchSize)
165 ); 207 );
166 } 208 }
209<<<<<<< HEAD
167 for(int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize) 210 for(int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize)
168 { 211 {
169 for(int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize) 212 for(int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize)
213=======
214 for (int xx = 0; xx < terrData.SizeX; xx += Constants.TerrainPatchSize)
215 {
216 for (int yy = 0; yy < terrData.SizeY; yy += Constants.TerrainPatchSize)
217>>>>>>> avn/ubitvar
170 { 218 {
171 // Only set tainted. The patch bit may be set if the patch was to be sent later. 219 // Only set tainted. The patch bit may be set if the patch was to be sent later.
172 if (terrData.IsTaintedAt(xx, yy, false)) 220 if (terrData.IsTaintedAt(xx, yy, false))
@@ -227,12 +275,20 @@ namespace OpenSim.Region.CoreModules.World.Terrain
227 (int)m_scene.RegionInfo.RegionSizeY, 275 (int)m_scene.RegionInfo.RegionSizeY,
228 (int)m_scene.RegionInfo.RegionSizeZ); 276 (int)m_scene.RegionInfo.RegionSizeZ);
229 m_scene.Heightmap = m_channel; 277 m_scene.Heightmap = m_channel;
278<<<<<<< HEAD
230 UpdateRevertMap(); 279 UpdateRevertMap();
280=======
281 UpdateBakedMap();
282>>>>>>> avn/ubitvar
231 } 283 }
232 else 284 else
233 { 285 {
234 m_channel = m_scene.Heightmap; 286 m_channel = m_scene.Heightmap;
287<<<<<<< HEAD
235 UpdateRevertMap(); 288 UpdateRevertMap();
289=======
290 UpdateBakedMap();
291>>>>>>> avn/ubitvar
236 } 292 }
237 293
238 m_scene.RegisterModuleInterface<ITerrainModule>(this); 294 m_scene.RegisterModuleInterface<ITerrainModule>(this);
@@ -240,7 +296,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
240 m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed; 296 m_scene.EventManager.OnClientClosed += EventManager_OnClientClosed;
241 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 297 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
242 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick; 298 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
299<<<<<<< HEAD
243 m_scene.EventManager.OnFrame += EventManager_OnFrame; 300 m_scene.EventManager.OnFrame += EventManager_OnFrame;
301=======
302 m_scene.EventManager.OnTerrainCheckUpdates += EventManager_TerrainCheckUpdates;
303>>>>>>> avn/ubitvar
244 } 304 }
245 305
246 InstallDefaultEffects(); 306 InstallDefaultEffects();
@@ -279,7 +339,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
279 // remove the commands 339 // remove the commands
280 m_scene.UnregisterModuleCommander(m_commander.Name); 340 m_scene.UnregisterModuleCommander(m_commander.Name);
281 // remove the event-handlers 341 // remove the event-handlers
342<<<<<<< HEAD
282 m_scene.EventManager.OnFrame -= EventManager_OnFrame; 343 m_scene.EventManager.OnFrame -= EventManager_OnFrame;
344=======
345 m_scene.EventManager.OnTerrainCheckUpdates -= EventManager_TerrainCheckUpdates;
346>>>>>>> avn/ubitvar
283 m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick; 347 m_scene.EventManager.OnTerrainTick -= EventManager_OnTerrainTick;
284 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; 348 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole;
285 m_scene.EventManager.OnClientClosed -= EventManager_OnClientClosed; 349 m_scene.EventManager.OnClientClosed -= EventManager_OnClientClosed;
@@ -334,7 +398,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
334 m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height); 398 m_log.DebugFormat("[TERRAIN]: Loaded terrain, wd/ht: {0}/{1}", channel.Width, channel.Height);
335 m_scene.Heightmap = channel; 399 m_scene.Heightmap = channel;
336 m_channel = channel; 400 m_channel = channel;
337 UpdateRevertMap(); 401 UpdateBakedMap();
338 } 402 }
339 catch(NotImplementedException) 403 catch(NotImplementedException)
340 { 404 {
@@ -426,7 +490,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
426 { 490 {
427 ITerrainChannel channel = loader.Value.LoadStream(stream); 491 ITerrainChannel channel = loader.Value.LoadStream(stream);
428 m_channel.Merge(channel, displacement, radianRotation, rotationDisplacement); 492 m_channel.Merge(channel, displacement, radianRotation, rotationDisplacement);
493<<<<<<< HEAD
429 UpdateRevertMap(); 494 UpdateRevertMap();
495=======
496 UpdateBakedMap();
497>>>>>>> avn/ubitvar
430 } 498 }
431 catch(NotImplementedException) 499 catch(NotImplementedException)
432 { 500 {
@@ -506,16 +574,48 @@ namespace OpenSim.Region.CoreModules.World.Terrain
506 574
507 // Someone diddled terrain outside the normal code paths. Set the taintedness for all clients. 575 // Someone diddled terrain outside the normal code paths. Set the taintedness for all clients.
508 // ITerrainModule.TaintTerrain() 576 // ITerrainModule.TaintTerrain()
577<<<<<<< HEAD
509 public void TaintTerrain() 578 public void TaintTerrain()
510 { 579 {
511 lock(m_perClientPatchUpdates) 580 lock(m_perClientPatchUpdates)
512 { 581 {
513 // Set the flags for all clients so the tainted patches will be sent out 582 // Set the flags for all clients so the tainted patches will be sent out
514 foreach(PatchUpdates pups in m_perClientPatchUpdates.Values) 583 foreach(PatchUpdates pups in m_perClientPatchUpdates.Values)
584=======
585 public void TaintTerrain ()
586 {
587 lock (m_perClientPatchUpdates)
588 {
589 // Set the flags for all clients so the tainted patches will be sent out
590 foreach (PatchUpdates pups in m_perClientPatchUpdates.Values)
591>>>>>>> avn/ubitvar
515 { 592 {
516 pups.SetAll(m_scene.Heightmap.GetTerrainData()); 593 pups.SetAll(m_scene.Heightmap.GetTerrainData());
517 } 594 }
518 } 595 }
596<<<<<<< HEAD
597=======
598 }
599
600 // ITerrainModule.PushTerrain()
601 public void PushTerrain(IClientAPI pClient)
602 {
603 ScenePresence presence = m_scene.GetScenePresence(pClient.AgentId);
604 if (presence != null)
605 {
606 lock (m_perClientPatchUpdates)
607 {
608 PatchUpdates pups;
609 if (!m_perClientPatchUpdates.TryGetValue(pClient.AgentId, out pups))
610 {
611 // There is a ScenePresence without a send patch map. Create one.
612 pups = new PatchUpdates(m_scene.Heightmap.GetTerrainData(), presence);
613 m_perClientPatchUpdates.Add(presence.UUID, pups);
614 }
615 pups.SetAll(true);
616 }
617 }
618>>>>>>> avn/ubitvar
519 } 619 }
520 620
521 // ITerrainModule.PushTerrain() 621 // ITerrainModule.PushTerrain()
@@ -636,7 +736,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
636 m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere(); 736 m_painteffects[StandardTerrainEffects.Smooth] = new SmoothSphere();
637 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere(); 737 m_painteffects[StandardTerrainEffects.Noise] = new NoiseSphere();
638 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere(); 738 m_painteffects[StandardTerrainEffects.Flatten] = new FlattenSphere();
639 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_revert); 739 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
640 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere(); 740 m_painteffects[StandardTerrainEffects.Erode] = new ErodeSphere();
641 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere(); 741 m_painteffects[StandardTerrainEffects.Weather] = new WeatherSphere();
642 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere(); 742 m_painteffects[StandardTerrainEffects.Olsen] = new OlsenSphere();
@@ -647,7 +747,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
647 m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea(); 747 m_floodeffects[StandardTerrainEffects.Smooth] = new SmoothArea();
648 m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea(); 748 m_floodeffects[StandardTerrainEffects.Noise] = new NoiseArea();
649 m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea(); 749 m_floodeffects[StandardTerrainEffects.Flatten] = new FlattenArea();
650 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_revert); 750 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
651 751
652 // Terrain Modifier operations 752 // Terrain Modifier operations
653 m_modifyOperations["min"] = new MinModifier(this); 753 m_modifyOperations["min"] = new MinModifier(this);
@@ -673,10 +773,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain
673 } 773 }
674 774
675 /// <summary> 775 /// <summary>
676 /// Saves the current state of the region into the revert map buffer. 776 /// Saves the current state of the region into the baked map buffer.
777
677 /// </summary> 778 /// </summary>
678 public void UpdateRevertMap() 779 public void UpdateBakedMap()
679 { 780 {
781<<<<<<< HEAD
680 /* 782 /*
681 int x; 783 int x;
682 for (x = 0; x < m_channel.Width; x++) 784 for (x = 0; x < m_channel.Width; x++)
@@ -689,6 +791,11 @@ namespace OpenSim.Region.CoreModules.World.Terrain
689 } 791 }
690 */ 792 */
691 m_revert = m_channel.MakeCopy(); 793 m_revert = m_channel.MakeCopy();
794=======
795 m_baked = m_channel.MakeCopy();
796 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
797 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
798>>>>>>> avn/ubitvar
692 } 799 }
693 800
694 /// <summary> 801 /// <summary>
@@ -715,11 +822,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
715 { 822 {
716 ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY, 823 ITerrainChannel channel = loader.Value.LoadFile(filename, offsetX, offsetY,
717 fileWidth, fileHeight, 824 fileWidth, fileHeight,
825<<<<<<< HEAD
718 (int)m_scene.RegionInfo.RegionSizeX, 826 (int)m_scene.RegionInfo.RegionSizeX,
719 (int)m_scene.RegionInfo.RegionSizeY); 827 (int)m_scene.RegionInfo.RegionSizeY);
828=======
829 (int) m_scene.RegionInfo.RegionSizeX,
830 (int) m_scene.RegionInfo.RegionSizeY);
831>>>>>>> avn/ubitvar
720 m_scene.Heightmap = channel; 832 m_scene.Heightmap = channel;
721 m_channel = channel; 833 m_channel = channel;
722 UpdateRevertMap(); 834 UpdateBakedMap();
723 } 835 }
724 836
725 return; 837 return;
@@ -782,12 +894,16 @@ namespace OpenSim.Region.CoreModules.World.Terrain
782 } 894 }
783 895
784 /// <summary> 896 /// <summary>
897<<<<<<< HEAD
785 /// Called before processing of every simulation frame. 898 /// Called before processing of every simulation frame.
899=======
900>>>>>>> avn/ubitvar
786 /// This is used to check to see of any of the terrain is tainted and, if so, schedule 901 /// This is used to check to see of any of the terrain is tainted and, if so, schedule
787 /// updates for all the presences. 902 /// updates for all the presences.
788 /// This also checks to see if there are updates that need to be sent for each presence. 903 /// This also checks to see if there are updates that need to be sent for each presence.
789 /// This is where the logic is to send terrain updates to clients. 904 /// This is where the logic is to send terrain updates to clients.
790 /// </summary> 905 /// </summary>
906<<<<<<< HEAD
791 private void EventManager_OnFrame() 907 private void EventManager_OnFrame()
792 { 908 {
793 TerrainData terrData = m_channel.GetTerrainData(); 909 TerrainData terrData = m_channel.GetTerrainData();
@@ -798,6 +914,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
798 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize) 914 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
799 { 915 {
800 if (terrData.IsTaintedAt(x, y)) 916 if (terrData.IsTaintedAt(x, y))
917=======
918 private void EventManager_TerrainCheckUpdates()
919 {
920 // this needs fixing
921 TerrainData terrData = m_channel.GetTerrainData();
922
923 bool shouldTaint = false;
924 for (int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
925 {
926 for (int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
927 {
928 if (terrData.IsTaintedAt(x, y,true))
929>>>>>>> avn/ubitvar
801 { 930 {
802 // Found a patch that was modified. Push this flag into the clients. 931 // Found a patch that was modified. Push this flag into the clients.
803 SendToClients(terrData, x, y); 932 SendToClients(terrData, x, y);
@@ -815,6 +944,10 @@ namespace OpenSim.Region.CoreModules.World.Terrain
815 m_scene.EventManager.TriggerTerrainTainted(); 944 m_scene.EventManager.TriggerTerrainTainted();
816 m_tainted = true; 945 m_tainted = true;
817 } 946 }
947<<<<<<< HEAD
948=======
949
950>>>>>>> avn/ubitvar
818 } 951 }
819 952
820 /// <summary> 953 /// <summary>
@@ -883,11 +1016,18 @@ namespace OpenSim.Region.CoreModules.World.Terrain
883 presence.ControllingClient.OnLandUndo -= client_OnLandUndo; 1016 presence.ControllingClient.OnLandUndo -= client_OnLandUndo;
884 presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain; 1017 presence.ControllingClient.OnUnackedTerrain -= client_OnUnackedTerrain;
885 } 1018 }
1019<<<<<<< HEAD
886 1020
887 lock(m_perClientPatchUpdates) 1021 lock(m_perClientPatchUpdates)
888 m_perClientPatchUpdates.Remove(client); 1022 m_perClientPatchUpdates.Remove(client);
889 } 1023 }
1024=======
1025>>>>>>> avn/ubitvar
890 1026
1027 lock (m_perClientPatchUpdates)
1028 m_perClientPatchUpdates.Remove(client);
1029 }
1030
891 /// <summary> 1031 /// <summary>
892 /// Scan over changes in the terrain and limit height changes. This enforces the 1032 /// Scan over changes in the terrain and limit height changes. This enforces the
893 /// non-estate owner limits on rate of terrain editting. 1033 /// non-estate owner limits on rate of terrain editting.
@@ -898,12 +1038,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
898 TerrainData terrData = m_channel.GetTerrainData(); 1038 TerrainData terrData = m_channel.GetTerrainData();
899 1039
900 bool wasLimited = false; 1040 bool wasLimited = false;
1041<<<<<<< HEAD
901 for(int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize) 1042 for(int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
902 { 1043 {
903 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize) 1044 for(int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
904 { 1045 {
905 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */)) 1046 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
906 { 1047 {
1048=======
1049 for (int x = 0; x < terrData.SizeX; x += Constants.TerrainPatchSize)
1050 {
1051 for (int y = 0; y < terrData.SizeY; y += Constants.TerrainPatchSize)
1052 {
1053 if (terrData.IsTaintedAt(x, y, false /* clearOnTest */))
1054 {
1055>>>>>>> avn/ubitvar
907 // If we should respect the estate settings then 1056 // If we should respect the estate settings then
908 // fixup and height deltas that don't respect them. 1057 // fixup and height deltas that don't respect them.
909 // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values. 1058 // Note that LimitChannelChanges() modifies the TerrainChannel with the limited height values.
@@ -926,13 +1075,22 @@ namespace OpenSim.Region.CoreModules.World.Terrain
926 float maxDelta = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit; 1075 float maxDelta = (float)m_scene.RegionInfo.RegionSettings.TerrainRaiseLimit;
927 1076
928 // loop through the height map for this patch and compare it against 1077 // loop through the height map for this patch and compare it against
1078<<<<<<< HEAD
929 // the revert map 1079 // the revert map
930 for(int x = xStart; x < xStart + Constants.TerrainPatchSize; x++) 1080 for(int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
1081=======
1082 // the baked map
1083 for (int x = xStart; x < xStart + Constants.TerrainPatchSize; x++)
1084>>>>>>> avn/ubitvar
931 { 1085 {
932 for(int y = yStart; y < yStart + Constants.TerrainPatchSize; y++) 1086 for(int y = yStart; y < yStart + Constants.TerrainPatchSize; y++)
933 { 1087 {
934 float requestedHeight = terrData[x, y]; 1088 float requestedHeight = terrData[x, y];
1089<<<<<<< HEAD
935 float bakedHeight = (float)m_revert[x, y]; 1090 float bakedHeight = (float)m_revert[x, y];
1091=======
1092 float bakedHeight = (float)m_baked[x, y];
1093>>>>>>> avn/ubitvar
936 float requestedDelta = requestedHeight - bakedHeight; 1094 float requestedDelta = requestedHeight - bakedHeight;
937 1095
938 if (requestedDelta > maxDelta) 1096 if (requestedDelta > maxDelta)
@@ -953,6 +1111,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
953 1111
954 private void client_OnLandUndo(IClientAPI client) 1112 private void client_OnLandUndo(IClientAPI client)
955 { 1113 {
1114<<<<<<< HEAD
956 lock(m_undo) 1115 lock(m_undo)
957 { 1116 {
958 if (m_undo.Count > 0) 1117 if (m_undo.Count > 0)
@@ -962,6 +1121,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
962 goback.PlaybackState(); 1121 goback.PlaybackState();
963 } 1122 }
964 } 1123 }
1124=======
1125
1126>>>>>>> avn/ubitvar
965 } 1127 }
966 1128
967 /// <summary> 1129 /// <summary>
@@ -971,6 +1133,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
971 /// <param name="x">The patch corner to send</param> 1133 /// <param name="x">The patch corner to send</param>
972 /// <param name="y">The patch corner to send</param> 1134 /// <param name="y">The patch corner to send</param>
973 private void SendToClients(TerrainData terrData, int x, int y) 1135 private void SendToClients(TerrainData terrData, int x, int y)
1136<<<<<<< HEAD
974 { 1137 {
975 if (m_sendTerrainUpdatesByViewDistance) 1138 if (m_sendTerrainUpdatesByViewDistance)
976 { 1139 {
@@ -1138,6 +1301,181 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1138 ret.Add(new PatchesToSend(x, y, dist)); 1301 ret.Add(new PatchesToSend(x, y, dist));
1139 } 1302 }
1140 } 1303 }
1304=======
1305 {
1306 // Add that this patch needs to be sent to the accounting for each client.
1307 lock (m_perClientPatchUpdates)
1308 {
1309 m_scene.ForEachScenePresence(presence =>
1310 {
1311 PatchUpdates thisClientUpdates;
1312 if (!m_perClientPatchUpdates.TryGetValue(presence.UUID, out thisClientUpdates))
1313 {
1314 // There is a ScenePresence without a send patch map. Create one.
1315 thisClientUpdates = new PatchUpdates(terrData, presence);
1316 m_perClientPatchUpdates.Add(presence.UUID, thisClientUpdates);
1317 }
1318 thisClientUpdates.SetByXY(x, y, true);
1319 }
1320 );
1321 }
1322 }
1323
1324 private class PatchesToSend : IComparable<PatchesToSend>
1325 {
1326 public int PatchX;
1327 public int PatchY;
1328 public float Dist;
1329 public PatchesToSend(int pX, int pY, float pDist)
1330 {
1331 PatchX = pX;
1332 PatchY = pY;
1333 Dist = pDist;
1334 }
1335 public int CompareTo(PatchesToSend other)
1336 {
1337 return Dist.CompareTo(other.Dist);
1338 }
1339 }
1340
1341 // Called each frame time to see if there are any patches to send to any of the
1342 // ScenePresences.
1343 // Loop through all the per-client info and send any patches necessary.
1344 private void CheckSendingPatchesToClients()
1345 {
1346 lock (m_perClientPatchUpdates)
1347 {
1348 foreach (PatchUpdates pups in m_perClientPatchUpdates.Values)
1349 {
1350 // throught acording to land queue free to send bytes
1351 if (!pups.Presence.ControllingClient.CanSendLayerData())
1352 continue;
1353
1354 if (pups.HasUpdates())
1355 {
1356 // There is something that could be sent to this client.
1357 List<PatchesToSend> toSend = GetModifiedPatchesInViewDistance(pups);
1358 if (toSend.Count > 0)
1359 {
1360 // m_log.DebugFormat("{0} CheckSendingPatchesToClient: sending {1} patches to {2} in region {3}",
1361 // LogHeader, toSend.Count, pups.Presence.Name, m_scene.RegionInfo.RegionName);
1362 // Sort the patches to send by the distance from the presence
1363 toSend.Sort();
1364 /*
1365 foreach (PatchesToSend pts in toSend)
1366 {
1367 pups.Presence.ControllingClient.SendLayerData(pts.PatchX, pts.PatchY, null);
1368 // presence.ControllingClient.SendLayerData(xs.ToArray(), ys.ToArray(), null, TerrainPatch.LayerType.Land);
1369 }
1370 */
1371
1372 int[] xPieces = new int[toSend.Count];
1373 int[] yPieces = new int[toSend.Count];
1374 float[] patchPieces = new float[toSend.Count * 2];
1375 int pieceIndex = 0;
1376 foreach (PatchesToSend pts in toSend)
1377 {
1378 patchPieces[pieceIndex++] = pts.PatchX;
1379 patchPieces[pieceIndex++] = pts.PatchY;
1380 }
1381 pups.Presence.ControllingClient.SendLayerData(-toSend.Count, 0, patchPieces);
1382 }
1383 }
1384 }
1385 }
1386 }
1387
1388 private List<PatchesToSend> GetModifiedPatchesInViewDistance(PatchUpdates pups)
1389 {
1390 List<PatchesToSend> ret = new List<PatchesToSend>();
1391
1392 int npatchs = 0;
1393
1394 ScenePresence presence = pups.Presence;
1395 if (presence == null)
1396 return ret;
1397
1398 float minz = presence.AbsolutePosition.Z;
1399 if (presence.CameraPosition.Z < minz)
1400 minz = presence.CameraPosition.Z;
1401
1402 // this limit should be max terrainheight + max draw
1403 if (minz > 1500f)
1404 return ret;
1405
1406 int DrawDistance = (int)presence.DrawDistance;
1407
1408 DrawDistance = DrawDistance / Constants.TerrainPatchSize;
1409
1410 int testposX;
1411 int testposY;
1412
1413 if (Math.Abs(presence.AbsolutePosition.X - presence.CameraPosition.X) > 30
1414 || Math.Abs(presence.AbsolutePosition.Y - presence.CameraPosition.Y) > 30)
1415 {
1416 testposX = (int)presence.CameraPosition.X / Constants.TerrainPatchSize;
1417 testposY = (int)presence.CameraPosition.Y / Constants.TerrainPatchSize;
1418 }
1419 else
1420 {
1421 testposX = (int)presence.AbsolutePosition.X / Constants.TerrainPatchSize;
1422 testposY = (int)presence.AbsolutePosition.Y / Constants.TerrainPatchSize;
1423 }
1424 int limitX = (int)m_scene.RegionInfo.RegionSizeX / Constants.TerrainPatchSize;
1425 int limitY = (int)m_scene.RegionInfo.RegionSizeY / Constants.TerrainPatchSize;
1426
1427 // Compute the area of patches within our draw distance
1428 int startX = testposX - DrawDistance;
1429 if (startX < 0)
1430 startX = 0;
1431 else if (startX > limitX)
1432 startX = limitX;
1433
1434 int startY = testposY - DrawDistance;
1435 if (startY < 0)
1436 startY = 0;
1437 else if (startY > limitY)
1438 startY = limitY;
1439
1440 int endX = testposX + DrawDistance;
1441 if (endX < 0)
1442 endX = 0;
1443 else if (endX > limitX)
1444 endX = limitX;
1445
1446 int endY = testposY + DrawDistance;
1447 if (endY < 0)
1448 endY = 0;
1449 else if (endY > limitY)
1450 endY = limitY;
1451
1452 int distx;
1453 int disty;
1454 int distsq;
1455
1456 DrawDistance *= DrawDistance;
1457
1458 for (int x = startX; x < endX; x++)
1459 {
1460 for (int y = startY; y < endY; y++)
1461 {
1462 if (pups.GetByPatch(x, y))
1463 {
1464 distx = x - testposX;
1465 disty = y - testposY;
1466 distsq = distx * distx + disty * disty;
1467 if (distsq < DrawDistance)
1468 {
1469 pups.SetByPatch(x, y, false);
1470 ret.Add(new PatchesToSend(x, y, (float)distsq));
1471 if (npatchs++ > 65536)
1472 {
1473 y = endY;
1474 x = endX;
1475 }
1476 }
1477 }
1478>>>>>>> avn/ubitvar
1141 } 1479 }
1142 } 1480 }
1143 return ret; 1481 return ret;
@@ -1161,6 +1499,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1161 int zx = (int)(west + 0.5); 1499 int zx = (int)(west + 0.5);
1162 int zy = (int)(north + 0.5); 1500 int zy = (int)(north + 0.5);
1163 1501
1502<<<<<<< HEAD
1164 int dx; 1503 int dx;
1165 for(dx=-n; dx<=n; dx++) 1504 for(dx=-n; dx<=n; dx++)
1166 { 1505 {
@@ -1176,16 +1515,52 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1176 allowMask[x, y] = true; 1515 allowMask[x, y] = true;
1177 allowed = true; 1516 allowed = true;
1178 } 1517 }
1518=======
1519
1520 int startX = zx - n;
1521 if (startX < 0)
1522 startX = 0;
1523
1524 int startY = zy - n;
1525 if (startY < 0)
1526 startY = 0;
1527
1528 int endX = zx + n;
1529 if (endX >= m_channel.Width)
1530 endX = m_channel.Width - 1;
1531 int endY = zy + n;
1532 if (endY >= m_channel.Height)
1533 endY = m_channel.Height - 1;
1534
1535 int x, y;
1536
1537 for (x = startX; x <= endX; x++)
1538 {
1539 for (y = startY; y <= endY; y++)
1540 {
1541 if (m_scene.Permissions.CanTerraformLand(agentId, new Vector3(x, y, 0)))
1542 {
1543 allowMask[x, y] = true;
1544 allowed = true;
1545>>>>>>> avn/ubitvar
1179 } 1546 }
1180 } 1547 }
1181 } 1548 }
1182 if (allowed) 1549 if (allowed)
1183 { 1550 {
1184 StoreUndoState(); 1551 StoreUndoState();
1552<<<<<<< HEAD
1185 m_painteffects[(StandardTerrainEffects)action].PaintEffect( 1553 m_painteffects[(StandardTerrainEffects)action].PaintEffect(
1186 m_channel, allowMask, west, south, height, size, seconds); 1554 m_channel, allowMask, west, south, height, size, seconds);
1187 1555
1188 //revert changes outside estate limits 1556 //revert changes outside estate limits
1557=======
1558 m_painteffects[(StandardTerrainEffects) action].PaintEffect(
1559 m_channel, allowMask, west, south, height, size, seconds,
1560 startX, endX, startY, endY);
1561
1562 //block changes outside estate limits
1563>>>>>>> avn/ubitvar
1189 if (!god) 1564 if (!god)
1190 EnforceEstateLimits(); 1565 EnforceEstateLimits();
1191 } 1566 }
@@ -1225,9 +1600,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1225 if (allowed) 1600 if (allowed)
1226 { 1601 {
1227 StoreUndoState(); 1602 StoreUndoState();
1603<<<<<<< HEAD
1228 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, size); 1604 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(m_channel, fillArea, size);
1229 1605
1230 //revert changes outside estate limits 1606 //revert changes outside estate limits
1607=======
1608 m_floodeffects[(StandardTerrainEffects) action].FloodEffect(m_channel, fillArea, size);
1609
1610 //block changes outside estate limits
1611>>>>>>> avn/ubitvar
1231 if (!god) 1612 if (!god)
1232 EnforceEstateLimits(); 1613 EnforceEstateLimits();
1233 } 1614 }
@@ -1260,6 +1641,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1260 1641
1261 private void StoreUndoState() 1642 private void StoreUndoState()
1262 { 1643 {
1644<<<<<<< HEAD
1263 lock(m_undo) 1645 lock(m_undo)
1264 { 1646 {
1265 if (m_undo.Count > 0) 1647 if (m_undo.Count > 0)
@@ -1275,22 +1657,36 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1275 LandUndoState nUndo = new LandUndoState(this, m_channel); 1657 LandUndoState nUndo = new LandUndoState(this, m_channel);
1276 m_undo.Push(nUndo); 1658 m_undo.Push(nUndo);
1277 } 1659 }
1660=======
1661>>>>>>> avn/ubitvar
1278 } 1662 }
1279 1663
1280 #region Console Commands 1664 #region Console Commands
1281 1665
1282 private void InterfaceLoadFile(Object[] args) 1666 private void InterfaceLoadFile(Object[] args)
1283 { 1667 {
1668<<<<<<< HEAD
1284 LoadFromFile((string)args[0]); 1669 LoadFromFile((string)args[0]);
1670=======
1671 LoadFromFile((string) args[0]);
1672>>>>>>> avn/ubitvar
1285 } 1673 }
1286 1674
1287 private void InterfaceLoadTileFile(Object[] args) 1675 private void InterfaceLoadTileFile(Object[] args)
1288 { 1676 {
1677<<<<<<< HEAD
1289 LoadFromFile((string)args[0], 1678 LoadFromFile((string)args[0],
1290 (int)args[1], 1679 (int)args[1],
1291 (int)args[2], 1680 (int)args[2],
1292 (int)args[3], 1681 (int)args[3],
1293 (int)args[4]); 1682 (int)args[4]);
1683=======
1684 LoadFromFile((string) args[0],
1685 (int) args[1],
1686 (int) args[2],
1687 (int) args[3],
1688 (int) args[4]);
1689>>>>>>> avn/ubitvar
1294 } 1690 }
1295 1691
1296 private void InterfaceSaveFile(Object[] args) 1692 private void InterfaceSaveFile(Object[] args)
@@ -1309,15 +1705,21 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1309 1705
1310 private void InterfaceBakeTerrain(Object[] args) 1706 private void InterfaceBakeTerrain(Object[] args)
1311 { 1707 {
1312 UpdateRevertMap(); 1708 UpdateBakedMap();
1313 } 1709 }
1314 1710
1315 private void InterfaceRevertTerrain(Object[] args) 1711 private void InterfaceRevertTerrain(Object[] args)
1316 { 1712 {
1317 int x, y; 1713 int x, y;
1714<<<<<<< HEAD
1318 for(x = 0; x < m_channel.Width; x++) 1715 for(x = 0; x < m_channel.Width; x++)
1319 for(y = 0; y < m_channel.Height; y++) 1716 for(y = 0; y < m_channel.Height; y++)
1320 m_channel[x, y] = m_revert[x, y]; 1717 m_channel[x, y] = m_revert[x, y];
1718=======
1719 for (x = 0; x < m_channel.Width; x++)
1720 for (y = 0; y < m_channel.Height; y++)
1721 m_channel[x, y] = m_baked[x, y];
1722>>>>>>> avn/ubitvar
1321 1723
1322 } 1724 }
1323 1725
@@ -1327,9 +1729,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1327 1729
1328 if (direction.ToLower().StartsWith("y")) 1730 if (direction.ToLower().StartsWith("y"))
1329 { 1731 {
1732<<<<<<< HEAD
1330 for(int x = 0; x < m_channel.Width; x++) 1733 for(int x = 0; x < m_channel.Width; x++)
1331 { 1734 {
1332 for(int y = 0; y < m_channel.Height / 2; y++) 1735 for(int y = 0; y < m_channel.Height / 2; y++)
1736=======
1737 for (int x = 0; x < m_channel.Width; x++)
1738 {
1739 for (int y = 0; y < m_channel.Height / 2; y++)
1740>>>>>>> avn/ubitvar
1333 { 1741 {
1334 double height = m_channel[x, y]; 1742 double height = m_channel[x, y];
1335 double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y]; 1743 double flippedHeight = m_channel[x, (int)m_channel.Height - 1 - y];
@@ -1341,9 +1749,15 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1341 } 1749 }
1342 else if (direction.ToLower().StartsWith("x")) 1750 else if (direction.ToLower().StartsWith("x"))
1343 { 1751 {
1752<<<<<<< HEAD
1344 for(int y = 0; y < m_channel.Height; y++) 1753 for(int y = 0; y < m_channel.Height; y++)
1345 { 1754 {
1346 for(int x = 0; x < m_channel.Width / 2; x++) 1755 for(int x = 0; x < m_channel.Width / 2; x++)
1756=======
1757 for (int y = 0; y < m_channel.Height; y++)
1758 {
1759 for (int x = 0; x < m_channel.Width / 2; x++)
1760>>>>>>> avn/ubitvar
1347 { 1761 {
1348 double height = m_channel[x, y]; 1762 double height = m_channel[x, y];
1349 double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y]; 1763 double flippedHeight = m_channel[(int)m_channel.Width - 1 - x, y];
@@ -1420,45 +1834,81 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1420 1834
1421 private void InterfaceElevateTerrain(Object[] args) 1835 private void InterfaceElevateTerrain(Object[] args)
1422 { 1836 {
1837 double val = (double)args[0];
1838
1423 int x, y; 1839 int x, y;
1840<<<<<<< HEAD
1424 for(x = 0; x < m_channel.Width; x++) 1841 for(x = 0; x < m_channel.Width; x++)
1425 for(y = 0; y < m_channel.Height; y++) 1842 for(y = 0; y < m_channel.Height; y++)
1426 m_channel[x, y] += (double)args[0]; 1843 m_channel[x, y] += (double)args[0];
1844=======
1845 for (x = 0; x < m_channel.Width; x++)
1846 for (y = 0; y < m_channel.Height; y++)
1847 m_channel[x, y] += val;
1848>>>>>>> avn/ubitvar
1427 } 1849 }
1428 1850
1429 private void InterfaceMultiplyTerrain(Object[] args) 1851 private void InterfaceMultiplyTerrain(Object[] args)
1430 { 1852 {
1431 int x, y; 1853 int x, y;
1854<<<<<<< HEAD
1432 for(x = 0; x < m_channel.Width; x++) 1855 for(x = 0; x < m_channel.Width; x++)
1433 for(y = 0; y < m_channel.Height; y++) 1856 for(y = 0; y < m_channel.Height; y++)
1434 m_channel[x, y] *= (double)args[0]; 1857 m_channel[x, y] *= (double)args[0];
1858=======
1859 double val = (double)args[0];
1860
1861 for (x = 0; x < m_channel.Width; x++)
1862 for (y = 0; y < m_channel.Height; y++)
1863 m_channel[x, y] *= val;
1864>>>>>>> avn/ubitvar
1435 } 1865 }
1436 1866
1437 private void InterfaceLowerTerrain(Object[] args) 1867 private void InterfaceLowerTerrain(Object[] args)
1438 { 1868 {
1439 int x, y; 1869 int x, y;
1870<<<<<<< HEAD
1440 for(x = 0; x < m_channel.Width; x++) 1871 for(x = 0; x < m_channel.Width; x++)
1441 for(y = 0; y < m_channel.Height; y++) 1872 for(y = 0; y < m_channel.Height; y++)
1442 m_channel[x, y] -= (double)args[0]; 1873 m_channel[x, y] -= (double)args[0];
1874=======
1875 double val = (double)args[0];
1876
1877 for (x = 0; x < m_channel.Width; x++)
1878 for (y = 0; y < m_channel.Height; y++)
1879 m_channel[x, y] -= val;
1880>>>>>>> avn/ubitvar
1443 } 1881 }
1444 1882
1445 public void InterfaceFillTerrain(Object[] args) 1883 public void InterfaceFillTerrain(Object[] args)
1446 { 1884 {
1447 int x, y; 1885 int x, y;
1886 double val = (double)args[0];
1448 1887
1888<<<<<<< HEAD
1449 for(x = 0; x < m_channel.Width; x++) 1889 for(x = 0; x < m_channel.Width; x++)
1450 for(y = 0; y < m_channel.Height; y++) 1890 for(y = 0; y < m_channel.Height; y++)
1451 m_channel[x, y] = (double)args[0]; 1891 m_channel[x, y] = (double)args[0];
1892=======
1893 for (x = 0; x < m_channel.Width; x++)
1894 for (y = 0; y < m_channel.Height; y++)
1895 m_channel[x, y] = val;
1896>>>>>>> avn/ubitvar
1452 } 1897 }
1453 1898
1454 private void InterfaceMinTerrain(Object[] args) 1899 private void InterfaceMinTerrain(Object[] args)
1455 { 1900 {
1456 int x, y; 1901 int x, y;
1902<<<<<<< HEAD
1457 for(x = 0; x < m_channel.Width; x++) 1903 for(x = 0; x < m_channel.Width; x++)
1904=======
1905 double val = (double)args[0];
1906 for (x = 0; x < m_channel.Width; x++)
1907>>>>>>> avn/ubitvar
1458 { 1908 {
1459 for(y = 0; y < m_channel.Height; y++) 1909 for(y = 0; y < m_channel.Height; y++)
1460 { 1910 {
1461 m_channel[x, y] = Math.Max((double)args[0], m_channel[x, y]); 1911 m_channel[x, y] = Math.Max(val, m_channel[x, y]);
1462 } 1912 }
1463 } 1913 }
1464 } 1914 }
@@ -1466,13 +1916,19 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1466 private void InterfaceMaxTerrain(Object[] args) 1916 private void InterfaceMaxTerrain(Object[] args)
1467 { 1917 {
1468 int x, y; 1918 int x, y;
1919<<<<<<< HEAD
1469 for(x = 0; x < m_channel.Width; x++) 1920 for(x = 0; x < m_channel.Width; x++)
1921=======
1922 double val = (double)args[0];
1923 for (x = 0; x < m_channel.Width; x++)
1924>>>>>>> avn/ubitvar
1470 { 1925 {
1471 for(y = 0; y < m_channel.Height; y++) 1926 for(y = 0; y < m_channel.Height; y++)
1472 { 1927 {
1473 m_channel[x, y] = Math.Min((double)args[0], m_channel[x, y]); 1928 m_channel[x, y] = Math.Min(val, m_channel[x, y]);
1474 } 1929 }
1475 } 1930 }
1931<<<<<<< HEAD
1476 } 1932 }
1477 1933
1478 private void InterfaceShow(Object[] args) 1934 private void InterfaceShow(Object[] args)
@@ -1488,6 +1944,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1488 double height = m_channel[(int)point.X, (int)point.Y]; 1944 double height = m_channel[(int)point.X, (int)point.Y];
1489 1945
1490 Console.WriteLine("Terrain height at {0} is {1}", point, height); 1946 Console.WriteLine("Terrain height at {0} is {1}", point, height);
1947=======
1948>>>>>>> avn/ubitvar
1491 } 1949 }
1492 1950
1493 private void InterfaceShowDebugStats(Object[] args) 1951 private void InterfaceShowDebugStats(Object[] args)
@@ -1620,9 +2078,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
1620 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double"); 2078 multiplyCommand.AddArgument("value", "The value to multiply the heightmap by.", "Double");
1621 2079
1622 Command bakeRegionCommand = 2080 Command bakeRegionCommand =
1623 new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions revert map."); 2081 new Command("bake", CommandIntentions.COMMAND_HAZARDOUS, InterfaceBakeTerrain, "Saves the current terrain into the regions baked map.");
1624 Command revertRegionCommand = 2082 Command revertRegionCommand =
1625 new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the revert map terrain into the regions heightmap."); 2083 new Command("revert", CommandIntentions.COMMAND_HAZARDOUS, InterfaceRevertTerrain, "Loads the baked map terrain into the regions heightmap.");
1626 2084
1627 Command flipCommand = 2085 Command flipCommand =
1628 new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis"); 2086 new Command("flip", CommandIntentions.COMMAND_HAZARDOUS, InterfaceFlipTerrain, "Flips the current terrain about the X or Y axis");
diff --git a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
index 29e80ef..40db370 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/Tests/TerrainTest.cs
@@ -60,7 +60,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize); 60 TerrainChannel map = new TerrainChannel((int)Constants.RegionSize, (int)Constants.RegionSize);
61 ITerrainPaintableEffect effect = new RaiseSphere(); 61 ITerrainPaintableEffect effect = new RaiseSphere();
62 62
63<<<<<<< HEAD
63 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); 64 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
65=======
66 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
67 0, midRegion - 1,0, (int)Constants.RegionSize -1);
68>>>>>>> avn/ubitvar
64 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128)."); 69 Assert.That(map[127, midRegion] > 0.0, "Raise brush should raising value at this point (127,128).");
65 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128)."); 70 Assert.That(map[125, midRegion] > 0.0, "Raise brush should raising value at this point (124,128).");
66 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128)."); 71 Assert.That(map[120, midRegion] == 0.0, "Raise brush should not change value at this point (120,128).");
@@ -79,7 +84,12 @@ namespace OpenSim.Region.CoreModules.World.Terrain.Tests
79 } 84 }
80 effect = new LowerSphere(); 85 effect = new LowerSphere();
81 86
87<<<<<<< HEAD
82 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0); 88 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0);
89=======
90 effect.PaintEffect(map, allowMask, midRegion, midRegion, -1.0, 2, 6.0,
91 0, (int)Constants.RegionSize -1,0, (int)Constants.RegionSize -1);
92>>>>>>> avn/ubitvar
83 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 0.0 at this point (127,128)."); 93 Assert.That(map[127, midRegion] >= 0.0, "Lower should not lowering value below 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)."); 94 Assert.That(map[127, midRegion] == 0.0, "Lower brush should lowering value to 0.0 at this point (127,128).");
85 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128)."); 95 Assert.That(map[125, midRegion] < 1.0, "Lower brush should lowering value at this point (124,128).");