diff options
author | Adam Frisby | 2008-03-12 11:02:30 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-12 11:02:30 +0000 |
commit | 8e27656fcc0331c8521e4ef8e8ece4495f1f32ae (patch) | |
tree | 560a7511ec1a7a7e26c540d7ca042825b2f10e1e /OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs | |
parent | * Renamed Main.cs to GridServerBase.cs (diff) | |
download | opensim-SC-8e27656fcc0331c8521e4ef8e8ece4495f1f32ae.zip opensim-SC-8e27656fcc0331c8521e4ef8e8ece4495f1f32ae.tar.gz opensim-SC-8e27656fcc0331c8521e4ef8e8ece4495f1f32ae.tar.bz2 opensim-SC-8e27656fcc0331c8521e4ef8e8ece4495f1f32ae.tar.xz |
* Refactored some terrain brushes to move out some common functions into TerrainUtil class. More needs doing.
* Adjusted strength of brushes to Math.Pow(2,size), this should in theory work closer to how it was before.
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs')
-rw-r--r-- | OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs | 43 |
1 files changed, 3 insertions, 40 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs index cac3d35..ef0f9fd 100644 --- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs +++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/WeatherSphere.cs | |||
@@ -142,58 +142,21 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes | |||
142 | return coord; | 142 | return coord; |
143 | } | 143 | } |
144 | 144 | ||
145 | private double SphericalFactor(double x, double y, double rx, double ry, double size) | ||
146 | { | ||
147 | double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry)); | ||
148 | return z; | ||
149 | } | ||
150 | |||
151 | private double GetBilinearInterpolate(double x, double y, ITerrainChannel map) | ||
152 | { | ||
153 | int w = map.Width; | ||
154 | int h = map.Height; | ||
155 | |||
156 | if (x > w - 2.0) | ||
157 | x = w - 2.0; | ||
158 | if (y > h - 2.0) | ||
159 | y = h - 2.0; | ||
160 | if (x < 0.0) | ||
161 | x = 0.0; | ||
162 | if (y < 0.0) | ||
163 | y = 0.0; | ||
164 | |||
165 | int stepSize = 1; | ||
166 | double h00 = map[(int)x, (int)y]; | ||
167 | double h10 = map[(int)x + stepSize, (int)y]; | ||
168 | double h01 = map[(int)x, (int)y + stepSize]; | ||
169 | double h11 = map[(int)x + stepSize, (int)y + stepSize]; | ||
170 | double h1 = h00; | ||
171 | double h2 = h10; | ||
172 | double h3 = h01; | ||
173 | double h4 = h11; | ||
174 | double a00 = h1; | ||
175 | double a10 = h2 - h1; | ||
176 | double a01 = h3 - h1; | ||
177 | double a11 = h1 - h2 - h3 + h4; | ||
178 | double partialx = x - (int)x; | ||
179 | double partialz = y - (int)y; | ||
180 | double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz); | ||
181 | return hi; | ||
182 | } | ||
183 | |||
184 | #endregion | 145 | #endregion |
185 | 146 | ||
186 | #region ITerrainPaintableEffect Members | 147 | #region ITerrainPaintableEffect Members |
187 | 148 | ||
188 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) | 149 | public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) |
189 | { | 150 | { |
151 | strength = TerrainUtil.MetersToSphericalStrength(strength); | ||
152 | |||
190 | int x, y; | 153 | int x, y; |
191 | 154 | ||
192 | for (x = 0; x < map.Width; x++) | 155 | for (x = 0; x < map.Width; x++) |
193 | { | 156 | { |
194 | for (y = 0; y < map.Height; y++) | 157 | for (y = 0; y < map.Height; y++) |
195 | { | 158 | { |
196 | double z = SphericalFactor(x, y, rx, ry, strength); | 159 | double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength); |
197 | 160 | ||
198 | if (z > 0) // add in non-zero amount | 161 | if (z > 0) // add in non-zero amount |
199 | { | 162 | { |