aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs73
1 files changed, 37 insertions, 36 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
index ba4943d..49d8883 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs
@@ -31,39 +31,6 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{ 31{
32 public class SmoothArea : ITerrainFloodEffect 32 public class SmoothArea : ITerrainFloodEffect
33 { 33 {
34 private double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
35 {
36 int w = map.Width;
37 int h = map.Height;
38
39 if (x > w - 2.0)
40 x = w - 2.0;
41 if (y > h - 2.0)
42 y = h - 2.0;
43 if (x < 0.0)
44 x = 0.0;
45 if (y < 0.0)
46 y = 0.0;
47
48 int stepSize = 1;
49 double h00 = map[(int)x, (int)y];
50 double h10 = map[(int)x + stepSize, (int)y];
51 double h01 = map[(int)x, (int)y + stepSize];
52 double h11 = map[(int)x + stepSize, (int)y + stepSize];
53 double h1 = h00;
54 double h2 = h10;
55 double h3 = h01;
56 double h4 = h11;
57 double a00 = h1;
58 double a10 = h2 - h1;
59 double a01 = h3 - h1;
60 double a11 = h1 - h2 - h3 + h4;
61 double partialx = x - (int)x;
62 double partialz = y - (int)y;
63 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
64 return hi;
65 }
66
67 #region ITerrainFloodEffect Members 34 #region ITerrainFloodEffect Members
68 35
69 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
@@ -71,9 +38,8 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
71 double area = strength; 38 double area = strength;
72 double step = strength / 4.0; 39 double step = strength / 4.0;
73 40
74 double[,] manipulate = new double[map.Width, map.Height]; 41 double[,] manipulate = new double[map.Width,map.Height];
75 int x, y; 42 int x, y;
76 double n, l;
77 for (x = 0; x < map.Width; x++) 43 for (x = 0; x < map.Width; x++)
78 { 44 {
79 for (y = 0; y < map.Height; y++) 45 for (y = 0; y < map.Height; y++)
@@ -84,8 +50,10 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
84 double average = 0.0; 50 double average = 0.0;
85 int avgsteps = 0; 51 int avgsteps = 0;
86 52
53 double n;
87 for (n = 0.0 - area; n < area; n += step) 54 for (n = 0.0 - area; n < area; n += step)
88 { 55 {
56 double l;
89 for (l = 0.0 - area; l < area; l += step) 57 for (l = 0.0 - area; l < area; l += step)
90 { 58 {
91 avgsteps++; 59 avgsteps++;
@@ -109,5 +77,38 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
109 } 77 }
110 78
111 #endregion 79 #endregion
80
81 private static double GetBilinearInterpolate(double x, double y, ITerrainChannel map)
82 {
83 int w = map.Width;
84 int h = map.Height;
85
86 if (x > w - 2.0)
87 x = w - 2.0;
88 if (y > h - 2.0)
89 y = h - 2.0;
90 if (x < 0.0)
91 x = 0.0;
92 if (y < 0.0)
93 y = 0.0;
94
95 int stepSize = 1;
96 double h00 = map[(int) x, (int) y];
97 double h10 = map[(int) x + stepSize, (int) y];
98 double h01 = map[(int) x, (int) y + stepSize];
99 double h11 = map[(int) x + stepSize, (int) y + stepSize];
100 double h1 = h00;
101 double h2 = h10;
102 double h3 = h01;
103 double h4 = h11;
104 double a00 = h1;
105 double a10 = h2 - h1;
106 double a01 = h3 - h1;
107 double a11 = h1 - h2 - h3 + h4;
108 double partialx = x - (int) x;
109 double partialz = y - (int) y;
110 double hi = a00 + (a10 * partialx) + (a01 * partialz) + (a11 * partialx * partialz);
111 return hi;
112 }
112 } 113 }
113} 114} \ No newline at end of file