aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs41
1 files changed, 16 insertions, 25 deletions
diff --git a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
index 1e2d611..e507481 100644
--- a/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
+++ b/OpenSim/Region/Environment/Modules/World/Terrain/PaintBrushes/FlattenSphere.cs
@@ -25,48 +25,29 @@
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
28using System;
28using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
29 30
30namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes 31namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
31{ 32{
32 public class FlattenSphere : ITerrainPaintableEffect 33 public class FlattenSphere : ITerrainPaintableEffect
33 { 34 {
34
35 #region ITerrainPaintableEffect Members 35 #region ITerrainPaintableEffect Members
36 36
37 public void PaintEffect(ITerrainChannel map, double rx, double ry, double strength, double duration) 37 public void PaintEffect(ITerrainChannel map, bool[,] mask, double rx, double ry, double rz, double strength, double duration)
38 { 38 {
39 strength = TerrainUtil.MetersToSphericalStrength(strength); 39 strength = TerrainUtil.MetersToSphericalStrength(strength);
40 40
41 int x, y; 41 int x, y;
42 42
43 double sum = 0.0;
44 double step2 = 0.0;
45 duration = 0.009; //MCP Should be read from ini file
46
47
48 // compute delta map
49 for (x = 0; x < map.Width; x++)
50 {
51 for (y = 0; y < map.Height; y++)
52 {
53 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength);
54
55 if (z > 0) // add in non-zero amount
56 {
57 sum += map[x, y] * z;
58 step2 += z;
59 }
60 }
61 }
62
63 double avg = sum / step2;
64
65 // blend in map 43 // blend in map
66 for (x = 0; x < map.Width; x++) 44 for (x = 0; x < map.Width; x++)
67 { 45 {
68 for (y = 0; y < map.Height; y++) 46 for (y = 0; y < map.Height; y++)
69 { 47 {
48 if (!mask[x,y])
49 continue;
50
70 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration; 51 double z = TerrainUtil.SphericalFactor(x, y, rx, ry, strength) * duration;
71 52
72 if (z > 0) // add in non-zero amount 53 if (z > 0) // add in non-zero amount
@@ -74,8 +55,18 @@ namespace OpenSim.Region.Environment.Modules.World.Terrain.PaintBrushes
74 if (z > 1.0) 55 if (z > 1.0)
75 z = 1.0; 56 z = 1.0;
76 57
77 map[x, y] = (map[x, y] * (1.0 - z)) + (avg * z); 58 map[x, y] = (map[x, y] * (1.0 - z)) + (rz * z);
78 } 59 }
60
61 double delta = rz - map[x, y];
62 if (Math.Abs(delta) > 0.1)
63 delta *= 0.25;
64
65 if (delta != 0) // add in non-zero amount
66 {
67 map[x, y] += delta;
68 }
69
79 } 70 }
80 } 71 }
81 } 72 }