diff options
Diffstat (limited to 'OpenSim/Region/Environment/Modules')
3 files changed, 378 insertions, 378 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs index 856405a..027c6a1 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs | |||
@@ -1,60 +1,60 @@ | |||
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.Terrain.FloodBrushes | 30 | namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes |
31 | { | 31 | { |
32 | public class RevertArea : ITerrainFloodEffect | 32 | public class RevertArea : ITerrainFloodEffect |
33 | { | 33 | { |
34 | ITerrainChannel m_revertmap; | 34 | ITerrainChannel m_revertmap; |
35 | 35 | ||
36 | public RevertArea(ITerrainChannel revertmap) | 36 | public RevertArea(ITerrainChannel revertmap) |
37 | { | 37 | { |
38 | m_revertmap = revertmap; | 38 | m_revertmap = revertmap; |
39 | } | 39 | } |
40 | 40 | ||
41 | #region ITerrainFloodEffect Members | 41 | #region ITerrainFloodEffect Members |
42 | 42 | ||
43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) | 43 | public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) |
44 | { | 44 | { |
45 | int x, y; | 45 | int x, y; |
46 | for (x = 0; x < map.Width; x++) | 46 | for (x = 0; x < map.Width; x++) |
47 | { | 47 | { |
48 | for (y = 0; y < map.Height; y++) | 48 | for (y = 0; y < map.Height; y++) |
49 | { | 49 | { |
50 | if (fillArea[x, y] == true) | 50 | if (fillArea[x, y] == true) |
51 | { | 51 | { |
52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); | 52 | map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); |
53 | } | 53 | } |
54 | } | 54 | } |
55 | } | 55 | } |
56 | } | 56 | } |
57 | 57 | ||
58 | #endregion | 58 | #endregion |
59 | } | 59 | } |
60 | } | 60 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs index e7ce68e..9d9c462 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/RevertSphere.cs | |||
@@ -1,75 +1,75 @@ | |||
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 System; | 28 | using System; |
29 | using OpenSim.Region.Environment.Interfaces; | 29 | using OpenSim.Region.Environment.Interfaces; |
30 | 30 | ||
31 | namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | 31 | namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes |
32 | { | 32 | { |
33 | public class RevertSphere : ITerrainPaintableEffect | 33 | public class RevertSphere : ITerrainPaintableEffect |
34 | { | 34 | { |
35 | ITerrainChannel m_revertmap; | 35 | ITerrainChannel m_revertmap; |
36 | 36 | ||
37 | public RevertSphere(ITerrainChannel revertmap) | 37 | public RevertSphere(ITerrainChannel revertmap) |
38 | { | 38 | { |
39 | m_revertmap = revertmap; | 39 | m_revertmap = revertmap; |
40 | } | 40 | } |
41 | 41 | ||
42 | #region ITerrainPaintableEffect Members | 42 | #region ITerrainPaintableEffect Members |
43 | 43 | ||
44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 44 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
45 | { | 45 | { |
46 | int x, y; | 46 | int x, y; |
47 | for (x = 0; x < map.Width; x++) | 47 | for (x = 0; x < map.Width; x++) |
48 | { | 48 | { |
49 | // Skip everything unlikely to be affected | 49 | // Skip everything unlikely to be affected |
50 | if (Math.Abs(x - rx) > strength * 1.1) | 50 | if (Math.Abs(x - rx) > strength * 1.1) |
51 | continue; | 51 | continue; |
52 | 52 | ||
53 | for (y = 0; y < map.Height; y++) | 53 | for (y = 0; y < map.Height; y++) |
54 | { | 54 | { |
55 | // Skip everything unlikely to be affected | 55 | // Skip everything unlikely to be affected |
56 | if (Math.Abs(y - ry) > strength * 1.1) | 56 | if (Math.Abs(y - ry) > strength * 1.1) |
57 | continue; | 57 | continue; |
58 | 58 | ||
59 | // Calculate a sphere and add it to the heighmap | 59 | // Calculate a sphere and add it to the heighmap |
60 | double z = strength; | 60 | double z = strength; |
61 | z *= z; | 61 | z *= z; |
62 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); | 62 | z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry)); |
63 | 63 | ||
64 | if (z > 0.0) | 64 | if (z > 0.0) |
65 | { | 65 | { |
66 | z *= duration; | 66 | z *= duration; |
67 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); | 67 | map[x, y] += (map[x, y] * (1.0 - z)) + (m_revertmap[x, y] * z); |
68 | } | 68 | } |
69 | } | 69 | } |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | #endregion | 73 | #endregion |
74 | } | 74 | } |
75 | } | 75 | } |
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs index bede47e..cac3d35 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs | |||
@@ -1,243 +1,243 @@ | |||
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.Terrain.PaintBrushes | 30 | namespace OpenSim.Region.Environment.Modules.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 | NeighbourSystem type = NeighbourSystem.Moore; // Parameter | 37 | NeighbourSystem type = NeighbourSystem.Moore; // Parameter |
38 | double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. | 38 | double talus = 0.2; // Number of meters max difference before stop eroding. Tweakage required. |
39 | 39 | ||
40 | #region Supporting Functions | 40 | #region Supporting Functions |
41 | private enum NeighbourSystem | 41 | private enum NeighbourSystem |
42 | { | 42 | { |
43 | Moore, | 43 | Moore, |
44 | VonNeumann | 44 | VonNeumann |
45 | } ; | 45 | } ; |
46 | 46 | ||
47 | private int[] Neighbours(NeighbourSystem type, int index) | 47 | private int[] Neighbours(NeighbourSystem type, int index) |
48 | { | 48 | { |
49 | int[] coord = new int[2]; | 49 | int[] coord = new int[2]; |
50 | 50 | ||
51 | index++; | 51 | index++; |
52 | 52 | ||
53 | switch (type) | 53 | switch (type) |
54 | { | 54 | { |
55 | case NeighbourSystem.Moore: | 55 | case NeighbourSystem.Moore: |
56 | switch (index) | 56 | switch (index) |
57 | { | 57 | { |
58 | case 1: | 58 | case 1: |
59 | coord[0] = -1; | 59 | coord[0] = -1; |
60 | coord[1] = -1; | 60 | coord[1] = -1; |
61 | break; | 61 | break; |
62 | 62 | ||
63 | case 2: | 63 | case 2: |
64 | coord[0] = -0; | 64 | coord[0] = -0; |
65 | coord[1] = -1; | 65 | coord[1] = -1; |
66 | break; | 66 | break; |
67 | 67 | ||
68 | case 3: | 68 | case 3: |
69 | coord[0] = +1; | 69 | coord[0] = +1; |
70 | coord[1] = -1; | 70 | coord[1] = -1; |
71 | break; | 71 | break; |
72 | 72 | ||
73 | case 4: | 73 | case 4: |
74 | coord[0] = -1; | 74 | coord[0] = -1; |
75 | coord[1] = -0; | 75 | coord[1] = -0; |
76 | break; | 76 | break; |
77 | 77 | ||
78 | case 5: | 78 | case 5: |
79 | coord[0] = -0; | 79 | coord[0] = -0; |
80 | coord[1] = -0; | 80 | coord[1] = -0; |
81 | break; | 81 | break; |
82 | 82 | ||
83 | case 6: | 83 | case 6: |
84 | coord[0] = +1; | 84 | coord[0] = +1; |
85 | coord[1] = -0; | 85 | coord[1] = -0; |
86 | break; | 86 | break; |
87 | 87 | ||
88 | case 7: | 88 | case 7: |
89 | coord[0] = -1; | 89 | coord[0] = -1; |
90 | coord[1] = +1; | 90 | coord[1] = +1; |
91 | break; | 91 | break; |
92 | 92 | ||
93 | case 8: | 93 | case 8: |
94 | coord[0] = -0; | 94 | coord[0] = -0; |
95 | coord[1] = +1; | 95 | coord[1] = +1; |
96 | break; | 96 | break; |
97 | 97 | ||
98 | case 9: | 98 | case 9: |
99 | coord[0] = +1; | 99 | coord[0] = +1; |
100 | coord[1] = +1; | 100 | coord[1] = +1; |
101 | break; | 101 | break; |
102 | 102 | ||
103 | default: | 103 | default: |
104 | break; | 104 | break; |
105 | } | 105 | } |
106 | break; | 106 | break; |
107 | 107 | ||
108 | case NeighbourSystem.VonNeumann: | 108 | case NeighbourSystem.VonNeumann: |
109 | switch (index) | 109 | switch (index) |
110 | { | 110 | { |
111 | case 1: | 111 | case 1: |
112 | coord[0] = 0; | 112 | coord[0] = 0; |
113 | coord[1] = -1; | 113 | coord[1] = -1; |
114 | break; | 114 | break; |
115 | 115 | ||
116 | case 2: | 116 | case 2: |
117 | coord[0] = -1; | 117 | coord[0] = -1; |
118 | coord[1] = 0; | 118 | coord[1] = 0; |
119 | break; | 119 | break; |
120 | 120 | ||
121 | case 3: | 121 | case 3: |
122 | coord[0] = +1; | 122 | coord[0] = +1; |
123 | coord[1] = 0; | 123 | coord[1] = 0; |
124 | break; | 124 | break; |
125 | 125 | ||
126 | case 4: | 126 | case 4: |
127 | coord[0] = 0; | 127 | coord[0] = 0; |
128 | coord[1] = +1; | 128 | coord[1] = +1; |
129 | break; | 129 | break; |
130 | 130 | ||
131 | case 5: | 131 | case 5: |
132 | coord[0] = -0; | 132 | coord[0] = -0; |
133 | coord[1] = -0; | 133 | coord[1] = -0; |
134 | break; | 134 | break; |
135 | 135 | ||
136 | default: | 136 | default: |
137 | break; | 137 | break; |
138 | } | 138 | } |
139 | break; | 139 | break; |
140 | } | 140 | } |
141 | 141 | ||
142 | return coord; | 142 | return coord; |
143 | } | 143 | } |
144 | 144 | ||
145 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | 145 | private double SphericalFactor(double x, double y, double rx, double ry, double size) |
146 | { | 146 | { |
147 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | 147 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); |
148 | return z; | 148 | return z; |
149 | } | 149 | } |
150 | 150 | ||
151 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | 151 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) |
152 | { | 152 | { |
153 | int w = map.Width; | 153 | int w = map.Width; |
154 | int h = map.Height; | 154 | int h = map.Height; |
155 | 155 | ||
156 | if (x > w - 2.0) | 156 | if (x > w - 2.0) |
157 | x = w - 2.0; | 157 | x = w - 2.0; |
158 | if (y > h - 2.0) | 158 | if (y > h - 2.0) |
159 | y = h - 2.0; | 159 | y = h - 2.0; |
160 | if (x < 0.0) | 160 | if (x < 0.0) |
161 | x = 0.0; | 161 | x = 0.0; |
162 | if (y < 0.0) | 162 | if (y < 0.0) |
163 | y = 0.0; | 163 | y = 0.0; |
164 | 164 | ||
165 | int stepSize = 1; | 165 | int stepSize = 1; |
166 | double h00 = map[(int)x, (int)y]; | 166 | double h00 = map[(int)x, (int)y]; |
167 | double h10 = map[(int)x + stepSize, (int)y]; | 167 | double h10 = map[(int)x + stepSize, (int)y]; |
168 | double h01 = map[(int)x, (int)y + stepSize]; | 168 | double h01 = map[(int)x, (int)y + stepSize]; |
169 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | 169 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; |
170 | double h1 = h00; | 170 | double h1 = h00; |
171 | double h2 = h10; | 171 | double h2 = h10; |
172 | double h3 = h01; | 172 | double h3 = h01; |
173 | double h4 = h11; | 173 | double h4 = h11; |
174 | double a00 = h1; | 174 | double a00 = h1; |
175 | double a10 = h2 - h1; | 175 | double a10 = h2 - h1; |
176 | double a01 = h3 - h1; | 176 | double a01 = h3 - h1; |
177 | double a11 = h1 - h2 - h3 + h4; | 177 | double a11 = h1 - h2 - h3 + h4; |
178 | double partialx = x - (int)x; | 178 | double partialx = x - (int)x; |
179 | double partialz = y - (int)y; | 179 | double partialz = y - (int)y; |
180 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | 180 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); |
181 | return hi; | 181 | return hi; |
182 | } | 182 | } |
183 | 183 | ||
184 | #endregion | 184 | #endregion |
185 | 185 | ||
186 | #region ITerrainPaintableEffect Members | 186 | #region ITerrainPaintableEffect Members |
187 | 187 | ||
188 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 188 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
189 | { | 189 | { |
190 | int x, y; | 190 | int x, y; |
191 | 191 | ||
192 | for (x = 0; x < map.Width; x++) | 192 | for (x = 0; x < map.Width; x++) |
193 | { | 193 | { |
194 | for (y = 0; y < map.Height; y++) | 194 | for (y = 0; y < map.Height; y++) |
195 | { | 195 | { |
196 | double z = SphericalFactor(x, y, rx, ry, strength); | 196 | double z = SphericalFactor(x, y, rx, ry, strength); |
197 | 197 | ||
198 | if (z > 0) // add in non-zero amount | 198 | if (z > 0) // add in non-zero amount |
199 | { | 199 | { |
200 | int NEIGHBOUR_ME = 4; | 200 | int NEIGHBOUR_ME = 4; |
201 | 201 | ||
202 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; | 202 | int NEIGHBOUR_MAX = type == NeighbourSystem.Moore ? 9 : 5; |
203 | 203 | ||
204 | for (int j = 0; j < NEIGHBOUR_MAX; j++) | 204 | for (int j = 0; j < NEIGHBOUR_MAX; j++) |
205 | { | 205 | { |
206 | if (j != NEIGHBOUR_ME) | 206 | if (j != NEIGHBOUR_ME) |
207 | { | 207 | { |
208 | int[] coords = Neighbours(type, j); | 208 | int[] coords = Neighbours(type, j); |
209 | 209 | ||
210 | coords[0] += x; | 210 | coords[0] += x; |
211 | coords[1] += y; | 211 | coords[1] += y; |
212 | 212 | ||
213 | if (coords[0] > map.Width - 1) | 213 | if (coords[0] > map.Width - 1) |
214 | continue; | 214 | continue; |
215 | if (coords[1] > map.Height - 1) | 215 | if (coords[1] > map.Height - 1) |
216 | continue; | 216 | continue; |
217 | if (coords[0] < 0) | 217 | if (coords[0] < 0) |
218 | continue; | 218 | continue; |
219 | if (coords[1] < 0) | 219 | if (coords[1] < 0) |
220 | continue; | 220 | continue; |
221 | 221 | ||
222 | double heightF = map[x, y]; | 222 | double heightF = map[x, y]; |
223 | double target = map[coords[0], coords[1]]; | 223 | double target = map[coords[0], coords[1]]; |
224 | 224 | ||
225 | if (target > heightF + talus) | 225 | if (target > heightF + talus) |
226 | { | 226 | { |
227 | double calc = duration * ((target - heightF) - talus) * z; | 227 | double calc = duration * ((target - heightF) - talus) * z; |
228 | heightF += calc; | 228 | heightF += calc; |
229 | target -= calc; | 229 | target -= calc; |
230 | } | 230 | } |
231 | 231 | ||
232 | map[x, y] = heightF; | 232 | map[x, y] = heightF; |
233 | map[coords[0], coords[1]] = target; | 233 | map[coords[0], coords[1]] = target; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | } | 236 | } |
237 | } | 237 | } |
238 | } | 238 | } |
239 | } | 239 | } |
240 | 240 | ||
241 | #endregion | 241 | #endregion |
242 | } | 242 | } |
243 | } | 243 | } |