aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAdam Frisby2007-04-11 05:19:27 +0000
committerAdam Frisby2007-04-11 05:19:27 +0000
commitadb56a46f49127911a2df169c86f2cdfde034966 (patch)
treec5a7b5e279f93538c9506f630b7304b9d55e93e8
parent(no commit message) (diff)
downloadopensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.zip
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.gz
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.bz2
opensim-SC_OLD-adb56a46f49127911a2df169c86f2cdfde034966.tar.xz
Major ass changes to terrain (now uses libTerrain-BSD!) and all-round improvements to code quality. Terrain saving/loading may work now (running through setHeights1D and getHeights1D before DB4o) **WARNING: UNTESTED**
-rw-r--r--OpenSim.Framework/ILocalStorage.cs4
-rw-r--r--OpenSim.RegionServer/world/Avatar.cs4
-rw-r--r--OpenSim.RegionServer/world/World.cs12
-rw-r--r--OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs6
-rw-r--r--OpenSim.Storage/LocalStorageDb4o/MapStorage.cs2
-rw-r--r--OpenSim.Terrain.BasicTerrain/Hills.cs72
-rw-r--r--OpenSim.Terrain.BasicTerrain/Normalise.cs102
-rw-r--r--OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj4
-rw-r--r--OpenSim.Terrain.BasicTerrain/RaiseLower.cs91
-rw-r--r--OpenSim.Terrain.BasicTerrain/TerrainEngine.cs82
-rw-r--r--OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dllbin16384 -> 16384 bytes
-rw-r--r--OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdbbin19968 -> 15872 bytes
-rw-r--r--OpenSim.Terrain.BasicTerrain/bin/Debug/libTerrain-BSD.dllbin0 -> 32768 bytes
-rw-r--r--OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dllbin16384 -> 16384 bytes
-rw-r--r--OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdbbin19968 -> 15872 bytes
-rw-r--r--OpenSim.Terrain.BasicTerrain/obj/Debug/Refactor/OpenSim.Terrain.BasicTerrain.dllbin0 -> 16384 bytes
-rw-r--r--bin/OpenSim.Terrain.BasicTerrain.dllbin7168 -> 16384 bytes
-rw-r--r--bin/libTerrain-BSD.dllbin0 -> 32768 bytes
-rw-r--r--prebuild.xml1
19 files changed, 70 insertions, 310 deletions
diff --git a/OpenSim.Framework/ILocalStorage.cs b/OpenSim.Framework/ILocalStorage.cs
index bc11d8f..2c45baa 100644
--- a/OpenSim.Framework/ILocalStorage.cs
+++ b/OpenSim.Framework/ILocalStorage.cs
@@ -39,8 +39,8 @@ namespace OpenSim.Framework.Interfaces
39 void StorePrim(PrimData prim); 39 void StorePrim(PrimData prim);
40 void RemovePrim(LLUUID primID); 40 void RemovePrim(LLUUID primID);
41 void LoadPrimitives(ILocalStorageReceiver receiver); 41 void LoadPrimitives(ILocalStorageReceiver receiver);
42 float[,] LoadWorld(); 42 float[] LoadWorld();
43 void SaveMap(float[,] heightmap); 43 void SaveMap(float[] heightmap);
44 void ShutDown(); 44 void ShutDown();
45 } 45 }
46 46
diff --git a/OpenSim.RegionServer/world/Avatar.cs b/OpenSim.RegionServer/world/Avatar.cs
index f507797..843c3af 100644
--- a/OpenSim.RegionServer/world/Avatar.cs
+++ b/OpenSim.RegionServer/world/Avatar.cs
@@ -44,7 +44,7 @@ namespace OpenSim.world
44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)"); 44 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("Avatar.cs - Loading details from grid (DUMMY)");
45 ControllingClient = TheClient; 45 ControllingClient = TheClient;
46 localid = 8880000 + (this.m_world._localNumber++); 46 localid = 8880000 + (this.m_world._localNumber++);
47 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 1.0f); 47 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 1.0f);
48 visualParams = new byte[218]; 48 visualParams = new byte[218];
49 for (int i = 0; i < 218; i++) 49 for (int i = 0; i < 218; i++)
50 { 50 {
@@ -332,7 +332,7 @@ namespace OpenSim.world
332 332
333 public override void LandRenegerated() 333 public override void LandRenegerated()
334 { 334 {
335 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain.map[(int)Pos.X, (int)Pos.Y] + 50.0f); 335 Pos = new LLVector3(100.0f, 100.0f, m_world.Terrain[(int)Pos.X, (int)Pos.Y] + 50.0f);
336 } 336 }
337 } 337 }
338 338
diff --git a/OpenSim.RegionServer/world/World.cs b/OpenSim.RegionServer/world/World.cs
index 580804a..c7c57d1 100644
--- a/OpenSim.RegionServer/world/World.cs
+++ b/OpenSim.RegionServer/world/World.cs
@@ -198,7 +198,7 @@ namespace OpenSim.world
198 { 198 {
199 this.phyScene.SetTerrain(Terrain.getHeights1D()); 199 this.phyScene.SetTerrain(Terrain.getHeights1D());
200 } 200 }
201 this.localStorage.SaveMap(this.Terrain.map); 201 this.localStorage.SaveMap(this.Terrain.getHeights1D());
202 202
203 foreach (SimClient client in m_clientThreads.Values) 203 foreach (SimClient client in m_clientThreads.Values)
204 { 204 {
@@ -213,12 +213,12 @@ namespace OpenSim.world
213 213
214 public void RegenerateTerrain(float[,] newMap) 214 public void RegenerateTerrain(float[,] newMap)
215 { 215 {
216 this.Terrain.map = newMap; 216 this.Terrain.setHeights2D(newMap);
217 lock (this.LockPhysicsEngine) 217 lock (this.LockPhysicsEngine)
218 { 218 {
219 this.phyScene.SetTerrain(this.Terrain.getHeights1D()); 219 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
220 } 220 }
221 this.localStorage.SaveMap(this.Terrain.map); 221 this.localStorage.SaveMap(this.Terrain.getHeights1D());
222 222
223 foreach (SimClient client in m_clientThreads.Values) 223 foreach (SimClient client in m_clientThreads.Values)
224 { 224 {
@@ -239,7 +239,7 @@ namespace OpenSim.world
239 { 239 {
240 this.phyScene.SetTerrain(this.Terrain.getHeights1D()); 240 this.phyScene.SetTerrain(this.Terrain.getHeights1D());
241 } 241 }
242 this.localStorage.SaveMap(this.Terrain.map); 242 this.localStorage.SaveMap(this.Terrain.getHeights1D());
243 243
244 foreach (SimClient client in m_clientThreads.Values) 244 foreach (SimClient client in m_clientThreads.Values)
245 { 245 {
@@ -252,7 +252,7 @@ namespace OpenSim.world
252 252
253 public void LoadWorldMap() 253 public void LoadWorldMap()
254 { 254 {
255 float[,] map = this.localStorage.LoadWorld(); 255 float[] map = this.localStorage.LoadWorld();
256 if (map == null) 256 if (map == null)
257 { 257 {
258 this.Terrain.hills(); 258 this.Terrain.hills();
@@ -260,7 +260,7 @@ namespace OpenSim.world
260 } 260 }
261 else 261 else
262 { 262 {
263 this.Terrain.map = map; 263 this.Terrain.setHeights1D(map);
264 } 264 }
265 } 265 }
266 266
diff --git a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
index 189ee1a..da77701 100644
--- a/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
+++ b/OpenSim.Storage/LocalStorageDb4o/Db4LocalStorage.cs
@@ -118,11 +118,11 @@ namespace OpenSim.Storage.LocalStorageDb4o
118 } 118 }
119 } 119 }
120 120
121 public float[,] LoadWorld() 121 public float[] LoadWorld()
122 { 122 {
123 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Loading world...."); 123 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Loading world....");
124 //World blank = new World(); 124 //World blank = new World();
125 float[,] heightmap = null; 125 float[] heightmap = null;
126 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Looking for a heightmap in local DB"); 126 OpenSim.Framework.Console.MainConsole.Instance.WriteLine("LoadWorld() - Looking for a heightmap in local DB");
127 IObjectSet world_result = db.Get(typeof(MapStorage)); 127 IObjectSet world_result = db.Get(typeof(MapStorage));
128 if (world_result.Count > 0) 128 if (world_result.Count > 0)
@@ -150,7 +150,7 @@ namespace OpenSim.Storage.LocalStorageDb4o
150 return heightmap; 150 return heightmap;
151 } 151 }
152 152
153 public void SaveMap(float[,] heightmap) 153 public void SaveMap(float[] heightmap)
154 { 154 {
155 IObjectSet world_result = db.Get(typeof(MapStorage)); 155 IObjectSet world_result = db.Get(typeof(MapStorage));
156 if (world_result.Count > 0) 156 if (world_result.Count > 0)
diff --git a/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
index dc5793e..db590ff 100644
--- a/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
+++ b/OpenSim.Storage/LocalStorageDb4o/MapStorage.cs
@@ -6,7 +6,7 @@ namespace OpenSim.Storage.LocalStorageDb4o
6{ 6{
7 public class MapStorage 7 public class MapStorage
8 { 8 {
9 public float[,] Map; 9 public float[] Map;
10 10
11 public MapStorage() 11 public MapStorage()
12 { 12 {
diff --git a/OpenSim.Terrain.BasicTerrain/Hills.cs b/OpenSim.Terrain.BasicTerrain/Hills.cs
deleted file mode 100644
index 40543a9..0000000
--- a/OpenSim.Terrain.BasicTerrain/Hills.cs
+++ /dev/null
@@ -1,72 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Terrain.BasicTerrain
6{
7 static class Hills
8 {
9 /// <summary>
10 /// Generates a series of spheres which are then either max()'d or added together. Inspired by suggestion from jh.
11 /// </summary>
12 /// <remarks>3-Clause BSD Licensed</remarks>
13 /// <param name="number">The number of hills to generate</param>
14 /// <param name="scale_min">The minimum size of each hill</param>
15 /// <param name="scale_range">The maximum size of each hill</param>
16 /// <param name="island">Whether to bias hills towards the center of the map</param>
17 /// <param name="additive">Whether to add hills together or to pick the largest value</param>
18 /// <param name="noisy">Generates hill-shaped noise instead of consistent hills</param>
19 public static void hillsSpheres(float[,] map,int seed, int number, double scale_min, double scale_range, bool island, bool additive, bool noisy)
20 {
21 Random random = new Random(seed);
22 int w = map.GetLength(0);
23 int h = map.GetLength(1);
24 int x, y;
25 int i;
26
27 for (i = 0; i < number; i++)
28 {
29 double rx = Math.Min(255.0, random.NextDouble() * w);
30 double ry = Math.Min(255.0, random.NextDouble() * h);
31 double rand = random.NextDouble();
32
33 if (island)
34 {
35 // Move everything towards the center
36 rx -= w / 2;
37 rx /= 2;
38 rx += w / 2;
39
40 ry -= h / 2;
41 ry /= 2;
42 ry += h / 2;
43 }
44
45 for (x = 0; x < w; x++)
46 {
47 for (y = 0; y < h; y++)
48 {
49 if (noisy)
50 rand = random.NextDouble();
51
52 double z = (scale_min + (scale_range * rand));
53 z *= z;
54 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
55
56 if (z < 0)
57 z = 0;
58
59 if (additive)
60 {
61 map[x, y] += (float)z;
62 }
63 else
64 {
65 map[x, y] = (float)Math.Max(map[x, y], z);
66 }
67 }
68 }
69 }
70 }
71 }
72}
diff --git a/OpenSim.Terrain.BasicTerrain/Normalise.cs b/OpenSim.Terrain.BasicTerrain/Normalise.cs
deleted file mode 100644
index 0d37f44..0000000
--- a/OpenSim.Terrain.BasicTerrain/Normalise.cs
+++ /dev/null
@@ -1,102 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Terrain.BasicTerrain
6{
7 static class Normalise
8 {
9 /// <summary>
10 /// Converts the heightmap to values ranging from 0..1
11 /// </summary>
12 /// <param name="map">The heightmap to be normalised</param>
13 public static void normalise(float[,] map)
14 {
15 double max = findMax(map);
16 double min = findMin(map);
17 int w = map.GetLength(0);
18 int h = map.GetLength(1);
19
20 int x, y;
21
22 for (x = 0; x < w; x++)
23 {
24 for (y = 0; y < h; y++)
25 {
26 map[x, y] = (float)((map[x, y] - min) * (1.0 / (max - min)));
27 }
28 }
29 }
30
31 /// <summary>
32 /// Converts the heightmap to values ranging from 0..<newmax>
33 /// </summary>
34 /// <param name="map">The heightmap to be normalised</param>
35 /// <param name="newmax">The new maximum height value of the map</param>
36 public static void normalise(float[,] map, double newmax)
37 {
38 double max = findMax(map);
39 double min = findMin(map);
40 int w = map.GetLength(0);
41 int h = map.GetLength(1);
42
43 int x, y;
44
45 for (x = 0; x < w; x++)
46 {
47 for (y = 0; y < h; y++)
48 {
49 map[x, y] = (float)((map[x, y] - min) * (1.0 / (max - min)) * newmax);
50 }
51 }
52 }
53
54 /// <summary>
55 /// Finds the largest value in the heightmap
56 /// </summary>
57 /// <param name="map">The heightmap</param>
58 /// <returns>The highest value</returns>
59 public static double findMax(float[,] map)
60 {
61 int x, y;
62 int w = map.GetLength(0);
63 int h = map.GetLength(1);
64 double max = double.MinValue;
65
66 for (x = 0; x < w; x++)
67 {
68 for (y = 0; y < h; y++)
69 {
70 if (map[x, y] > max)
71 max = map[x, y];
72 }
73 }
74
75 return max;
76 }
77
78 /// <summary>
79 /// Finds the lowest value in a heightmap
80 /// </summary>
81 /// <param name="map">The heightmap</param>
82 /// <returns>The minimum value</returns>
83 public static double findMin(float[,] map)
84 {
85 int x, y;
86 int w = map.GetLength(0);
87 int h = map.GetLength(1);
88 double min = double.MaxValue;
89
90 for (x = 0; x < w; x++)
91 {
92 for (y = 0; y < h; y++)
93 {
94 if (map[x, y] < min)
95 min = map[x, y];
96 }
97 }
98
99 return min;
100 }
101 }
102}
diff --git a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
index 328f69d..4c5c04f 100644
--- a/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
+++ b/OpenSim.Terrain.BasicTerrain/OpenSim.Terrain.BasicTerrain.csproj
@@ -28,14 +28,12 @@
28 <WarningLevel>4</WarningLevel> 28 <WarningLevel>4</WarningLevel>
29 </PropertyGroup> 29 </PropertyGroup>
30 <ItemGroup> 30 <ItemGroup>
31 <Reference Include="libTerrain-BSD, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL" />
31 <Reference Include="System" /> 32 <Reference Include="System" />
32 <Reference Include="System.Data" /> 33 <Reference Include="System.Data" />
33 <Reference Include="System.Xml" /> 34 <Reference Include="System.Xml" />
34 </ItemGroup> 35 </ItemGroup>
35 <ItemGroup> 36 <ItemGroup>
36 <Compile Include="Hills.cs" />
37 <Compile Include="Normalise.cs" />
38 <Compile Include="RaiseLower.cs" />
39 <Compile Include="TerrainEngine.cs" /> 37 <Compile Include="TerrainEngine.cs" />
40 <Compile Include="Properties\AssemblyInfo.cs" /> 38 <Compile Include="Properties\AssemblyInfo.cs" />
41 </ItemGroup> 39 </ItemGroup>
diff --git a/OpenSim.Terrain.BasicTerrain/RaiseLower.cs b/OpenSim.Terrain.BasicTerrain/RaiseLower.cs
deleted file mode 100644
index 384bcc0..0000000
--- a/OpenSim.Terrain.BasicTerrain/RaiseLower.cs
+++ /dev/null
@@ -1,91 +0,0 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Terrain.BasicTerrain
6{
7 static class RaiseLower
8 {
9 /// <summary>
10 /// Raises land around the selection
11 /// </summary>
12 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
13 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
14 /// <param name="size">The radius of the dimple</param>
15 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
16 public static void raise(float[,] map, double rx, double ry, double size, double amount)
17 {
18 raiseSphere(map, rx, ry, size, amount);
19 }
20
21 /// <summary>
22 /// Raises land in a sphere around the selection
23 /// </summary>
24 /// <param name="rx">The center the X coordinate of where you wish to raise the land</param>
25 /// <param name="ry">The center the Y coordinate of where you wish to raise the land</param>
26 /// <param name="size">The radius of the sphere dimple</param>
27 /// <param name="amount">How much impact to add to the terrain (0..2 usually)</param>
28 public static void raiseSphere(float[,] map, double rx, double ry, double size, double amount)
29 {
30 int x, y;
31 int w = map.GetLength(0);
32 int h = map.GetLength(1);
33
34 for (x = 0; x < w; x++)
35 {
36 for (y = 0; y < h; y++)
37 {
38 double z = size;
39 z *= z;
40 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
41
42 if (z < 0)
43 z = 0;
44
45 map[x, y] += (float)(z * amount);
46 }
47 }
48 }
49
50 /// <summary>
51 /// Lowers land in a sphere around the selection
52 /// </summary>
53 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
54 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
55 /// <param name="size">The radius of the sphere dimple</param>
56 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
57 public static void lower(float[,] map, double rx, double ry, double size, double amount)
58 {
59 lowerSphere(map, rx, ry, size, amount);
60 }
61
62 /// <summary>
63 /// Lowers land in a sphere around the selection
64 /// </summary>
65 /// <param name="rx">The center the X coordinate of where you wish to lower the land</param>
66 /// <param name="ry">The center the Y coordinate of where you wish to lower the land</param>
67 /// <param name="size">The radius of the sphere dimple</param>
68 /// <param name="amount">How much impact to remove from the terrain (0..2 usually)</param>
69 public static void lowerSphere(float[,] map, double rx, double ry, double size, double amount)
70 {
71 int x, y;
72 int w = map.GetLength(0);
73 int h = map.GetLength(1);
74
75 for (x = 0; x < w; x++)
76 {
77 for (y = 0; y < h; y++)
78 {
79 double z = size;
80 z *= z;
81 z -= ((x - rx) * (x - rx)) + ((y - ry) * (y - ry));
82
83 if (z < 0)
84 z = 0;
85
86 map[x, y] -= (float)(z * amount);
87 }
88 }
89 }
90 }
91}
diff --git a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
index 87dbf7e..bd4b85f 100644
--- a/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim.Terrain.BasicTerrain/TerrainEngine.cs
@@ -1,7 +1,7 @@
1using System; 1using System;
2using System.Collections.Generic; 2using System.Collections.Generic;
3using System.Text; 3using System.Text;
4using OpenSim.Terrain.BasicTerrain; 4using libTerrain;
5 5
6namespace OpenSim.Terrain 6namespace OpenSim.Terrain
7{ 7{
@@ -10,11 +10,8 @@ namespace OpenSim.Terrain
10 /// <summary> 10 /// <summary>
11 /// A [normally] 256x256 heightmap 11 /// A [normally] 256x256 heightmap
12 /// </summary> 12 /// </summary>
13 public float[,] map; 13 public Channel heightmap;
14 /// <summary> 14
15 /// A 256x256 heightmap storing water height values
16 /// </summary>
17 public float[,] water;
18 int w, h; 15 int w, h;
19 16
20 /// <summary> 17 /// <summary>
@@ -24,8 +21,7 @@ namespace OpenSim.Terrain
24 { 21 {
25 w = 256; 22 w = 256;
26 h = 256; 23 h = 256;
27 map = new float[w, h]; 24 heightmap = new Channel(w, h);
28 water = new float[w, h];
29 25
30 } 26 }
31 27
@@ -38,7 +34,21 @@ namespace OpenSim.Terrain
38 float[] heights = new float[w*h]; 34 float[] heights = new float[w*h];
39 int i; 35 int i;
40 for(i=0;i<w*h;i++) { 36 for(i=0;i<w*h;i++) {
41 heights[i] = map[i / w, i % w]; 37 heights[i] = (float)heightmap.map[i / w, i % w];
38 }
39 return heights;
40 }
41
42 public float[,] getHeights2D()
43 {
44 float[,] heights = new float[w, h];
45 int x, y;
46 for (x = 0; x < w; x++)
47 {
48 for (y = 0; y < h; y++)
49 {
50 heights[x, y] = (float)heightmap.map[x, y];
51 }
42 } 52 }
43 return heights; 53 return heights;
44 } 54 }
@@ -52,13 +62,27 @@ namespace OpenSim.Terrain
52 int i; 62 int i;
53 for (i = 0; i < w * h; i++) 63 for (i = 0; i < w * h; i++)
54 { 64 {
55 map[i / w, i % w] = heights[i]; 65 heightmap.map[i / w, i % w] = heights[i];
66 }
67 }
68
69 public float[,] setHeights2D(float[,] heights)
70 {
71 int x, y;
72 for (x = 0; x < w; x++)
73 {
74 for (y = 0; y < h; y++)
75 {
76 heightmap.set(x,y,(double)heights[x,y]);
77 }
56 } 78 }
79 return heights;
57 } 80 }
58 81
59 /// <summary> 82 /// <summary>
60 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map. 83 /// Loads a file consisting of 256x256 doubles and imports it as an array into the map.
61 /// </summary> 84 /// </summary>
85 /// <remarks>TODO: Move this to libTerrain itself</remarks>
62 /// <param name="filename">The filename of the double array to import</param> 86 /// <param name="filename">The filename of the double array to import</param>
63 public void loadFromFileF64(string filename) 87 public void loadFromFileF64(string filename)
64 { 88 {
@@ -70,22 +94,12 @@ namespace OpenSim.Terrain
70 { 94 {
71 for (y = 0; y < h; y++) 95 for (y = 0; y < h; y++)
72 { 96 {
73 map[x, y] = (float)bs.ReadDouble(); 97 heightmap.map[x, y] = bs.ReadDouble();
74 } 98 }
75 } 99 }
76 } 100 }
77 101
78 /// <summary> 102 /// <summary>
79 /// Swaps the references between the height and water buffers to allow you to edit the water heightmap. Remember to swap back when you are done.
80 /// </summary>
81 public void swapWaterBuffer()
82 {
83 float[,] temp = map;
84 map = water;
85 water = temp;
86 }
87
88 /// <summary>
89 /// Raises land in a sphere around the specified coordinates 103 /// Raises land in a sphere around the specified coordinates
90 /// </summary> 104 /// </summary>
91 /// <param name="rx">Center of the sphere on the X axis</param> 105 /// <param name="rx">Center of the sphere on the X axis</param>
@@ -94,9 +108,9 @@ namespace OpenSim.Terrain
94 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> 108 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
95 public void raise(double rx, double ry, double size, double amount) 109 public void raise(double rx, double ry, double size, double amount)
96 { 110 {
97 lock (map) 111 lock (heightmap)
98 { 112 {
99 RaiseLower.raiseSphere(this.map, rx, ry, size, amount); 113 heightmap.raise(rx, ry, size, amount);
100 } 114 }
101 } 115 }
102 116
@@ -109,9 +123,9 @@ namespace OpenSim.Terrain
109 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> 123 /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param>
110 public void lower(double rx, double ry, double size, double amount) 124 public void lower(double rx, double ry, double size, double amount)
111 { 125 {
112 lock (map) 126 lock (heightmap)
113 { 127 {
114 RaiseLower.lowerSphere(this.map, rx, ry, size, amount); 128 heightmap.lower(rx, ry, size, amount);
115 } 129 }
116 } 130 }
117 131
@@ -120,12 +134,24 @@ namespace OpenSim.Terrain
120 /// </summary> 134 /// </summary>
121 public void hills() 135 public void hills()
122 { 136 {
123 lock (map) 137 lock (heightmap)
124 { 138 {
125 Hills.hillsSpheres(this.map, 1337, 200, 20, 40, true, true, false); 139 heightmap.hillsSpheres(200, 20, 40, true, true, false);
126 Normalise.normalise(this.map,60); 140 heightmap.normalise();
141 heightmap *= 60.0; // Raise to 60m
127 } 142 }
128 } 143 }
129 144
145 public float this[int x, int y]
146 {
147 get
148 {
149 return (float)heightmap.get(x,y);
150 }
151 set
152 {
153 heightmap.set(x,y,(double)value);
154 }
155 }
130 } 156 }
131} 157}
diff --git a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll
index 0cfa595..b2bcf9f 100644
--- a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll
+++ b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.dll
Binary files differ
diff --git a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb
index ce440c6..e271888 100644
--- a/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb
+++ b/OpenSim.Terrain.BasicTerrain/bin/Debug/OpenSim.Terrain.BasicTerrain.pdb
Binary files differ
diff --git a/OpenSim.Terrain.BasicTerrain/bin/Debug/libTerrain-BSD.dll b/OpenSim.Terrain.BasicTerrain/bin/Debug/libTerrain-BSD.dll
new file mode 100644
index 0000000..d9b95fc
--- /dev/null
+++ b/OpenSim.Terrain.BasicTerrain/bin/Debug/libTerrain-BSD.dll
Binary files differ
diff --git a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll
index 0cfa595..b2bcf9f 100644
--- a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll
+++ b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.dll
Binary files differ
diff --git a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb
index ce440c6..e271888 100644
--- a/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb
+++ b/OpenSim.Terrain.BasicTerrain/obj/Debug/OpenSim.Terrain.BasicTerrain.pdb
Binary files differ
diff --git a/OpenSim.Terrain.BasicTerrain/obj/Debug/Refactor/OpenSim.Terrain.BasicTerrain.dll b/OpenSim.Terrain.BasicTerrain/obj/Debug/Refactor/OpenSim.Terrain.BasicTerrain.dll
new file mode 100644
index 0000000..f42e7bb
--- /dev/null
+++ b/OpenSim.Terrain.BasicTerrain/obj/Debug/Refactor/OpenSim.Terrain.BasicTerrain.dll
Binary files differ
diff --git a/bin/OpenSim.Terrain.BasicTerrain.dll b/bin/OpenSim.Terrain.BasicTerrain.dll
index c864d89..b2bcf9f 100644
--- a/bin/OpenSim.Terrain.BasicTerrain.dll
+++ b/bin/OpenSim.Terrain.BasicTerrain.dll
Binary files differ
diff --git a/bin/libTerrain-BSD.dll b/bin/libTerrain-BSD.dll
new file mode 100644
index 0000000..d9b95fc
--- /dev/null
+++ b/bin/libTerrain-BSD.dll
Binary files differ
diff --git a/prebuild.xml b/prebuild.xml
index 49b1563..f1109a6 100644
--- a/prebuild.xml
+++ b/prebuild.xml
@@ -379,6 +379,7 @@
379 </Configuration> 379 </Configuration>
380 380
381 <ReferencePath>../bin/</ReferencePath> 381 <ReferencePath>../bin/</ReferencePath>
382 <Reference name="libTerrain-BSD.dll"/>
382 <Reference name="System"/> 383 <Reference name="System"/>
383 <Reference name="System.Data"/> 384 <Reference name="System.Data"/>
384 <Reference name="System.Xml"/> 385 <Reference name="System.Xml"/>