aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
diff options
context:
space:
mode:
authorAdam Frisby2007-07-24 04:53:21 +0000
committerAdam Frisby2007-07-24 04:53:21 +0000
commit4b0734c4ad75b93d84c11942531cf2d2e070ba6e (patch)
treee1e6bf405de882a0bc688615c0a736c7b9f42df6 /OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
parent* More console related changes. (diff)
downloadopensim-SC_OLD-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.zip
opensim-SC_OLD-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.tar.gz
opensim-SC_OLD-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.tar.bz2
opensim-SC_OLD-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.tar.xz
* Terrain Fracture Generator now produces more appropriate results.
* Terrain Flatten Brush has been optimised, now affects an appropriate sized section of terrain. * Navier-Stokes handler bounds issue partially fixed.
Diffstat (limited to 'OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs50
1 files changed, 50 insertions, 0 deletions
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
index 57ba729..03b88a4 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs
@@ -44,6 +44,11 @@ namespace libTerrain
44 /// <param name="amount">The scale of the terrain mask</param> 44 /// <param name="amount">The scale of the terrain mask</param>
45 public void Flatten(double rx, double ry, double size, double amount) 45 public void Flatten(double rx, double ry, double size, double amount)
46 { 46 {
47 FlattenFast(rx, ry, size, amount);
48 }
49
50 private void FlattenSlow(double rx, double ry, double size, double amount)
51 {
47 // Generate the mask 52 // Generate the mask
48 Channel temp = new Channel(w, h); 53 Channel temp = new Channel(w, h);
49 temp.Fill(0); 54 temp.Fill(0);
@@ -70,6 +75,51 @@ namespace libTerrain
70 75
71 } 76 }
72 77
78 private void FlattenFast(double rx, double ry, double size, double amount)
79 {
80 int x, y;
81 double avg = 0;
82 double div = 0;
83
84 int minX = Math.Max(0, (int)(rx - (size + 1)));
85 int maxX = Math.Min(w, (int)(rx + (size + 1)));
86 int minY = Math.Max(0, (int)(ry - (size + 1)));
87 int maxY = Math.Min(h, (int)(ry + (size + 1)));
88
89 for (x = minX; x < maxX; x++)
90 {
91 for (y = minY; y < maxY; y++)
92 {
93 double z = size;
94 z *= z;
95 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
96
97 if (z < 0)
98 z = 0;
99
100 avg += z * amount;
101 div += z;
102 }
103 }
104
105 double height = avg / div;
106
107 for (x = minX; x < maxX; x++)
108 {
109 for (y = minY; y < maxY; y++)
110 {
111 double z = size;
112 z *= z;
113 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
114
115 if (z < 0)
116 z = 0;
117
118 map[x, y] = Tools.linearInterpolate(map[x, y], height, z);
119 }
120 }
121 }
122
73 public void Flatten(Channel mask, double amount) 123 public void Flatten(Channel mask, double amount)
74 { 124 {
75 // Generate the mask 125 // Generate the mask