aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
diff options
context:
space:
mode:
authorAdam Frisby2008-04-23 10:55:04 +0000
committerAdam Frisby2008-04-23 10:55:04 +0000
commit7c897043bab19bf748ac3078a05a74969c409fa7 (patch)
treef3f89972edbdebd9678025e754734f6aeb8b2952 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
parent* Get rid of missing texture notification drop messages for now - obscuring t... (diff)
downloadopensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.zip
opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.gz
opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.bz2
opensim-SC_OLD-7c897043bab19bf748ac3078a05a74969c409fa7.tar.xz
* Removing old libTerrainBSD and associated Plugin & Project.
* Updated prebuild.xml accordingly.
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs211
1 files changed, 0 insertions, 211 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
deleted file mode 100644
index 6a846cd..0000000
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/AerobicErosion.cs
+++ /dev/null
@@ -1,211 +0,0 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29
30namespace libTerrain
31{
32 partial class Channel
33 {
34 // Ideas for Aerobic erosion
35 //
36 // Unlike thermal (gravity) and hydraulic (water suspension)
37 // aerobic erosion should displace mass by moving sediment
38 // in "hops". The length of the hop being dictated by the
39 // presence of sharp cliffs and wind speed.
40
41 // The ability to pickup sediment is defined by the total
42 // surface area, such that:
43 // 0 0 0
44 // 0 1 0
45 // 0 0 0
46 // Would be the best possible value for sediment to be
47 // picked up (total difference = 8) and flatter land
48 // will erode less quickly.
49
50 // Suspended particles assist the erosion process by hitting
51 // the surface and chiselling additional particles off faster
52 // than alone.
53
54 // Particles are deposited when one of two conditions is met
55 // First:
56 // When particles hit a wall - such that the
57 // wind direction points at a difference >= the
58 // deposition mininum talus.
59 // Second:
60 // When wind speed is lowered to below the minimum
61 // required for transit. An idea for this is to
62 // use the navier-stokes algorithms for simulating
63 // pressure across the terrain.
64
65 /// <summary>
66 /// An experimental erosion algorithm developed by Adam. Moves sediment by factoring the surface area of each height point.
67 /// </summary>
68 /// <param name="windspeed">0..1 The speed of the wind</param>
69 /// <param name="pickup_talus_minimum">The minimum angle at which rock is eroded 0..1 (recommended: <= 0.30)</param>
70 /// <param name="drop_talus_minimum">The minimum angle at which rock is dropped 0..1 (recommended: >= 0.00)</param>
71 /// <param name="carry">The percentage of rock which can be picked up to pickup 0..1</param>
72 /// <param name="rounds">The number of erosion rounds (recommended: 25+)</param>
73 /// <param name="lowest">Drop sediment at the lowest point?</param>
74 public void AerobicErosion(double windspeed, double pickupTalusMinimum, double dropTalusMinimum, double carry,
75 int rounds, bool lowest, bool usingFluidDynamics)
76 {
77 bool debugImages = false;
78
79 Channel wind = new Channel(w, h);
80 Channel sediment = new Channel(w, h);
81 int x, y, i, j;
82
83 Normalise();
84
85 wind = Copy();
86 wind.Noise();
87
88 if (debugImages)
89 wind.SaveImage("testimg/wind_start.png");
90
91 if (usingFluidDynamics)
92 {
93 wind.navierStokes(20, 0.1, 0.0, 0.0);
94 }
95 else
96 {
97 wind.Pertubation(30);
98 }
99
100 if (debugImages)
101 wind.SaveImage("testimg/wind_begin.png");
102
103 for (i = 0; i < rounds; i++)
104 {
105 // Convert some rocks to sand
106 for (x = 1; x < w - 1; x++)
107 {
108 for (y = 1; y < h - 1; y++)
109 {
110 double me = Get(x, y);
111 double surfacearea = 0.3; // Everything will erode even if it's flat. Just slower.
112
113 for (j = 0; j < 9; j++)
114 {
115 int[] coords = Neighbours(NeighbourSystem.Moore, j);
116 double target = Get(x + coords[0], y + coords[1]);
117
118 surfacearea += Math.Abs(target - me);
119 }
120
121 double amount = surfacearea*wind.map[x, y]*carry;
122
123 if (amount < 0)
124 amount = 0;
125
126 if (surfacearea > pickupTalusMinimum)
127 {
128 Set(x, y, map[x, y] - amount);
129 sediment.map[x, y] += amount;
130 }
131 }
132 }
133
134 if (usingFluidDynamics)
135 {
136 sediment.navierStokes(7, 0.1, 0.0, 0.1);
137
138 Channel noiseChan = new Channel(w, h);
139 noiseChan.Noise();
140 wind.Blend(noiseChan, 0.01);
141
142 wind.navierStokes(10, 0.1, 0.01, 0.01);
143
144 sediment.Distort(wind, windspeed);
145 }
146 else
147 {
148 wind.Pertubation(15); // Can do better later
149 wind.seed++;
150 sediment.Pertubation(10); // Sediment is blown around a bit
151 sediment.seed++;
152 }
153
154 if (debugImages)
155 wind.SaveImage("testimg/wind_" + i.ToString() + ".png");
156
157 // Convert some sand to rock
158 for (x = 1; x < w - 1; x++)
159 {
160 for (y = 1; y < h - 1; y++)
161 {
162 double me = Get(x, y);
163 double surfacearea = 0.01; // Flat land does not get deposition
164 double min = double.MaxValue;
165 int[] minside = new int[2];
166
167 for (j = 0; j < 9; j++)
168 {
169 int[] coords = Neighbours(NeighbourSystem.Moore, j);
170 double target = Get(x + coords[0], y + coords[1]);
171
172 surfacearea += Math.Abs(target - me);
173
174 if (target < min && lowest)
175 {
176 minside = (int[]) coords.Clone();
177 min = target;
178 }
179 }
180
181 double amount = surfacearea*(1.0 - wind.map[x, y])*carry;
182
183 if (amount < 0)
184 amount = 0;
185
186 if (surfacearea > dropTalusMinimum)
187 {
188 Set(x + minside[0], y + minside[1], map[x + minside[0], y + minside[1]] + amount);
189 sediment.map[x, y] -= amount;
190 }
191 }
192 }
193
194 if (debugImages)
195 sediment.SaveImage("testimg/sediment_" + i.ToString() + ".png");
196
197 wind.Normalise();
198 wind *= windspeed;
199
200 Normalise();
201 }
202
203 Channel myself = this;
204 myself += sediment;
205 myself.Normalise();
206
207 if (debugImages)
208 SaveImage("testimg/output.png");
209 }
210 }
211}