aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs43
1 files changed, 3 insertions, 40 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs
index 2d46fd9..e679189 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/PaintBrushes/ErodeSphere.cs
@@ -146,51 +146,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
146 return coord; 146 return coord;
147 } 147 }
148 148
149 private double SphericalFactor(double x, double y, double rx, double ry, double size)
150 {
151 double z = size * size - ((x - rx) * (x - rx) + (y - ry) * (y - ry));
152 return z;
153 }
154
155 private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
156 {
157 int w = map.Width;
158 int h = map.Height;
159
160 if (x > w - 2.0)
161 x = w - 2.0;
162 if (y > h - 2.0)
163 y = h - 2.0;
164 if (x < 0.0)
165 x = 0.0;
166 if (y < 0.0)
167 y = 0.0;
168
169 int stepSize = 1;
170 double h00 = map[(int)x, (int)y];
171 double h10 = map[(int)x + stepSize, (int)y];
172 double h01 = map[(int)x, (int)y + stepSize];
173 double h11 = map[(int)x + stepSize, (int)y + stepSize];
174 double h1 = h00;
175 double h2 = h10;
176 double h3 = h01;
177 double h4 = h11;
178 double a00 = h1;
179 double a10 = h2 - h1;
180 double a01 = h3 - h1;
181 double a11 = h1 - h2 - h3 + h4;
182 double partialx = x - (int)x;
183 double partialz = y - (int)y;
184 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
185 return hi;
186 }
187
188 #endregion 149 #endregion
189 150
190 #region ITerrainPaintableEffect Members 151 #region ITerrainPaintableEffect Members
191 152
192 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 153 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration)
193 { 154 {
155 strength = TerrainUtil.MetersToSphericalStrength(strength);
156
194 int x, y; 157 int x, y;
195 // Using one 'rain' round for this, so skipping a useless loop 158 // Using one 'rain' round for this, so skipping a useless loop
196 // Will need to adapt back in for the Flood brush 159 // Will need to adapt back in for the Flood brush
@@ -201,7 +164,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.PaintBrushes
201 // Fill with rain 164 // Fill with rain
202 for (x = 0; x < water.Width; x++) 165 for (x = 0; x < water.Width; x++)
203 for (y = 0; y < water.Height; y++) 166 for (y = 0; y < water.Height; y++)
204 water[x, y] = Math.Max(0.0, SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration); 167 water[x, y] = Math.Max(0.0, TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * rainHeight * duration);
205 168
206 for (int i = 0; i < rounds; i++) 169 for (int i = 0; i < rounds; i++)
207 { 170 {