aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD
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
parent* More console related changes. (diff)
downloadopensim-SC-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.zip
opensim-SC-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.tar.gz
opensim-SC-4b0734c4ad75b93d84c11942531cf2d2e070ba6e.tar.bz2
opensim-SC-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')
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Editing/Flatten.cs50
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs37
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs4
3 files changed, 87 insertions, 4 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
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
index b585caa..8427eab 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Generators/Fracture.cs
@@ -79,6 +79,7 @@ namespace libTerrain
79 79
80 throw new Exception("Out of bounds parameter (val)"); 80 throw new Exception("Out of bounds parameter (val)");
81 } 81 }
82
82 public void Fracture(int number, double scalemin, double scalemax) 83 public void Fracture(int number, double scalemin, double scalemax)
83 { 84 {
84 Random rand = new Random(seed); 85 Random rand = new Random(seed);
@@ -90,6 +91,8 @@ namespace libTerrain
90 a = RadialEdge256(rand.Next(1023)); // TODO: Broken 91 a = RadialEdge256(rand.Next(1023)); // TODO: Broken
91 b = RadialEdge256(rand.Next(1023)); // TODO: Broken 92 b = RadialEdge256(rand.Next(1023)); // TODO: Broken
92 double z = rand.NextDouble(); 93 double z = rand.NextDouble();
94 double u = rand.NextDouble();
95 double v = rand.NextDouble();
93 96
94 for (int x = 0; x < w; x++) 97 for (int x = 0; x < w; x++)
95 { 98 {
@@ -97,9 +100,39 @@ namespace libTerrain
97 { 100 {
98 double miny = Tools.linearInterpolate(a[1], b[1], (double)x / (double)w); 101 double miny = Tools.linearInterpolate(a[1], b[1], (double)x / (double)w);
99 102
100 if (y > miny) 103 if (v >= 0.5)
104 {
105 if (u >= 0.5)
106 {
107 if (y > miny)
108 {
109 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
110 }
111 }
112 else
113 {
114 if (y < miny)
115 {
116 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
117 }
118 }
119 }
120 else
101 { 121 {
102 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z); 122 if (u >= 0.5)
123 {
124 if (x > miny)
125 {
126 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
127 }
128 }
129 else
130 {
131 if (x < miny)
132 {
133 map[x, y] += Tools.linearInterpolate(scalemin, scalemax, z);
134 }
135 }
103 } 136 }
104 } 137 }
105 } 138 }
diff --git a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
index 24ff37c..a035098 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/libTerrainBSD/Channel/Manipulators/NavierStokes.cs
@@ -225,9 +225,9 @@ namespace libTerrain
225 int i; 225 int i;
226 int j; 226 int j;
227 227
228 for (i = 0; i <= N; i++) 228 for (i = 1; i <= N; i++)
229 { 229 {
230 for (j = 0; j <= N; j++) 230 for (j = 1; j <= N; j++)
231 { 231 {
232 dens[nsIX(i, j, N)] = doubles[i, j]; 232 dens[nsIX(i, j, N)] = doubles[i, j];
233 } 233 }