aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorAdam Frisby2007-07-24 05:22:33 +0000
committerAdam Frisby2007-07-24 05:22:33 +0000
commitd8997b59d30b63218f594d840d924a10287ce509 (patch)
treef96960b2605c8da0d6b0a0d9a905db28a62fca67 /OpenSim
parent* Terrain Fracture Generator now produces more appropriate results. (diff)
downloadopensim-SC-d8997b59d30b63218f594d840d924a10287ce509.zip
opensim-SC-d8997b59d30b63218f594d840d924a10287ce509.tar.gz
opensim-SC-d8997b59d30b63218f594d840d924a10287ce509.tar.bz2
opensim-SC-d8997b59d30b63218f594d840d924a10287ce509.tar.xz
* Terrain should now send just updated patches.
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs45
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs4
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs16
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs3
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs33
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs6
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs8
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs9
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs7
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs18
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs4
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs2
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs25
20 files changed, 167 insertions, 27 deletions
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 16b8b4c..564ba5f 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -235,25 +235,40 @@ namespace OpenSim.Region.Environment.Scenes
235 storageCount = 0; 235 storageCount = 0;
236 } 236 }
237 237
238 if (Terrain.tainted > 0) 238 if (Terrain.Tainted())
239 { 239 {
240 lock (m_syncRoot) 240 lock (Terrain.heightmap)
241 { 241 {
242 phyScene.SetTerrain(Terrain.GetHeights1D()); 242 lock (m_syncRoot)
243 } 243 {
244 phyScene.SetTerrain(Terrain.GetHeights1D());
245 }
244 246
245 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); 247 storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD());
246 248
247 ForEachScenePresence(delegate(ScenePresence presence) 249 float[] terData = Terrain.GetHeights1D();
248 { 250
249 SendLayerData(presence.ControllingClient); 251 ForEachScenePresence(delegate(ScenePresence presence)
250 }); 252 {
253 for (int x = 0; x < 16; x++)
254 {
255 for (int y = 0; y < 16; y++)
256 {
257 if (Terrain.Tainted(x, y))
258 {
259 SendLayerData(x, y, presence.ControllingClient, terData);
260 }
261 }
262 }
263 });
264
265 foreach (LLUUID UUID in Entities.Keys)
266 {
267 Entities[UUID].LandRenegerated();
268 }
251 269
252 foreach (LLUUID UUID in Entities.Keys) 270 Terrain.ResetTaint();
253 {
254 Entities[UUID].LandRenegerated();
255 } 271 }
256 Terrain.tainted = 0;
257 } 272 }
258 273
259 landPrimCheckCount++; 274 landPrimCheckCount++;
@@ -365,9 +380,11 @@ namespace OpenSim.Region.Environment.Scenes
365 { 380 {
366 /* Dont save here, rely on tainting system instead */ 381 /* Dont save here, rely on tainting system instead */
367 382
383 float[] terrain = Terrain.GetHeights1D();
384
368 ForEachScenePresence(delegate(ScenePresence presence) 385 ForEachScenePresence(delegate(ScenePresence presence)
369 { 386 {
370 SendLayerData(pointx, pointy, presence.ControllingClient); 387 SendLayerData(pointx, pointy, presence.ControllingClient, terrain);
371 }); 388 });
372 } 389 }
373 } 390 }
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index fb7624a..76a8439 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -90,9 +90,9 @@ namespace OpenSim.Region.Environment.Scenes
90 /// <param name="px">Patch coordinate (x) 0..16</param> 90 /// <param name="px">Patch coordinate (x) 0..16</param>
91 /// <param name="py">Patch coordinate (y) 0..16</param> 91 /// <param name="py">Patch coordinate (y) 0..16</param>
92 /// <param name="RemoteClient">The client to send to</param> 92 /// <param name="RemoteClient">The client to send to</param>
93 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) 93 public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient, float[] terrain)
94 { 94 {
95 RemoteClient.SendLayerData(px, py, Terrain.GetHeights1D()); 95 RemoteClient.SendLayerData(px, py, terrain);
96 } 96 }
97 97
98 #endregion 98 #endregion
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index 9c58874..a609623 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -99,6 +99,22 @@ namespace OpenSim.Region.Terrain
99 tainted++; 99 tainted++;
100 } 100 }
101 101
102 public bool Tainted()
103 {
104 return (tainted != 0);
105 }
106
107 public bool Tainted(int x, int y)
108 {
109 return (heightmap.diff[x / 16, y / 16] != 0);
110 }
111
112 public void ResetTaint()
113 {
114 tainted = 0;
115 heightmap.diff = new int[w / 16, h / 16];
116 }
117
102 /// <summary> 118 /// <summary>
103 /// Checks to make sure the terrain is within baked values +/- maxRaise/minLower 119 /// Checks to make sure the terrain is within baked values +/- maxRaise/minLower
104 /// </summary> 120 /// </summary>
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
index 53fb6b2..6dfee1f 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Channel.cs
@@ -40,6 +40,7 @@ namespace libTerrain
40 partial class Channel 40 partial class Channel
41 { 41 {
42 public double[,] map; 42 public double[,] map;
43 public int[,] diff;
43 public int w; 44 public int w;
44 public int h; 45 public int h;
45 46
@@ -50,6 +51,7 @@ namespace libTerrain
50 w = 256; 51 w = 256;
51 h = 256; 52 h = 256;
52 map = new double[w, h]; 53 map = new double[w, h];
54 diff = new int[(int)(w / 16), (int)(h / 16)];
53 } 55 }
54 56
55 public Channel(int width, int height) 57 public Channel(int width, int height)
@@ -57,6 +59,7 @@ namespace libTerrain
57 w = width; 59 w = width;
58 h = height; 60 h = height;
59 map = new double[w, h]; 61 map = new double[w, h];
62 diff = new int[(int)(w / 16), (int)(h / 16)];
60 } 63 }
61 64
62 } 65 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
index 0d6d0fc..5715c70 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Common.cs
@@ -51,8 +51,31 @@ namespace libTerrain
51 return x; 51 return x;
52 } 52 }
53 53
54 public void SetDiff()
55 {
56 SetDiff(1);
57 }
58
59 public void SetDiff(int val)
60 {
61 for (int x = 0; x < w / 16; x++)
62 {
63 for (int y = 0; y < h / 16; y++)
64 {
65 diff[x, y] = val;
66 }
67 }
68 }
69
70 public void SetDiff(int x, int y)
71 {
72 diff[x / 16, y / 16]++;
73 }
74
54 public void Set(int x, int y, double val) 75 public void Set(int x, int y, double val)
55 { 76 {
77 SetDiff(x, y);
78
56 if (x >= w) 79 if (x >= w)
57 throw new Exception("Bounds error while setting pixel (width)"); 80 throw new Exception("Bounds error while setting pixel (width)");
58 if (y >= h) 81 if (y >= h)
@@ -67,6 +90,8 @@ namespace libTerrain
67 90
68 public void SetClip(int x, int y, double val) 91 public void SetClip(int x, int y, double val)
69 { 92 {
93 SetDiff(x, y);
94
70 if (x >= w) 95 if (x >= w)
71 throw new Exception("Bounds error while setting pixel (width)"); 96 throw new Exception("Bounds error while setting pixel (width)");
72 if (y >= h) 97 if (y >= h)
@@ -129,11 +154,15 @@ namespace libTerrain
129 154
130 public void SetWrap(int x, int y, double val) 155 public void SetWrap(int x, int y, double val)
131 { 156 {
157 SetDiff(x, y);
158
132 map[x % w, y % h] = val; 159 map[x % w, y % h] = val;
133 } 160 }
134 161
135 public void SetWrapClip(int x, int y, double val) 162 public void SetWrapClip(int x, int y, double val)
136 { 163 {
164 SetDiff(x, y);
165
137 if (val > 1.0) 166 if (val > 1.0)
138 val = 1.0; 167 val = 1.0;
139 if (val < 0.0) 168 if (val < 0.0)
@@ -144,6 +173,8 @@ namespace libTerrain
144 173
145 public void Fill(double val) 174 public void Fill(double val)
146 { 175 {
176 SetDiff();
177
147 int x, y; 178 int x, y;
148 for (x = 0; x < w; x++) 179 for (x = 0; x < w; x++)
149 { 180 {
@@ -156,6 +187,8 @@ namespace libTerrain
156 187
157 public void Fill(double min, double max, double val) 188 public void Fill(double min, double max, double val)
158 { 189 {
190 SetDiff();
191
159 int x, y; 192 int x, y;
160 for (x = 0; x < w; x++) 193 for (x = 0; x < w; x++)
161 { 194 {
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
index 03b88a4..ef7a6a7 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
@@ -115,7 +115,7 @@ namespace libTerrain
115 if (z < 0) 115 if (z < 0)
116 z = 0; 116 z = 0;
117 117
118 map[x, y] = Tools.linearInterpolate(map[x, y], height, z); 118 Set(x, y, Tools.linearInterpolate(map[x, y], height, z));
119 } 119 }
120 } 120 }
121 } 121 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
index 7bccef3..1d04a4f 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Raise.cs
@@ -68,7 +68,7 @@ namespace libTerrain
68 if (z < 0) 68 if (z < 0)
69 z = 0; 69 z = 0;
70 70
71 map[x, y] += z * amount; 71 Set(x, y, map[x, y] + (z * amount));
72 } 72 }
73 } 73 }
74 } 74 }
@@ -93,7 +93,7 @@ namespace libTerrain
93 if (z < 0) 93 if (z < 0)
94 z = 0; 94 z = 0;
95 95
96 map[x, y] += z * amount; 96 Set(x, y, map[x, y] + (z * amount));
97 } 97 }
98 } 98 }
99 } 99 }
@@ -131,7 +131,7 @@ namespace libTerrain
131 if (z < 0) 131 if (z < 0)
132 z = 0; 132 z = 0;
133 133
134 map[x, y] -= z * amount; 134 Set(x, y, map[x, y] - (z * amount));
135 } 135 }
136 } 136 }
137 } 137 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
index e09dc5a..b147004 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/File.cs
@@ -37,6 +37,8 @@ namespace libTerrain
37 { 37 {
38 public Channel LoadImage(string filename) 38 public Channel LoadImage(string filename)
39 { 39 {
40 SetDiff();
41
40 Bitmap bit = new Bitmap(filename); 42 Bitmap bit = new Bitmap(filename);
41 Channel chan = new Channel(bit.Width, bit.Height); 43 Channel chan = new Channel(bit.Width, bit.Height);
42 44
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
index 8427eab..13dd1bc 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
@@ -82,6 +82,8 @@ namespace libTerrain
82 82
83 public void Fracture(int number, double scalemin, double scalemax) 83 public void Fracture(int number, double scalemin, double scalemax)
84 { 84 {
85 SetDiff();
86
85 Random rand = new Random(seed); 87 Random rand = new Random(seed);
86 88
87 for (int i = 0; i < number; i++) 89 for (int i = 0; i < number; i++)
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
index 0c9b3c3..47b7a66 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Gradient.cs
@@ -37,6 +37,8 @@ namespace libTerrain
37 37
38 public void GradientCube() 38 public void GradientCube()
39 { 39 {
40 SetDiff();
41
40 int x, y; 42 int x, y;
41 for (x = 0; x < w; x++) 43 for (x = 0; x < w; x++)
42 { 44 {
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
index 3b8e963..5a697b1 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs
@@ -46,6 +46,8 @@ namespace libTerrain
46 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param> 46 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
47 public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 47 public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
48 { 48 {
49 SetDiff();
50
49 Random random = new Random(seed); 51 Random random = new Random(seed);
50 52
51 int x, y; 53 int x, y;
@@ -110,6 +112,8 @@ namespace libTerrain
110 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param> 112 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
111 public void HillsCones(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 113 public void HillsCones(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
112 { 114 {
115 SetDiff();
116
113 Random random = new Random(seed); 117 Random random = new Random(seed);
114 118
115 int x, y; 119 int x, y;
@@ -163,6 +167,8 @@ namespace libTerrain
163 167
164 public void HillsBlocks(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 168 public void HillsBlocks(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
165 { 169 {
170 SetDiff();
171
166 Random random = new Random(seed); 172 Random random = new Random(seed);
167 173
168 int x, y; 174 int x, y;
@@ -217,6 +223,8 @@ namespace libTerrain
217 223
218 public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) 224 public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
219 { 225 {
226 SetDiff();
227
220 Random random = new Random(seed); 228 Random random = new Random(seed);
221 229
222 int x, y; 230 int x, y;
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
index ebb1771..3cefcfe 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Noise.cs
@@ -40,6 +40,8 @@ namespace libTerrain
40 /// <remarks>3-Clause BSD Licensed</remarks> 40 /// <remarks>3-Clause BSD Licensed</remarks>
41 public void Noise() 41 public void Noise()
42 { 42 {
43 SetDiff();
44
43 Random rand = new Random(seed); 45 Random rand = new Random(seed);
44 int x, y; 46 int x, y;
45 for (x = 0; x < w; x++) 47 for (x = 0; x < w; x++)
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
index aeff730..80abfe5 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Spiral.cs
@@ -36,7 +36,6 @@ namespace libTerrain
36 { 36 {
37 private double[] CoordinatesToPolar(int x, int y) 37 private double[] CoordinatesToPolar(int x, int y)
38 { 38 {
39
40 double theta = Math.Atan2(x - (w / 2), y - (h / 2)); 39 double theta = Math.Atan2(x - (w / 2), y - (h / 2));
41 double rx = (double)x - ((double)w / 2); 40 double rx = (double)x - ((double)w / 2);
42 double ry = (double)y - ((double)h / 2); 41 double ry = (double)y - ((double)h / 2);
@@ -78,6 +77,8 @@ namespace libTerrain
78 77
79 public void Polar() 78 public void Polar()
80 { 79 {
80 SetDiff();
81
81 Channel n = this.Copy(); 82 Channel n = this.Copy();
82 83
83 int x, y; 84 int x, y;
@@ -97,6 +98,8 @@ namespace libTerrain
97 98
98 public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle) 99 public void SpiralPlanter(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle)
99 { 100 {
101 SetDiff();
102
100 int i; 103 int i;
101 double r = offsetRadius; 104 double r = offsetRadius;
102 double theta = offsetAngle; 105 double theta = offsetAngle;
@@ -112,6 +115,8 @@ namespace libTerrain
112 115
113 public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c) 116 public void SpiralCells(int steps, double incAngle, double incRadius, double offsetRadius, double offsetAngle, double[] c)
114 { 117 {
118 SetDiff();
119
115 List<Point2D> points = new List<Point2D>(); 120 List<Point2D> points = new List<Point2D>();
116 121
117 int i; 122 int i;
@@ -131,6 +136,8 @@ namespace libTerrain
131 136
132 public void Spiral(double wid, double hig, double offset) 137 public void Spiral(double wid, double hig, double offset)
133 { 138 {
139 SetDiff();
140
134 int x, y, z; 141 int x, y, z;
135 z = 0; 142 z = 0;
136 for (x = 0; x < w; x++) 143 for (x = 0; x < w; x++)
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
index e973d14..eb8f7ba 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Voronoi.cs
@@ -44,6 +44,8 @@ namespace libTerrain
44 /// <param name="c">The Voronoi diagram type. Usually an array with values consisting of [-1,1]. Experiment with the chain, you can have as many values as you like.</param> 44 /// <param name="c">The Voronoi diagram type. Usually an array with values consisting of [-1,1]. Experiment with the chain, you can have as many values as you like.</param>
45 public void VoronoiDiagram(int pointsPerBlock, int blockSize, double[] c) 45 public void VoronoiDiagram(int pointsPerBlock, int blockSize, double[] c)
46 { 46 {
47 SetDiff();
48
47 List<Point2D> points = new List<Point2D>(); 49 List<Point2D> points = new List<Point2D>();
48 Random generator = new Random(seed); 50 Random generator = new Random(seed);
49 51
@@ -103,7 +105,8 @@ namespace libTerrain
103 105
104 public void VoronoiDiagram(List<Point2D> points, double[] c) 106 public void VoronoiDiagram(List<Point2D> points, double[] c)
105 { 107 {
106 108 SetDiff();
109
107 Random generator = new Random(seed); 110 Random generator = new Random(seed);
108 int x, y, i; 111 int x, y, i;
109 double[] distances = new double[points.Count]; 112 double[] distances = new double[points.Count];
@@ -146,6 +149,8 @@ namespace libTerrain
146 149
147 public void VoroflatDiagram(int pointsPerBlock, int blockSize) 150 public void VoroflatDiagram(int pointsPerBlock, int blockSize)
148 { 151 {
152 SetDiff();
153
149 List<Point2D> points = new List<Point2D>(); 154 List<Point2D> points = new List<Point2D>();
150 Random generator = new Random(seed); 155 Random generator = new Random(seed);
151 156
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
index 38a8023..ce36daf 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Worms.cs
@@ -44,6 +44,8 @@ namespace libTerrain
44 /// <param name="centerspawn">Do worms start in the middle, or randomly?</param> 44 /// <param name="centerspawn">Do worms start in the middle, or randomly?</param>
45 public void Worms(int number, int rounds, double movement, double size, bool centerspawn) 45 public void Worms(int number, int rounds, double movement, double size, bool centerspawn)
46 { 46 {
47 SetDiff();
48
47 Random random = new Random(seed); 49 Random random = new Random(seed);
48 int i, j; 50 int i, j;
49 51
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
index a9106b4..a39db50 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Grid.cs
@@ -36,6 +36,8 @@ namespace libTerrain
36 { 36 {
37 public Channel Normalise() 37 public Channel Normalise()
38 { 38 {
39 SetDiff();
40
39 double max = FindMax(); 41 double max = FindMax();
40 double min = FindMin(); 42 double min = FindMin();
41 43
@@ -54,6 +56,8 @@ namespace libTerrain
54 56
55 public Channel Normalise(double minv, double maxv) 57 public Channel Normalise(double minv, double maxv)
56 { 58 {
59 SetDiff();
60
57 double max = FindMax(); 61 double max = FindMax();
58 double min = FindMin(); 62 double min = FindMin();
59 63
@@ -99,7 +103,8 @@ namespace libTerrain
99 double val = map[x, y]; 103 double val = map[x, y];
100 if (val > max) val = max; 104 if (val > max) val = max;
101 if (val < min) val = min; 105 if (val < min) val = min;
102 map[x, y] = val; 106
107 Set(x, y, val);
103 } 108 }
104 } 109 }
105 return this; 110 return this;
@@ -132,6 +137,8 @@ namespace libTerrain
132 137
133 public Channel AddClip(Channel other) 138 public Channel AddClip(Channel other)
134 { 139 {
140 SetDiff();
141
135 int x, y; 142 int x, y;
136 for (x = 0; x < w; x++) 143 for (x = 0; x < w; x++)
137 { 144 {
@@ -149,6 +156,8 @@ namespace libTerrain
149 156
150 public void Smooth(double amount) 157 public void Smooth(double amount)
151 { 158 {
159 SetDiff();
160
152 double area = amount; 161 double area = amount;
153 double step = amount / 4.0; 162 double step = amount / 4.0;
154 163
@@ -179,6 +188,8 @@ namespace libTerrain
179 188
180 public void Pertubation(double amount) 189 public void Pertubation(double amount)
181 { 190 {
191 SetDiff();
192
182 // Simple pertubation filter 193 // Simple pertubation filter
183 double[,] manipulated = new double[w, h]; 194 double[,] manipulated = new double[w, h];
184 Random generator = new Random(seed); // Seeds FTW! 195 Random generator = new Random(seed); // Seeds FTW!
@@ -227,6 +238,7 @@ namespace libTerrain
227 238
228 double p = GetBilinearInterpolate(offset_x, offset_y); 239 double p = GetBilinearInterpolate(offset_x, offset_y);
229 manipulated[x, y] = p; 240 manipulated[x, y] = p;
241 SetDiff(x, y);
230 } 242 }
231 } 243 }
232 map = manipulated; 244 map = manipulated;
@@ -239,7 +251,7 @@ namespace libTerrain
239 { 251 {
240 for (y = 0; y < h; y++) 252 for (y = 0; y < h; y++)
241 { 253 {
242 map[x, y] = Tools.linearInterpolate(map[x,y],other.map[x,y],amount); 254 Set(x, y, Tools.linearInterpolate(map[x, y], other.map[x, y], amount));
243 } 255 }
244 } 256 }
245 return this; 257 return this;
@@ -252,7 +264,7 @@ namespace libTerrain
252 { 264 {
253 for (y = 0; y < h; y++) 265 for (y = 0; y < h; y++)
254 { 266 {
255 map[x, y] = Tools.linearInterpolate(map[x, y], other.map[x, y], amount.map[x,y]); 267 Set(x, y, Tools.linearInterpolate(map[x, y], other.map[x, y], amount.map[x, y]));
256 } 268 }
257 } 269 }
258 return this; 270 return this;
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
index 198c337..f4dfe1d 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
@@ -118,7 +118,7 @@ namespace libTerrain
118 118
119 if (surfacearea > pickupTalusMinimum) 119 if (surfacearea > pickupTalusMinimum)
120 { 120 {
121 this.map[x, y] -= amount; 121 Set(x, y, map[x, y] - amount);
122 sediment.map[x, y] += amount; 122 sediment.map[x, y] += amount;
123 } 123 }
124 } 124 }
@@ -168,7 +168,7 @@ namespace libTerrain
168 168
169 if (surfacearea > dropTalusMinimum) 169 if (surfacearea > dropTalusMinimum)
170 { 170 {
171 this.map[x + minside[0], y + minside[1]] += amount; 171 Set(x + minside[0], y + minside[1], map[x + minside[0], y + minside[1]] + amount);
172 sediment.map[x, y] -= amount; 172 sediment.map[x, y] -= amount;
173 } 173 }
174 } 174 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
index 5ace241..36da77c 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/HydraulicErosion.cs
@@ -36,6 +36,8 @@ namespace libTerrain
36 { 36 {
37 public void HydraulicErosion(Channel rain, double evaporation, double solubility, int frequency, int rounds) 37 public void HydraulicErosion(Channel rain, double evaporation, double solubility, int frequency, int rounds)
38 { 38 {
39 SetDiff();
40
39 Channel water = new Channel(w, h); 41 Channel water = new Channel(w, h);
40 Channel sediment = new Channel(w, h); 42 Channel sediment = new Channel(w, h);
41 Channel terrain = this; 43 Channel terrain = this;
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
index 449bf85..07c7d66 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/ThermalWeathering.cs
@@ -42,6 +42,8 @@ namespace libTerrain
42 /// <param name="c">The amount of rock to carry each round</param> 42 /// <param name="c">The amount of rock to carry each round</param>
43 public Channel ThermalWeathering(double talus, int rounds, double c) 43 public Channel ThermalWeathering(double talus, int rounds, double c)
44 { 44 {
45 SetDiff();
46
45 double[,] lastFrame; 47 double[,] lastFrame;
46 double[,] thisFrame; 48 double[,] thisFrame;
47 49
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
index 623c85c..3199ddc 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Operators.cs
@@ -49,6 +49,9 @@ namespace libTerrain
49 { 49 {
50 for (y = 0; y < A.h; y++) 50 for (y = 0; y < A.h; y++)
51 { 51 {
52 if (B.map[x, y] != 0)
53 A.SetDiff(x, y);
54
52 A.map[x, y] += B.map[x, y]; 55 A.map[x, y] += B.map[x, y];
53 } 56 }
54 } 57 }
@@ -73,6 +76,8 @@ namespace libTerrain
73 } 76 }
74 } 77 }
75 78
79 A.SetDiff();
80
76 return A; 81 return A;
77 } 82 }
78 83
@@ -89,6 +94,8 @@ namespace libTerrain
89 { 94 {
90 for (y = 0; y < A.h; y++) 95 for (y = 0; y < A.h; y++)
91 { 96 {
97 if (B.map[x, y] != 0)
98 A.SetDiff(x, y);
92 A.map[x, y] -= B.map[x, y]; 99 A.map[x, y] -= B.map[x, y];
93 } 100 }
94 } 101 }
@@ -113,6 +120,8 @@ namespace libTerrain
113 } 120 }
114 } 121 }
115 122
123 A.SetDiff();
124
116 return A; 125 return A;
117 } 126 }
118 127
@@ -133,6 +142,8 @@ namespace libTerrain
133 } 142 }
134 } 143 }
135 144
145 A.SetDiff();
146
136 return A; 147 return A;
137 } 148 }
138 149
@@ -151,6 +162,9 @@ namespace libTerrain
151 } 162 }
152 } 163 }
153 164
165 if (B != 0)
166 A.SetDiff();
167
154 return A; 168 return A;
155 } 169 }
156 170
@@ -166,6 +180,9 @@ namespace libTerrain
166 } 180 }
167 } 181 }
168 182
183 if (B != 0)
184 A.SetDiff();
185
169 return A; 186 return A;
170 } 187 }
171 188
@@ -181,6 +198,9 @@ namespace libTerrain
181 } 198 }
182 } 199 }
183 200
201 if (B != 1)
202 A.SetDiff();
203
184 return A; 204 return A;
185 } 205 }
186 206
@@ -196,6 +216,9 @@ namespace libTerrain
196 } 216 }
197 } 217 }
198 218
219 if (B != 1)
220 A.SetDiff();
221
199 return A; 222 return A;
200 } 223 }
201 224
@@ -211,6 +234,8 @@ namespace libTerrain
211 } 234 }
212 } 235 }
213 236
237 A.SetDiff();
238
214 return A; 239 return A;
215 } 240 }
216 241