diff options
Update svn properties. Minor formatting cleanup.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs | 412 |
1 files changed, 206 insertions, 206 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs index 2d81054..b48beb8 100644 --- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/WeatherSphere.cs | |||
@@ -1,207 +1,207 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (c) Contributors, http://opensimulator.org/ | 2 | * Copyright (c) Contributors, http://opensimulator.org/ |
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | 3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. |
4 | * | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions are met: | 6 | * modification, are permitted provided that the following conditions are met: |
7 | * * Redistributions of source code must retain the above copyright | 7 | * * Redistributions of source code must retain the above copyright |
8 | * notice, this list of conditions and the following disclaimer. | 8 | * notice, this list of conditions and the following disclaimer. |
9 | * * Redistributions in binary form must reproduce the above copyright | 9 | * * Redistributions in binary form must reproduce the above copyright |
10 | * notice, this list of conditions and the following disclaimer in the | 10 | * notice, this list of conditions and the following disclaimer in the |
11 | * documentation and/or other materials provided with the distribution. | 11 | * documentation and/or other materials provided with the distribution. |
12 | * * Neither the name of the OpenSim Project nor the | 12 | * * Neither the name of the OpenSim Project nor the |
13 | * names of its contributors may be used to endorse or promote products | 13 | * names of its contributors may be used to endorse or promote products |
14 | * derived from this software without specific prior written permission. | 14 | * derived from this software without specific prior written permission. |
15 | * | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | 16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY |
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | 19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY |
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | 20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | 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 | 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 | 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 | 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. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using OpenSim.Region.Environment.Interfaces; | 28 | using OpenSim.Region.Environment.Interfaces; |
29 | 29 | ||
30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes |
31 | { | 31 | { |
32 | /// <summary> | 32 | /// <summary> |
33 | /// Thermal Weathering Paint Brush | 33 | /// Thermal Weathering Paint Brush |
34 | /// </summary> | 34 | /// </summary> |
35 | public class WeatherSphere : ITerrainPaintableEffect | 35 | public class WeatherSphere : ITerrainPaintableEffect |
36 | { | 36 | { |
37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. | 37 | private double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. |
38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 38 | private NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
39 | 39 | ||
40 | #region Supporting Functions | 40 | #region Supporting Functions |
41 | 41 | ||
42 | private int[] Neighbours(NeighbourSystem type, int index) | 42 | private int[] Neighbours(NeighbourSystem type, int index) |
43 | { | 43 | { |
44 | int[] coord = new int[2]; | 44 | int[] coord = new int[2]; |
45 | 45 | ||
46 | index++; | 46 | index++; |
47 | 47 | ||
48 | switch (type) | 48 | switch (type) |
49 | { | 49 | { |
50 | case NeighbourSystem.Moore: | 50 | case NeighbourSystem.Moore: |
51 | switch (index) | 51 | switch (index) |
52 | { | 52 | { |
53 | case 1: | 53 | case 1: |
54 | coord[0] = -1; | 54 | coord[0] = -1; |
55 | coord[1] = -1; | 55 | coord[1] = -1; |
56 | break; | 56 | break; |
57 | 57 | ||
58 | case 2: | 58 | case 2: |
59 | coord[0] = -0; | 59 | coord[0] = -0; |
60 | coord[1] = -1; | 60 | coord[1] = -1; |
61 | break; | 61 | break; |
62 | 62 | ||
63 | case 3: | 63 | case 3: |
64 | coord[0] = +1; | 64 | coord[0] = +1; |
65 | coord[1] = -1; | 65 | coord[1] = -1; |
66 | break; | 66 | break; |
67 | 67 | ||
68 | case 4: | 68 | case 4: |
69 | coord[0] = -1; | 69 | coord[0] = -1; |
70 | coord[1] = -0; | 70 | coord[1] = -0; |
71 | break; | 71 | break; |
72 | 72 | ||
73 | case 5: | 73 | case 5: |
74 | coord[0] = -0; | 74 | coord[0] = -0; |
75 | coord[1] = -0; | 75 | coord[1] = -0; |
76 | break; | 76 | break; |
77 | 77 | ||
78 | case 6: | 78 | case 6: |
79 | coord[0] = +1; | 79 | coord[0] = +1; |
80 | coord[1] = -0; | 80 | coord[1] = -0; |
81 | break; | 81 | break; |
82 | 82 | ||
83 | case 7: | 83 | case 7: |
84 | coord[0] = -1; | 84 | coord[0] = -1; |
85 | coord[1] = +1; | 85 | coord[1] = +1; |
86 | break; | 86 | break; |
87 | 87 | ||
88 | case 8: | 88 | case 8: |
89 | coord[0] = -0; | 89 | coord[0] = -0; |
90 | coord[1] = +1; | 90 | coord[1] = +1; |
91 | break; | 91 | break; |
92 | 92 | ||
93 | case 9: | 93 | case 9: |
94 | coord[0] = +1; | 94 | coord[0] = +1; |
95 | coord[1] = +1; | 95 | coord[1] = +1; |
96 | break; | 96 | break; |
97 | 97 | ||
98 | default: | 98 | default: |
99 | break; | 99 | break; |
100 | } | 100 | } |
101 | break; | 101 | break; |
102 | 102 | ||
103 | case NeighbourSystem.VonNeumann: | 103 | case NeighbourSystem.VonNeumann: |
104 | switch (index) | 104 | switch (index) |
105 | { | 105 | { |
106 | case 1: | 106 | case 1: |
107 | coord[0] = 0; | 107 | coord[0] = 0; |
108 | coord[1] = -1; | 108 | coord[1] = -1; |
109 | break; | 109 | break; |
110 | 110 | ||
111 | case 2: | 111 | case 2: |
112 | coord[0] = -1; | 112 | coord[0] = -1; |
113 | coord[1] = 0; | 113 | coord[1] = 0; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case 3: | 116 | case 3: |
117 | coord[0] = +1; | 117 | coord[0] = +1; |
118 | coord[1] = 0; | 118 | coord[1] = 0; |
119 | break; | 119 | break; |
120 | 120 | ||
121 | case 4: | 121 | case 4: |
122 | coord[0] = 0; | 122 | coord[0] = 0; |
123 | coord[1] = +1; | 123 | coord[1] = +1; |
124 | break; | 124 | break; |
125 | 125 | ||
126 | case 5: | 126 | case 5: |
127 | coord[0] = -0; | 127 | coord[0] = -0; |
128 | coord[1] = -0; | 128 | coord[1] = -0; |
129 | break; | 129 | break; |
130 | 130 | ||
131 | default: | 131 | default: |
132 | break; | 132 | break; |
133 | } | 133 | } |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | 136 | ||
137 | return coord; | 137 | return coord; |
138 | } | 138 | } |
139 | 139 | ||
140 | private enum NeighbourSystem | 140 | private enum NeighbourSystem |
141 | { | 141 | { |
142 | Moore, | 142 | Moore, |
143 | VonNeumann | 143 | VonNeumann |
144 | } ; | 144 | } ; |
145 | 145 | ||
146 | #endregion | 146 | #endregion |
147 | 147 | ||
148 | #region ITerrainPaintableEffect Members | 148 | #region ITerrainPaintableEffect Members |
149 | 149 | ||
150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 150 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
151 | { | 151 | { |
152 | strength = TerrainUtil.MetersToSphericalStrength(strength); | 152 | strength = TerrainUtil.MetersToSphericalStrength(strength); |
153 | 153 | ||
154 | int x, y; | 154 | int x, y; |
155 | 155 | ||
156 | for (x = 0; x < map.Width; x++) | 156 | for (x = 0; x < map.Width; x++) |
157 | { | 157 | { |
158 | for (y = 0; y < map.Height; y++) | 158 | for (y = 0; y < map.Height; y++) |
159 | { | 159 | { |
160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); | 160 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
161 | 161 | ||
162 | if (z > 0) // add in non-zero amount | 162 | if (z > 0) // add in non-zero amount |
163 | { | 163 | { |
164 | int NEIGHBOUR_ME = 4; | 164 | int NEIGHBOUR_ME = 4; |
165 | 165 | ||
166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 166 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
167 | 167 | ||
168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 168 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
169 | { | 169 | { |
170 | if (j != NEIGHBOUR_ME) | 170 | if (j != NEIGHBOUR_ME) |
171 | { | 171 | { |
172 | int[] coords = Neighbours(type, j); | 172 | int[] coords = Neighbours(type, j); |
173 | 173 | ||
174 | coords[0] += x; | 174 | coords[0] += x; |
175 | coords[1] += y; | 175 | coords[1] += y; |
176 | 176 | ||
177 | if (coords[0] > map.Width - 1) | 177 | if (coords[0] > map.Width - 1) |
178 | continue; | 178 | continue; |
179 | if (coords[1] > map.Height - 1) | 179 | if (coords[1] > map.Height - 1) |
180 | continue; | 180 | continue; |
181 | if (coords[0] < 0) | 181 | if (coords[0] < 0) |
182 | continue; | 182 | continue; |
183 | if (coords[1] < 0) | 183 | if (coords[1] < 0) |
184 | continue; | 184 | continue; |
185 | 185 | ||
186 | double heightF = map[x, y]; | 186 | double heightF = map[x, y]; |
187 | double target = map[coords[0], coords[1]]; | 187 | double target = map[coords[0], coords[1]]; |
188 | 188 | ||
189 | if (target > heightF + talus) | 189 | if (target > heightF + talus) |
190 | { | 190 | { |
191 | double calc = duration * ((target - heightF) - talus) * z; | 191 | double calc = duration * ((target - heightF) - talus) * z; |
192 | heightF += calc; | 192 | heightF += calc; |
193 | target -= calc; | 193 | target -= calc; |
194 | } | 194 | } |
195 | 195 | ||
196 | map[x, y] = heightF; | 196 | map[x, y] = heightF; |
197 | map[coords[0], coords[1]] = target; | 197 | map[coords[0], coords[1]] = target; |
198 | } | 198 | } |
199 | } | 199 | } |
200 | } | 200 | } |
201 | } | 201 | } |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | #endregion | 205 | #endregion |
206 | } | 206 | } |
207 | } \ No newline at end of file | 207 | } \ No newline at end of file |