diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs index 7cea800..6806748 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/HillPlanter.cs | |||
@@ -27,8 +27,6 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System; | 29 | using System; |
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | 30 | ||
33 | namespace libTerrain | 31 | namespace libTerrain |
34 | { | 32 | { |
@@ -44,7 +42,8 @@ namespace libTerrain | |||
44 | /// <param name="island">Whether to bias hills towards the center of the map</param> | 42 | /// <param name="island">Whether to bias hills towards the center of the map</param> |
45 | /// <param name="additive">Whether to add hills together or to pick the largest value</param> | 43 | /// <param name="additive">Whether to add hills together or to pick the largest value</param> |
46 | /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param> | 44 | /// <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) | 45 | public void HillsSpheres(int number, double scale_min, double scale_range, bool island, bool additive, |
46 | bool noisy) | ||
48 | { | 47 | { |
49 | SetDiff(); | 48 | SetDiff(); |
50 | 49 | ||
@@ -55,20 +54,20 @@ namespace libTerrain | |||
55 | 54 | ||
56 | for (i = 0; i < number; i++) | 55 | for (i = 0; i < number; i++) |
57 | { | 56 | { |
58 | double rx = Math.Min(255.0, random.NextDouble() * w); | 57 | double rx = Math.Min(255.0, random.NextDouble()*w); |
59 | double ry = Math.Min(255.0, random.NextDouble() * h); | 58 | double ry = Math.Min(255.0, random.NextDouble()*h); |
60 | double rand = random.NextDouble(); | 59 | double rand = random.NextDouble(); |
61 | 60 | ||
62 | if (island) | 61 | if (island) |
63 | { | 62 | { |
64 | // Move everything towards the center | 63 | // Move everything towards the center |
65 | rx -= w / 2; | 64 | rx -= w/2; |
66 | rx /= 2; | 65 | rx /= 2; |
67 | rx += w / 2; | 66 | rx += w/2; |
68 | 67 | ||
69 | ry -= h / 2; | 68 | ry -= h/2; |
70 | ry /= 2; | 69 | ry /= 2; |
71 | ry += h / 2; | 70 | ry += h/2; |
72 | } | 71 | } |
73 | 72 | ||
74 | for (x = 0; x < w; x++) | 73 | for (x = 0; x < w; x++) |
@@ -78,9 +77,9 @@ namespace libTerrain | |||
78 | if (noisy) | 77 | if (noisy) |
79 | rand = random.NextDouble(); | 78 | rand = random.NextDouble(); |
80 | 79 | ||
81 | double z = (scale_min + (scale_range * rand)); | 80 | double z = (scale_min + (scale_range*rand)); |
82 | z *= z; | 81 | z *= z; |
83 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 82 | z -= ((x - rx)*(x - rx)) + ((y - ry)*(y - ry)); |
84 | 83 | ||
85 | if (z < 0) | 84 | if (z < 0) |
86 | z = 0; | 85 | z = 0; |
@@ -121,20 +120,20 @@ namespace libTerrain | |||
121 | 120 | ||
122 | for (i = 0; i < number; i++) | 121 | for (i = 0; i < number; i++) |
123 | { | 122 | { |
124 | double rx = Math.Min(255.0, random.NextDouble() * w); | 123 | double rx = Math.Min(255.0, random.NextDouble()*w); |
125 | double ry = Math.Min(255.0, random.NextDouble() * h); | 124 | double ry = Math.Min(255.0, random.NextDouble()*h); |
126 | double rand = random.NextDouble(); | 125 | double rand = random.NextDouble(); |
127 | 126 | ||
128 | if (island) | 127 | if (island) |
129 | { | 128 | { |
130 | // Move everything towards the center | 129 | // Move everything towards the center |
131 | rx -= w / 2; | 130 | rx -= w/2; |
132 | rx /= 2; | 131 | rx /= 2; |
133 | rx += w / 2; | 132 | rx += w/2; |
134 | 133 | ||
135 | ry -= h / 2; | 134 | ry -= h/2; |
136 | ry /= 2; | 135 | ry /= 2; |
137 | ry += h / 2; | 136 | ry += h/2; |
138 | } | 137 | } |
139 | 138 | ||
140 | for (x = 0; x < w; x++) | 139 | for (x = 0; x < w; x++) |
@@ -144,8 +143,8 @@ namespace libTerrain | |||
144 | if (noisy) | 143 | if (noisy) |
145 | rand = random.NextDouble(); | 144 | rand = random.NextDouble(); |
146 | 145 | ||
147 | double z = (scale_min + (scale_range * rand)); | 146 | double z = (scale_min + (scale_range*rand)); |
148 | z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); | 147 | z -= Math.Sqrt(((x - rx)*(x - rx)) + ((y - ry)*(y - ry))); |
149 | 148 | ||
150 | if (z < 0) | 149 | if (z < 0) |
151 | z = 0; | 150 | z = 0; |
@@ -176,20 +175,20 @@ namespace libTerrain | |||
176 | 175 | ||
177 | for (i = 0; i < number; i++) | 176 | for (i = 0; i < number; i++) |
178 | { | 177 | { |
179 | double rx = Math.Min(255.0, random.NextDouble() * w); | 178 | double rx = Math.Min(255.0, random.NextDouble()*w); |
180 | double ry = Math.Min(255.0, random.NextDouble() * h); | 179 | double ry = Math.Min(255.0, random.NextDouble()*h); |
181 | double rand = random.NextDouble(); | 180 | double rand = random.NextDouble(); |
182 | 181 | ||
183 | if (island) | 182 | if (island) |
184 | { | 183 | { |
185 | // Move everything towards the center | 184 | // Move everything towards the center |
186 | rx -= w / 2; | 185 | rx -= w/2; |
187 | rx /= 2; | 186 | rx /= 2; |
188 | rx += w / 2; | 187 | rx += w/2; |
189 | 188 | ||
190 | ry -= h / 2; | 189 | ry -= h/2; |
191 | ry /= 2; | 190 | ry /= 2; |
192 | ry += h / 2; | 191 | ry += h/2; |
193 | } | 192 | } |
194 | 193 | ||
195 | for (x = 0; x < w; x++) | 194 | for (x = 0; x < w; x++) |
@@ -199,8 +198,8 @@ namespace libTerrain | |||
199 | if (noisy) | 198 | if (noisy) |
200 | rand = random.NextDouble(); | 199 | rand = random.NextDouble(); |
201 | 200 | ||
202 | double z = (scale_min + (scale_range * rand)); | 201 | double z = (scale_min + (scale_range*rand)); |
203 | z -= Math.Abs(x-rx) + Math.Abs(y-ry); | 202 | z -= Math.Abs(x - rx) + Math.Abs(y - ry); |
204 | //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); | 203 | //z -= Math.Sqrt(((x - rx) * (x - rx)) + ((y - ry) * (y - ry))); |
205 | 204 | ||
206 | if (z < 0) | 205 | if (z < 0) |
@@ -221,7 +220,8 @@ namespace libTerrain | |||
221 | Normalise(); | 220 | Normalise(); |
222 | } | 221 | } |
223 | 222 | ||
224 | public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, bool noisy) | 223 | public void HillsSquared(int number, double scale_min, double scale_range, bool island, bool additive, |
224 | bool noisy) | ||
225 | { | 225 | { |
226 | SetDiff(); | 226 | SetDiff(); |
227 | 227 | ||
@@ -232,20 +232,20 @@ namespace libTerrain | |||
232 | 232 | ||
233 | for (i = 0; i < number; i++) | 233 | for (i = 0; i < number; i++) |
234 | { | 234 | { |
235 | double rx = Math.Min(255.0, random.NextDouble() * w); | 235 | double rx = Math.Min(255.0, random.NextDouble()*w); |
236 | double ry = Math.Min(255.0, random.NextDouble() * h); | 236 | double ry = Math.Min(255.0, random.NextDouble()*h); |
237 | double rand = random.NextDouble(); | 237 | double rand = random.NextDouble(); |
238 | 238 | ||
239 | if (island) | 239 | if (island) |
240 | { | 240 | { |
241 | // Move everything towards the center | 241 | // Move everything towards the center |
242 | rx -= w / 2; | 242 | rx -= w/2; |
243 | rx /= 2; | 243 | rx /= 2; |
244 | rx += w / 2; | 244 | rx += w/2; |
245 | 245 | ||
246 | ry -= h / 2; | 246 | ry -= h/2; |
247 | ry /= 2; | 247 | ry /= 2; |
248 | ry += h / 2; | 248 | ry += h/2; |
249 | } | 249 | } |
250 | 250 | ||
251 | for (x = 0; x < w; x++) | 251 | for (x = 0; x < w; x++) |
@@ -255,11 +255,11 @@ namespace libTerrain | |||
255 | if (noisy) | 255 | if (noisy) |
256 | rand = random.NextDouble(); | 256 | rand = random.NextDouble(); |
257 | 257 | ||
258 | double z = (scale_min + (scale_range * rand)); | 258 | double z = (scale_min + (scale_range*rand)); |
259 | z *= z * z * z; | 259 | z *= z*z*z; |
260 | double dx = Math.Abs(x - rx); | 260 | double dx = Math.Abs(x - rx); |
261 | double dy = Math.Abs(y - ry); | 261 | double dy = Math.Abs(y - ry); |
262 | z -= (dx * dx * dx * dx) + (dy * dy * dy * dy); | 262 | z -= (dx*dx*dx*dx) + (dy*dy*dy*dy); |
263 | 263 | ||
264 | if (z < 0) | 264 | if (z < 0) |
265 | z = 0; | 265 | z = 0; |
@@ -278,6 +278,5 @@ namespace libTerrain | |||
278 | 278 | ||
279 | Normalise(); | 279 | Normalise(); |
280 | } | 280 | } |
281 | |||
282 | } | 281 | } |
283 | } | 282 | } \ No newline at end of file |