aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Environment/Modules/Terrain/FloodBrushes')
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs12
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs7
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs4
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs6
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/SmoothArea.cs73
6 files changed, 54 insertions, 55 deletions
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs
index 76abc36..1e0b151 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/FlattenArea.cs
@@ -25,10 +25,6 @@
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;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Region.Environment.Modules.Terrain;
32using OpenSim.Region.Environment.Interfaces; 28using OpenSim.Region.Environment.Interfaces;
33 29
34namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes 30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
@@ -41,14 +37,14 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
41 { 37 {
42 double sum = 0.0; 38 double sum = 0.0;
43 double steps = 0.0; 39 double steps = 0.0;
44 double avg = 0.0; 40 double avg;
45 41
46 int x, y; 42 int x, y;
47 for (x = 0; x < map.Width; x++) 43 for (x = 0; x < map.Width; x++)
48 { 44 {
49 for (y = 0; y < map.Height; y++) 45 for (y = 0; y < map.Height; y++)
50 { 46 {
51 if (fillArea[x, y] == true) 47 if (fillArea[x, y])
52 { 48 {
53 sum += map[x, y]; 49 sum += map[x, y];
54 steps += 1.0; 50 steps += 1.0;
@@ -64,7 +60,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
64 { 60 {
65 for (y = 0; y < map.Height; y++) 61 for (y = 0; y < map.Height; y++)
66 { 62 {
67 if (fillArea[x, y] == true) 63 if (fillArea[x, y])
68 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str); 64 map[x, y] = (map[x, y] * (1.0 - str)) + (avg * str);
69 } 65 }
70 } 66 }
@@ -72,4 +68,4 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
72 68
73 #endregion 69 #endregion
74 } 70 }
75} 71} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs
index 4bb7ab1..410d0cf 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/LowerArea.cs
@@ -35,12 +35,13 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
35 35
36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength) 36 public void FloodEffect(ITerrainChannel map, bool[,] fillArea, double strength)
37 { 37 {
38 int x, y; 38 int x;
39 for (x = 0; x < map.Width; x++) 39 for (x = 0; x < map.Width; x++)
40 { 40 {
41 int y;
41 for (y = 0; y < map.Height; y++) 42 for (y = 0; y < map.Height; y++)
42 { 43 {
43 if (fillArea[x, y] == true) 44 if (fillArea[x, y])
44 { 45 {
45 map[x, y] -= strength; 46 map[x, y] -= strength;
46 } 47 }
@@ -50,4 +51,4 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
50 51
51 #endregion 52 #endregion
52 } 53 }
53} 54} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs
index 284ce42..2ea1b90 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/NoiseArea.cs
@@ -25,6 +25,7 @@
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 OpenSim.Framework;
28using OpenSim.Region.Environment.Interfaces; 29using OpenSim.Region.Environment.Interfaces;
29 30
30namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes 31namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
@@ -40,9 +41,9 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
40 { 41 {
41 for (y = 0; y < map.Height; y++) 42 for (y = 0; y < map.Height; y++)
42 { 43 {
43 if (fillArea[x, y] == true) 44 if (fillArea[x, y])
44 { 45 {
45 double noise = TerrainUtil.PerlinNoise2D((double)x / (double)Framework.Constants.RegionSize, (double)y / (double)Framework.Constants.RegionSize, 8, 1.0); 46 double noise = TerrainUtil.PerlinNoise2D((double) x / Constants.RegionSize, (double) y / Constants.RegionSize, 8, 1.0);
46 47
47 map[x, y] += noise * strength; 48 map[x, y] += noise * strength;
48 } 49 }
@@ -52,4 +53,4 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
52 53
53 #endregion 54 #endregion
54 } 55 }
55} 56} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
index 7a9a3e5..4ea06c8 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RaiseArea.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
40 { 40 {
41 for (y = 0; y < map.Height; y++) 41 for (y = 0; y < map.Height; y++)
42 { 42 {
43 if (fillArea[x, y] == true) 43 if (fillArea[x, y])
44 { 44 {
45 map[x, y] += strength; 45 map[x, y] += strength;
46 } 46 }
@@ -50,4 +50,4 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
50 50
51 #endregion 51 #endregion
52 } 52 }
53} 53} \ No newline at end of file
diff --git a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs
index 45f2d83..198b309 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/FloodBrushes/RevertArea.cs
@@ -31,7 +31,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
31{ 31{
32 public class RevertArea : ITerrainFloodEffect 32 public class RevertArea : ITerrainFloodEffect
33 { 33 {
34 ITerrainChannel m_revertmap; 34 private readonly ITerrainChannel m_revertmap;
35 35
36 public RevertArea(ITerrainChannel revertmap) 36 public RevertArea(ITerrainChannel revertmap)
37 { 37 {
@@ -47,7 +47,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
47 { 47 {
48 for (y = 0; y < map.Height; y++) 48 for (y = 0; y < map.Height; y++)
49 { 49 {
50 if (fillArea[x, y] == true) 50 if (fillArea[x, y])
51 { 51 {
52 map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength); 52 map[x, y] = (map[x, y] * (1.0 - strength)) + (m_revertmap[x, y] * strength);
53 } 53 }
@@ -57,4 +57,4 @@ namespace OpenSim.Region.Environment.Modules.Terrain.FloodBrushes
57 57
58 #endregion 58 #endregion
59 } 59 }
60} 60} \ No newline at end of file
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