29 using OpenSim.Region.Framework.Interfaces;
30 using OpenSim.Region.Framework.Scenes;
42 private const double nConst = 1024.0;
43 private const NeighbourSystem type = NeighbourSystem.Moore;
45 #region Supporting Functions
47 private static int[] Neighbours(NeighbourSystem neighbourType,
int index)
49 int[] coord =
new int[2];
53 switch (neighbourType)
55 case NeighbourSystem.Moore:
108 case NeighbourSystem.VonNeumann:
145 private enum NeighbourSystem
153 #region ITerrainPaintableEffect Members
156 double strength,
double duration,
int startX,
int endX,
int startY,
int endY)
158 strength = TerrainUtil.MetersToSphericalStrength(strength);
162 for (x = startX; x <= endX; x++)
164 for (y = startY; y <= endY; y++)
169 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
173 const int NEIGHBOUR_ME = 4;
174 const int NEIGHBOUR_MAX = 9;
176 double max = Double.MinValue;
180 for (
int j = 0; j < NEIGHBOUR_MAX; j++)
182 if (j != NEIGHBOUR_ME)
184 int[] coords = Neighbours(type, j);
189 if (coords[0] > map.
Width - 1)
191 if (coords[1] > map.
Height - 1)
198 double cellmax = map[x, y] - map[coords[0], coords[1]];
207 double T = nConst / ((map.Width + map.Height) / 2.0);
209 if (0 < max && max <= T)
211 int[] maxCoords = Neighbours(type, loc);
212 double heightDelta = 0.5 * max * z * duration;
213 map[x, y] -= heightDelta;
214 map[x + maxCoords[0], y + maxCoords[1]] += heightDelta;
void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration, int startX, int endX, int startY, int endY)
Speed-Optimised Hybrid Erosion Brush