diff options
author | Adam Frisby | 2007-07-25 10:08:16 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-25 10:08:16 +0000 |
commit | cd88a4914dc31779a13d673aaaa6a1327ebeb351 (patch) | |
tree | 5626fed7ae06f4f39fb6f837f47b04dc2b642f28 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators | |
parent | * Several functions should now be more efficient with sending packets to the ... (diff) | |
download | opensim-SC-cd88a4914dc31779a13d673aaaa6a1327ebeb351.zip opensim-SC-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.gz opensim-SC-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.bz2 opensim-SC-cd88a4914dc31779a13d673aaaa6a1327ebeb351.tar.xz |
* Assorted terrain fixes
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators')
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs | 37 | ||||
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs | 39 |
2 files changed, 68 insertions, 8 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs index f4dfe1d..fecb748 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs | |||
@@ -76,13 +76,19 @@ namespace libTerrain | |||
76 | /// <param name="lowest">Drop sediment at the lowest point?</param> | 76 | /// <param name="lowest">Drop sediment at the lowest point?</param> |
77 | public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics) | 77 | public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry, int rounds, bool lowest, bool usingFluidDynamics) |
78 | { | 78 | { |
79 | bool debugImages = true; | ||
80 | |||
79 | Channel wind = new Channel(w, h) ; | 81 | Channel wind = new Channel(w, h) ; |
80 | Channel sediment = new Channel(w, h); | 82 | Channel sediment = new Channel(w, h); |
81 | int x, y, i, j; | 83 | int x, y, i, j; |
82 | 84 | ||
85 | this.Normalise(); | ||
86 | |||
83 | wind = this.Copy(); | 87 | wind = this.Copy(); |
84 | wind.Normalise(); // Cheap wind calculations | 88 | wind.Noise(); |
85 | wind *= windspeed; | 89 | |
90 | if (debugImages) | ||
91 | wind.SaveImage("testimg/wind_start.png"); | ||
86 | 92 | ||
87 | if (usingFluidDynamics) | 93 | if (usingFluidDynamics) |
88 | { | 94 | { |
@@ -90,9 +96,12 @@ namespace libTerrain | |||
90 | } | 96 | } |
91 | else | 97 | else |
92 | { | 98 | { |
93 | wind.Pertubation(30); // Can do better later | 99 | wind.Pertubation(30); |
94 | } | 100 | } |
95 | 101 | ||
102 | if (debugImages) | ||
103 | wind.SaveImage("testimg/wind_begin.png"); | ||
104 | |||
96 | for (i = 0; i < rounds; i++) | 105 | for (i = 0; i < rounds; i++) |
97 | { | 106 | { |
98 | // Convert some rocks to sand | 107 | // Convert some rocks to sand |
@@ -127,7 +136,14 @@ namespace libTerrain | |||
127 | if (usingFluidDynamics) | 136 | if (usingFluidDynamics) |
128 | { | 137 | { |
129 | sediment.navierStokes(7, 0.1, 0.0, 0.1); | 138 | sediment.navierStokes(7, 0.1, 0.0, 0.1); |
130 | wind.navierStokes(10, 0.1, 0.0, 0.0); | 139 | |
140 | Channel noiseChan = new Channel(w, h); | ||
141 | noiseChan.Noise(); | ||
142 | wind.Blend(noiseChan, 0.01); | ||
143 | |||
144 | wind.navierStokes(10, 0.1, 0.01, 0.01); | ||
145 | |||
146 | sediment.Distort(wind, windspeed); | ||
131 | } | 147 | } |
132 | else | 148 | else |
133 | { | 149 | { |
@@ -137,6 +153,9 @@ namespace libTerrain | |||
137 | sediment.seed++; | 153 | sediment.seed++; |
138 | } | 154 | } |
139 | 155 | ||
156 | if (debugImages) | ||
157 | wind.SaveImage("testimg/wind_" + i.ToString() + ".png"); | ||
158 | |||
140 | // Convert some sand to rock | 159 | // Convert some sand to rock |
141 | for (x = 1; x < w - 1; x++) | 160 | for (x = 1; x < w - 1; x++) |
142 | { | 161 | { |
@@ -174,11 +193,21 @@ namespace libTerrain | |||
174 | } | 193 | } |
175 | } | 194 | } |
176 | 195 | ||
196 | if (debugImages) | ||
197 | sediment.SaveImage("testimg/sediment_" + i.ToString() + ".png"); | ||
198 | |||
199 | wind.Normalise(); | ||
200 | wind *= windspeed; | ||
201 | |||
202 | this.Normalise(); | ||
177 | } | 203 | } |
178 | 204 | ||
179 | Channel myself = this; | 205 | Channel myself = this; |
180 | myself += sediment; | 206 | myself += sediment; |
181 | myself.Normalise(); | 207 | myself.Normalise(); |
208 | |||
209 | if (debugImages) | ||
210 | this.SaveImage("testimg/output.png"); | ||
182 | } | 211 | } |
183 | } | 212 | } |
184 | } \ No newline at end of file | 213 | } \ No newline at end of file |
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs index a035098..8a111ed 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs | |||
@@ -211,11 +211,11 @@ namespace libTerrain | |||
211 | int i; | 211 | int i; |
212 | int j; | 212 | int j; |
213 | 213 | ||
214 | for (i = 0; i <= N; i++) | 214 | for (i = 1; i <= N; i++) |
215 | { | 215 | { |
216 | for (j = 0; j <= N; j++) | 216 | for (j = 1; j <= N; j++) |
217 | { | 217 | { |
218 | doubles[i, j] = dens[nsIX(i, j, N)]; | 218 | doubles[i - 1, j - 1] = dens[nsIX(i, j, N)]; |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
@@ -229,7 +229,7 @@ namespace libTerrain | |||
229 | { | 229 | { |
230 | for (j = 1; j <= N; j++) | 230 | for (j = 1; j <= N; j++) |
231 | { | 231 | { |
232 | dens[nsIX(i, j, N)] = doubles[i, j]; | 232 | dens[nsIX(i, j, N)] = doubles[i - 1, j - 1]; |
233 | } | 233 | } |
234 | } | 234 | } |
235 | } | 235 | } |
@@ -272,5 +272,36 @@ namespace libTerrain | |||
272 | { | 272 | { |
273 | nsSimulate(this.h, rounds, dt, diff, visc); | 273 | nsSimulate(this.h, rounds, dt, diff, visc); |
274 | } | 274 | } |
275 | |||
276 | public void navierStokes(int rounds, double dt, double diff, double visc, ref double[,] uret, ref double[,] vret) | ||
277 | { | ||
278 | int N = this.h; | ||
279 | |||
280 | int size = (N * 2) * (N * 2); | ||
281 | |||
282 | double[] u = new double[size]; // Force, X axis | ||
283 | double[] v = new double[size]; // Force, Y axis | ||
284 | double[] u_prev = new double[size]; | ||
285 | double[] v_prev = new double[size]; | ||
286 | double[] dens = new double[size]; | ||
287 | double[] dens_prev = new double[size]; | ||
288 | |||
289 | nsDoublesToBuffer(this.map, N, ref dens); | ||
290 | nsDoublesToBuffer(this.map, N, ref dens_prev); | ||
291 | |||
292 | for (int i = 0; i < rounds; i++) | ||
293 | { | ||
294 | u_prev = u; | ||
295 | v_prev = v; | ||
296 | dens_prev = dens; | ||
297 | |||
298 | nsVelStep(N, ref u, ref v, ref u_prev, ref v_prev, visc, dt); | ||
299 | nsDensStep(N, ref dens, ref dens_prev, ref u, ref v, diff, dt); | ||
300 | } | ||
301 | |||
302 | nsBufferToDoubles(ref u, N, ref uret); | ||
303 | nsBufferToDoubles(ref v, N, ref vret); | ||
304 | nsBufferToDoubles(ref dens, N, ref this.map); | ||
305 | } | ||
275 | } | 306 | } |
276 | } \ No newline at end of file | 307 | } \ No newline at end of file |