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