diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs | 207 |
1 files changed, 0 insertions, 207 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs deleted file mode 100644 index f46ba8f..0000000 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs +++ /dev/null | |||
@@ -1,207 +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 | |||
28 | using OpenSim.Region.Environment.Interfaces; | ||
29 | |||
30 | namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | ||
31 | { | ||
32 | /// <summary> | ||
33 | /// Thermal Weathering Paint Brush | ||
34 | /// </summary> | ||
35 | public class WeatherSphere : ITerrainPaintableEffect | ||
36 | { | ||
37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. | ||
38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | ||
39 | |||
40 | #region Supporting Functions | ||
41 | |||
42 | private int[] Neighbours(NeighbourSystem type, int index) | ||
43 | { | ||
44 | int[] coord = new int[2]; | ||
45 | |||
46 | index++; | ||
47 | |||
48 | switch (type) | ||
49 | { | ||
50 | case NeighbourSystem.Moore: | ||
51 | switch (index) | ||
52 | { | ||
53 | case 1: | ||
54 | coord[0] = -1; | ||
55 | coord[1] = -1; | ||
56 | break; | ||
57 | |||
58 | case 2: | ||
59 | coord[0] = -0; | ||
60 | coord[1] = -1; | ||
61 | break; | ||
62 | |||
63 | case 3: | ||
64 | coord[0] = +1; | ||
65 | coord[1] = -1; | ||
66 | break; | ||
67 | |||
68 | case 4: | ||
69 | coord[0] = -1; | ||
70 | coord[1] = -0; | ||
71 | break; | ||
72 | |||
73 | case 5: | ||
74 | coord[0] = -0; | ||
75 | coord[1] = -0; | ||
76 | break; | ||
77 | |||
78 | case 6: | ||
79 | coord[0] = +1; | ||
80 | coord[1] = -0; | ||
81 | break; | ||
82 | |||
83 | case 7: | ||
84 | coord[0] = -1; | ||
85 | coord[1] = +1; | ||
86 | break; | ||
87 | |||
88 | case 8: | ||
89 | coord[0] = -0; | ||
90 | coord[1] = +1; | ||
91 | break; | ||
92 | |||
93 | case 9: | ||
94 | coord[0] = +1; | ||
95 | coord[1] = +1; | ||
96 | break; | ||
97 | |||
98 | default: | ||
99 | break; | ||
100 | } | ||
101 | break; | ||
102 | |||
103 | case NeighbourSystem.VonNeumann: | ||
104 | switch (index) | ||
105 | { | ||
106 | case 1: | ||
107 | coord[0] = 0; | ||
108 | coord[1] = -1; | ||
109 | break; | ||
110 | |||
111 | case 2: | ||
112 | coord[0] = -1; | ||
113 | coord[1] = 0; | ||
114 | break; | ||
115 | |||
116 | case 3: | ||
117 | coord[0] = +1; | ||
118 | coord[1] = 0; | ||
119 | break; | ||
120 | |||
121 | case 4: | ||
122 | coord[0] = 0; | ||
123 | coord[1] = +1; | ||
124 | break; | ||
125 | |||
126 | case 5: | ||
127 | coord[0] = -0; | ||
128 | coord[1] = -0; | ||
129 | break; | ||
130 | |||
131 | default: | ||
132 | break; | ||
133 | } | ||
134 | break; | ||
135 | } | ||
136 | |||
137 | return coord; | ||
138 | } | ||
139 | |||
140 | private enum NeighbourSystem | ||
141 | { | ||
142 | Moore, | ||
143 | VonNeumann | ||
144 | } ; | ||
145 | |||
146 | #endregion | ||
147 | |||
148 | #region ITerrainPaintableEffect Members | ||
149 | |||
150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | ||
151 | { | ||
152 | strength = TerrainUtil.MetersToSphericalStrength(strength); | ||
153 | |||
154 | int x, y; | ||
155 | |||
156 | for (x = 0; x < map.Width; x++) | ||
157 | { | ||
158 | for (y = 0; y < map.Height; y++) | ||
159 | { | ||
160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | ||
161 | |||
162 | if (z > 0) // add in non-zero amount | ||
163 | { | ||
164 | int NEIGHBOUR_ME = 4; | ||
165 | |||
166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | ||
167 | |||
168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | ||
169 | { | ||
170 | if (j != NEIGHBOUR_ME) | ||
171 | { | ||
172 | int[] coords = Neighbours(type, j); | ||
173 | |||
174 | coords[0] += x; | ||
175 | coords[1] += y; | ||
176 | |||
177 | if (coords[0] > map.Width - 1) | ||
178 | continue; | ||
179 | if (coords[1] > map.Height - 1) | ||
180 | continue; | ||
181 | if (coords[0] < 0) | ||
182 | continue; | ||
183 | if (coords[1] < 0) | ||
184 | continue; | ||
185 | |||
186 | double heightF = map[x, y]; | ||
187 | double target = map[coords[0], coords[1]]; | ||
188 | |||
189 | if (target > heightF + talus) | ||
190 | { | ||
191 | double calc = duration * ((target - heightF) - talus) * z; | ||
192 | heightF += calc; | ||
193 | target -= calc; | ||
194 | } | ||
195 | |||
196 | map[x, y] = heightF; | ||
197 | map[coords[0], coords[1]] = target; | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | } | ||
202 | } | ||
203 | } | ||
204 | |||
205 | #endregion | ||
206 | } | ||
207 | } \ No newline at end of file | ||