diff options
author | Adam Frisby | 2007-07-21 22:20:22 +0000 |
---|---|---|
committer | Adam Frisby | 2007-07-21 22:20:22 +0000 |
commit | 4eb8ca49a901b09ce4bc3130f76f53b910391bbc (patch) | |
tree | a8bf71c7dee31f69a26e29e0708317429653fd7c /OpenSim/Region | |
parent | * Fixed an issue whereby extremely tall terrains would be unable to output a ... (diff) | |
download | opensim-SC_OLD-4eb8ca49a901b09ce4bc3130f76f53b910391bbc.zip opensim-SC_OLD-4eb8ca49a901b09ce4bc3130f76f53b910391bbc.tar.gz opensim-SC_OLD-4eb8ca49a901b09ce4bc3130f76f53b910391bbc.tar.bz2 opensim-SC_OLD-4eb8ca49a901b09ce4bc3130f76f53b910391bbc.tar.xz |
* Renamed terrain functions to match OpenSim naming styles.
* Added capability to support minimum/maximum terrain limits (from the last 'bake')
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/RegionApplicationBase.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Environment/LandManagement/Land.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 12 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 30 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 4 | ||||
-rw-r--r-- | OpenSim/Region/Examples/SimpleApp/MyWorld.cs | 2 | ||||
-rw-r--r-- | OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | 136 |
7 files changed, 113 insertions, 77 deletions
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs index 4a1fd99..1651ec2 100644 --- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs +++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs | |||
@@ -113,7 +113,7 @@ namespace OpenSim.Region.ClientStack | |||
113 | scene.LoadWorldMap(); | 113 | scene.LoadWorldMap(); |
114 | 114 | ||
115 | scene.PhysScene = GetPhysicsScene( ); | 115 | scene.PhysScene = GetPhysicsScene( ); |
116 | scene.PhysScene.SetTerrain(scene.Terrain.getHeights1D()); | 116 | scene.PhysScene.SetTerrain(scene.Terrain.GetHeights1D()); |
117 | scene.LoadPrimsFromStorage(); | 117 | scene.LoadPrimsFromStorage(); |
118 | 118 | ||
119 | //Master Avatar Setup | 119 | //Master Avatar Setup |
diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs index b333f36..bae3b0e 100644 --- a/OpenSim/Region/Environment/LandManagement/Land.cs +++ b/OpenSim/Region/Environment/LandManagement/Land.cs | |||
@@ -219,8 +219,8 @@ namespace OpenSim.Region.Environment.LandManagement | |||
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | landData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.get((min_x * 4), (min_y * 4))); | 222 | landData.AABBMin = new LLVector3((float)(min_x * 4), (float)(min_y * 4), (float)m_world.Terrain.GetHeight((min_x * 4), (min_y * 4))); |
223 | landData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.get((max_x * 4), (max_y * 4))); | 223 | landData.AABBMax = new LLVector3((float)(max_x * 4), (float)(max_y * 4), (float)m_world.Terrain.GetHeight((max_x * 4), (max_y * 4))); |
224 | landData.area = tempArea; | 224 | landData.area = tempArea; |
225 | } | 225 | } |
226 | 226 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index 9a81a5f..e963737 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | |||
@@ -54,32 +54,32 @@ namespace OpenSim.Region.Environment.Scenes | |||
54 | { | 54 | { |
55 | case 0: | 55 | case 0: |
56 | // flatten terrain | 56 | // flatten terrain |
57 | Terrain.flatten(north, west, size, (double)seconds / 5.0); | 57 | Terrain.FlattenTerrain(north, west, size, (double)seconds / 5.0); |
58 | RegenerateTerrain(true, (int)north, (int)west); | 58 | RegenerateTerrain(true, (int)north, (int)west); |
59 | break; | 59 | break; |
60 | case 1: | 60 | case 1: |
61 | // raise terrain | 61 | // raise terrain |
62 | Terrain.raise(north, west, size, (double)seconds / 5.0); | 62 | Terrain.RaiseTerrain(north, west, size, (double)seconds / 5.0); |
63 | RegenerateTerrain(true, (int)north, (int)west); | 63 | RegenerateTerrain(true, (int)north, (int)west); |
64 | break; | 64 | break; |
65 | case 2: | 65 | case 2: |
66 | //lower terrain | 66 | //lower terrain |
67 | Terrain.lower(north, west, size, (double)seconds / 5.0); | 67 | Terrain.LowerTerrain(north, west, size, (double)seconds / 5.0); |
68 | RegenerateTerrain(true, (int)north, (int)west); | 68 | RegenerateTerrain(true, (int)north, (int)west); |
69 | break; | 69 | break; |
70 | case 3: | 70 | case 3: |
71 | // smooth terrain | 71 | // smooth terrain |
72 | Terrain.smooth(north, west, size, (double)seconds / 5.0); | 72 | Terrain.SmoothTerrain(north, west, size, (double)seconds / 5.0); |
73 | RegenerateTerrain(true, (int)north, (int)west); | 73 | RegenerateTerrain(true, (int)north, (int)west); |
74 | break; | 74 | break; |
75 | case 4: | 75 | case 4: |
76 | // noise | 76 | // noise |
77 | Terrain.noise(north, west, size, (double)seconds / 5.0); | 77 | Terrain.NoiseTerrain(north, west, size, (double)seconds / 5.0); |
78 | RegenerateTerrain(true, (int)north, (int)west); | 78 | RegenerateTerrain(true, (int)north, (int)west); |
79 | break; | 79 | break; |
80 | case 5: | 80 | case 5: |
81 | // revert | 81 | // revert |
82 | Terrain.revert(north, west, size, (double)seconds / 5.0); | 82 | Terrain.RevertTerrain(north, west, size, (double)seconds / 5.0); |
83 | RegenerateTerrain(true, (int)north, (int)west); | 83 | RegenerateTerrain(true, (int)north, (int)west); |
84 | break; | 84 | break; |
85 | 85 | ||
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index acd7f3f..64676f0 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs | |||
@@ -239,10 +239,10 @@ namespace OpenSim.Region.Environment.Scenes | |||
239 | { | 239 | { |
240 | lock (m_syncRoot) | 240 | lock (m_syncRoot) |
241 | { | 241 | { |
242 | phyScene.SetTerrain(Terrain.getHeights1D()); | 242 | phyScene.SetTerrain(Terrain.GetHeights1D()); |
243 | } | 243 | } |
244 | 244 | ||
245 | storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 245 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
246 | 246 | ||
247 | ForEachScenePresence(delegate(ScenePresence presence) | 247 | ForEachScenePresence(delegate(ScenePresence presence) |
248 | { | 248 | { |
@@ -295,14 +295,14 @@ namespace OpenSim.Region.Environment.Scenes | |||
295 | { | 295 | { |
296 | try | 296 | try |
297 | { | 297 | { |
298 | Terrain.hills(); | 298 | Terrain.HillsGenerator(); |
299 | 299 | ||
300 | lock (m_syncRoot) | 300 | lock (m_syncRoot) |
301 | { | 301 | { |
302 | phyScene.SetTerrain(Terrain.getHeights1D()); | 302 | phyScene.SetTerrain(Terrain.GetHeights1D()); |
303 | } | 303 | } |
304 | 304 | ||
305 | storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 305 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
306 | 306 | ||
307 | ForEachScenePresence(delegate(ScenePresence presence) | 307 | ForEachScenePresence(delegate(ScenePresence presence) |
308 | { | 308 | { |
@@ -328,12 +328,12 @@ namespace OpenSim.Region.Environment.Scenes | |||
328 | { | 328 | { |
329 | try | 329 | try |
330 | { | 330 | { |
331 | Terrain.setHeights2D(newMap); | 331 | Terrain.SetHeights2D(newMap); |
332 | lock (m_syncRoot) | 332 | lock (m_syncRoot) |
333 | { | 333 | { |
334 | phyScene.SetTerrain(Terrain.getHeights1D()); | 334 | phyScene.SetTerrain(Terrain.GetHeights1D()); |
335 | } | 335 | } |
336 | storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 336 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
337 | 337 | ||
338 | ForEachScenePresence(delegate(ScenePresence presence) | 338 | ForEachScenePresence(delegate(ScenePresence presence) |
339 | { | 339 | { |
@@ -395,28 +395,28 @@ namespace OpenSim.Region.Environment.Scenes | |||
395 | if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile)) | 395 | if (string.IsNullOrEmpty(m_regInfo.estateSettings.terrainFile)) |
396 | { | 396 | { |
397 | Console.WriteLine("No default terrain, procedurally generating..."); | 397 | Console.WriteLine("No default terrain, procedurally generating..."); |
398 | Terrain.hills(); | 398 | Terrain.HillsGenerator(); |
399 | 399 | ||
400 | storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 400 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
401 | } | 401 | } |
402 | else | 402 | else |
403 | { | 403 | { |
404 | try | 404 | try |
405 | { | 405 | { |
406 | Terrain.loadFromFileF32(m_regInfo.estateSettings.terrainFile); | 406 | Terrain.LoadFromFileF32(m_regInfo.estateSettings.terrainFile); |
407 | Terrain *= m_regInfo.estateSettings.terrainMultiplier; | 407 | Terrain *= m_regInfo.estateSettings.terrainMultiplier; |
408 | } | 408 | } |
409 | catch | 409 | catch |
410 | { | 410 | { |
411 | Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); | 411 | Console.WriteLine("Unable to load default terrain, procedurally generating instead..."); |
412 | Terrain.hills(); | 412 | Terrain.HillsGenerator(); |
413 | } | 413 | } |
414 | storageManager.DataStore.StoreTerrain(Terrain.getHeights2DD()); | 414 | storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD()); |
415 | } | 415 | } |
416 | } | 416 | } |
417 | else | 417 | else |
418 | { | 418 | { |
419 | Terrain.setHeights2D(map); | 419 | Terrain.SetHeights2D(map); |
420 | } | 420 | } |
421 | 421 | ||
422 | CreateTerrainTexture(); | 422 | CreateTerrainTexture(); |
@@ -433,7 +433,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
433 | public void CreateTerrainTexture() | 433 | public void CreateTerrainTexture() |
434 | { | 434 | { |
435 | //create a texture asset of the terrain | 435 | //create a texture asset of the terrain |
436 | byte[] data = Terrain.exportJpegImage("defaultstripe.png"); | 436 | byte[] data = Terrain.ExportJpegImage("defaultstripe.png"); |
437 | m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); | 437 | m_regInfo.estateSettings.terrainImageID = LLUUID.Random(); |
438 | AssetBase asset = new AssetBase(); | 438 | AssetBase asset = new AssetBase(); |
439 | asset.FullID = m_regInfo.estateSettings.terrainImageID; | 439 | asset.FullID = m_regInfo.estateSettings.terrainImageID; |
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs index f3db9e2..c91c654 100644 --- a/OpenSim/Region/Environment/Scenes/SceneBase.cs +++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs | |||
@@ -81,7 +81,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
81 | /// <param name="RemoteClient">Client to send to</param> | 81 | /// <param name="RemoteClient">Client to send to</param> |
82 | public virtual void SendLayerData(IClientAPI RemoteClient) | 82 | public virtual void SendLayerData(IClientAPI RemoteClient) |
83 | { | 83 | { |
84 | RemoteClient.SendLayerData(Terrain.getHeights1D()); | 84 | RemoteClient.SendLayerData(Terrain.GetHeights1D()); |
85 | } | 85 | } |
86 | 86 | ||
87 | /// <summary> | 87 | /// <summary> |
@@ -92,7 +92,7 @@ namespace OpenSim.Region.Environment.Scenes | |||
92 | /// <param name="RemoteClient">The client to send to</param> | 92 | /// <param name="RemoteClient">The client to send to</param> |
93 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) | 93 | public virtual void SendLayerData(int px, int py, IClientAPI RemoteClient) |
94 | { | 94 | { |
95 | RemoteClient.SendLayerData(px, py, Terrain.getHeights1D()); | 95 | RemoteClient.SendLayerData(px, py, Terrain.GetHeights1D()); |
96 | } | 96 | } |
97 | 97 | ||
98 | #endregion | 98 | #endregion |
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs index 9749e22..6704a19 100644 --- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs +++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs | |||
@@ -36,7 +36,7 @@ namespace SimpleApp | |||
36 | map[i] = 25f; | 36 | map[i] = 25f; |
37 | } | 37 | } |
38 | 38 | ||
39 | this.Terrain.setHeights1D(map); | 39 | this.Terrain.GetHeights1D(map); |
40 | this.CreateTerrainTexture(); | 40 | this.CreateTerrainTexture(); |
41 | } | 41 | } |
42 | 42 | ||
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs index 686b35d..f965c41 100644 --- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs +++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs | |||
@@ -69,6 +69,17 @@ namespace OpenSim.Region.Terrain | |||
69 | public Channel watermap; | 69 | public Channel watermap; |
70 | 70 | ||
71 | /// <summary> | 71 | /// <summary> |
72 | /// Max amount the terrain can be raised from the revert parameters | ||
73 | /// </summary> | ||
74 | public double maxRaise = 500.0; | ||
75 | |||
76 | /// <summary> | ||
77 | /// Min amount the terrain can be lowered from the revert parameters | ||
78 | /// </summary> | ||
79 | public double minLower = 500.0; | ||
80 | |||
81 | |||
82 | /// <summary> | ||
72 | /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. | 83 | /// Whether or not the terrain has been modified since it was last saved and sent to the Physics engine. |
73 | /// Counts the number of modifications since the last save. (0 = Untainted) | 84 | /// Counts the number of modifications since the last save. (0 = Untainted) |
74 | /// </summary> | 85 | /// </summary> |
@@ -89,10 +100,33 @@ namespace OpenSim.Region.Terrain | |||
89 | } | 100 | } |
90 | 101 | ||
91 | /// <summary> | 102 | /// <summary> |
103 | /// Checks to make sure the terrain is within baked values +/- maxRaise/minLower | ||
104 | /// </summary> | ||
105 | public void CheckHeightValues() | ||
106 | { | ||
107 | int x, y; | ||
108 | for (x = 0; x < w; x++) | ||
109 | { | ||
110 | for (y = 0; y < h; y++) | ||
111 | { | ||
112 | if ((heightmap.get(x, y) > revertmap.get(x, y) + maxRaise)) | ||
113 | { | ||
114 | heightmap.map[x, y] = revertmap(x, y) + maxRaise; | ||
115 | } | ||
116 | if ((heightmap.get(x, y) > revertmap.get(x, y) - minLower)) | ||
117 | { | ||
118 | heightmap.map[x, y] = revertmap(x, y) - minLower; | ||
119 | } | ||
120 | } | ||
121 | } | ||
122 | } | ||
123 | |||
124 | |||
125 | /// <summary> | ||
92 | /// Converts the heightmap to a 65536 value 1D floating point array | 126 | /// Converts the heightmap to a 65536 value 1D floating point array |
93 | /// </summary> | 127 | /// </summary> |
94 | /// <returns>A float[65536] array containing the heightmap</returns> | 128 | /// <returns>A float[65536] array containing the heightmap</returns> |
95 | public float[] getHeights1D() | 129 | public float[] GetHeights1D() |
96 | { | 130 | { |
97 | float[] heights = new float[w * h]; | 131 | float[] heights = new float[w * h]; |
98 | int i; | 132 | int i; |
@@ -109,7 +143,7 @@ namespace OpenSim.Region.Terrain | |||
109 | /// Converts the heightmap to a 256x256 value 2D floating point array. | 143 | /// Converts the heightmap to a 256x256 value 2D floating point array. |
110 | /// </summary> | 144 | /// </summary> |
111 | /// <returns>An array of 256,256 values containing the heightmap</returns> | 145 | /// <returns>An array of 256,256 values containing the heightmap</returns> |
112 | public float[,] getHeights2D() | 146 | public float[,] GetHeights2D() |
113 | { | 147 | { |
114 | float[,] heights = new float[w, h]; | 148 | float[,] heights = new float[w, h]; |
115 | int x, y; | 149 | int x, y; |
@@ -127,7 +161,7 @@ namespace OpenSim.Region.Terrain | |||
127 | /// Converts the heightmap to a 256x256 value 2D floating point array. Double precision version. | 161 | /// Converts the heightmap to a 256x256 value 2D floating point array. Double precision version. |
128 | /// </summary> | 162 | /// </summary> |
129 | /// <returns>An array of 256,256 values containing the heightmap</returns> | 163 | /// <returns>An array of 256,256 values containing the heightmap</returns> |
130 | public double[,] getHeights2DD() | 164 | public double[,] GetHeights2DD() |
131 | { | 165 | { |
132 | return heightmap.map; | 166 | return heightmap.map; |
133 | } | 167 | } |
@@ -136,7 +170,7 @@ namespace OpenSim.Region.Terrain | |||
136 | /// Imports a 1D floating point array into the 2D heightmap array | 170 | /// Imports a 1D floating point array into the 2D heightmap array |
137 | /// </summary> | 171 | /// </summary> |
138 | /// <param name="heights">The array to import (must have 65536 members)</param> | 172 | /// <param name="heights">The array to import (must have 65536 members)</param> |
139 | public void setHeights1D(float[] heights) | 173 | public void GetHeights1D(float[] heights) |
140 | { | 174 | { |
141 | int i; | 175 | int i; |
142 | for (i = 0; i < w * h; i++) | 176 | for (i = 0; i < w * h; i++) |
@@ -151,7 +185,7 @@ namespace OpenSim.Region.Terrain | |||
151 | /// Loads a 2D array of values into the heightmap | 185 | /// Loads a 2D array of values into the heightmap |
152 | /// </summary> | 186 | /// </summary> |
153 | /// <param name="heights">An array of 256,256 float values</param> | 187 | /// <param name="heights">An array of 256,256 float values</param> |
154 | public void setHeights2D(float[,] heights) | 188 | public void SetHeights2D(float[,] heights) |
155 | { | 189 | { |
156 | int x, y; | 190 | int x, y; |
157 | for (x = 0; x < w; x++) | 191 | for (x = 0; x < w; x++) |
@@ -161,6 +195,7 @@ namespace OpenSim.Region.Terrain | |||
161 | heightmap.set(x, y, (double)heights[x, y]); | 195 | heightmap.set(x, y, (double)heights[x, y]); |
162 | } | 196 | } |
163 | } | 197 | } |
198 | SaveRevertMap(); | ||
164 | tainted++; | 199 | tainted++; |
165 | } | 200 | } |
166 | 201 | ||
@@ -168,7 +203,7 @@ namespace OpenSim.Region.Terrain | |||
168 | /// Loads a 2D array of values into the heightmap (Double Precision Version) | 203 | /// Loads a 2D array of values into the heightmap (Double Precision Version) |
169 | /// </summary> | 204 | /// </summary> |
170 | /// <param name="heights">An array of 256,256 float values</param> | 205 | /// <param name="heights">An array of 256,256 float values</param> |
171 | public void setHeights2D(double[,] heights) | 206 | public void SetHeights2D(double[,] heights) |
172 | { | 207 | { |
173 | int x, y; | 208 | int x, y; |
174 | for (x = 0; x < w; x++) | 209 | for (x = 0; x < w; x++) |
@@ -178,13 +213,14 @@ namespace OpenSim.Region.Terrain | |||
178 | heightmap.set(x, y, heights[x, y]); | 213 | heightmap.set(x, y, heights[x, y]); |
179 | } | 214 | } |
180 | } | 215 | } |
216 | SaveRevertMap(); | ||
181 | tainted++; | 217 | tainted++; |
182 | } | 218 | } |
183 | 219 | ||
184 | /// <summary> | 220 | /// <summary> |
185 | /// Swaps the two heightmap buffers (the 'revert map' and the heightmap) | 221 | /// Swaps the two heightmap buffers (the 'revert map' and the heightmap) |
186 | /// </summary> | 222 | /// </summary> |
187 | public void swapRevertMaps() | 223 | public void SwapRevertMaps() |
188 | { | 224 | { |
189 | Channel backup = heightmap.copy(); | 225 | Channel backup = heightmap.copy(); |
190 | heightmap = revertmap; | 226 | heightmap = revertmap; |
@@ -194,7 +230,7 @@ namespace OpenSim.Region.Terrain | |||
194 | /// <summary> | 230 | /// <summary> |
195 | /// Saves the current heightmap into the revertmap | 231 | /// Saves the current heightmap into the revertmap |
196 | /// </summary> | 232 | /// </summary> |
197 | public void saveRevertMap() | 233 | public void SaveRevertMap() |
198 | { | 234 | { |
199 | revertmap = heightmap.copy(); | 235 | revertmap = heightmap.copy(); |
200 | } | 236 | } |
@@ -239,20 +275,20 @@ namespace OpenSim.Region.Terrain | |||
239 | return false; | 275 | return false; |
240 | 276 | ||
241 | case "revert": | 277 | case "revert": |
242 | swapRevertMaps(); | 278 | SwapRevertMaps(); |
243 | saveRevertMap(); | 279 | SaveRevertMap(); |
244 | break; | 280 | break; |
245 | 281 | ||
246 | case "bake": | 282 | case "bake": |
247 | saveRevertMap(); | 283 | SaveRevertMap(); |
248 | break; | 284 | break; |
249 | 285 | ||
250 | case "seed": | 286 | case "seed": |
251 | setSeed(Convert.ToInt32(args[1])); | 287 | SetSeed(Convert.ToInt32(args[1])); |
252 | break; | 288 | break; |
253 | 289 | ||
254 | case "erode": | 290 | case "erode": |
255 | return consoleErosion(args, ref resultText); | 291 | return ConsoleErosion(args, ref resultText); |
256 | 292 | ||
257 | case "voronoi": | 293 | case "voronoi": |
258 | double[] c = new double[2]; | 294 | double[] c = new double[2]; |
@@ -262,14 +298,14 @@ namespace OpenSim.Region.Terrain | |||
262 | break; | 298 | break; |
263 | 299 | ||
264 | case "hills": | 300 | case "hills": |
265 | return consoleHills(args, ref resultText); | 301 | return ConsoleHills(args, ref resultText); |
266 | 302 | ||
267 | case "regenerate": | 303 | case "regenerate": |
268 | hills(); | 304 | HillsGenerator(); |
269 | break; | 305 | break; |
270 | 306 | ||
271 | case "rescale": | 307 | case "rescale": |
272 | setRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); | 308 | SetRange(Convert.ToSingle(args[1]), Convert.ToSingle(args[2])); |
273 | break; | 309 | break; |
274 | 310 | ||
275 | case "multiply": | 311 | case "multiply": |
@@ -282,15 +318,15 @@ namespace OpenSim.Region.Terrain | |||
282 | switch (args[1].ToLower()) | 318 | switch (args[1].ToLower()) |
283 | { | 319 | { |
284 | case "f32": | 320 | case "f32": |
285 | loadFromFileF32(args[2]); | 321 | LoadFromFileF32(args[2]); |
286 | break; | 322 | break; |
287 | 323 | ||
288 | case "f64": | 324 | case "f64": |
289 | loadFromFileF64(args[2]); | 325 | LoadFromFileF64(args[2]); |
290 | break; | 326 | break; |
291 | 327 | ||
292 | case "raw": | 328 | case "raw": |
293 | loadFromFileSLRAW(args[2]); | 329 | LoadFromFileSLRAW(args[2]); |
294 | break; | 330 | break; |
295 | 331 | ||
296 | case "img": | 332 | case "img": |
@@ -308,15 +344,15 @@ namespace OpenSim.Region.Terrain | |||
308 | switch (args[1].ToLower()) | 344 | switch (args[1].ToLower()) |
309 | { | 345 | { |
310 | case "f32": | 346 | case "f32": |
311 | writeToFileF32(args[2]); | 347 | WriteToFileF32(args[2]); |
312 | break; | 348 | break; |
313 | 349 | ||
314 | case "f64": | 350 | case "f64": |
315 | writeToFileF64(args[2]); | 351 | WriteToFileF64(args[2]); |
316 | break; | 352 | break; |
317 | 353 | ||
318 | case "grdmap": | 354 | case "grdmap": |
319 | exportImage(args[2], args[3]); | 355 | ExportImage(args[2], args[3]); |
320 | break; | 356 | break; |
321 | 357 | ||
322 | case "png": | 358 | case "png": |
@@ -324,11 +360,11 @@ namespace OpenSim.Region.Terrain | |||
324 | break; | 360 | break; |
325 | 361 | ||
326 | case "raw": | 362 | case "raw": |
327 | writeToFileRAW(args[2]); | 363 | WriteToFileRAW(args[2]); |
328 | break; | 364 | break; |
329 | 365 | ||
330 | case "hiraw": | 366 | case "hiraw": |
331 | writeToFileHiRAW(args[2]); | 367 | WriteToFileHiRAW(args[2]); |
332 | break; | 368 | break; |
333 | 369 | ||
334 | default: | 370 | default: |
@@ -366,7 +402,7 @@ namespace OpenSim.Region.Terrain | |||
366 | } | 402 | } |
367 | } | 403 | } |
368 | 404 | ||
369 | private bool consoleErosion(string[] args, ref string resultText) | 405 | private bool ConsoleErosion(string[] args, ref string resultText) |
370 | { | 406 | { |
371 | switch (args[1].ToLower()) | 407 | switch (args[1].ToLower()) |
372 | { | 408 | { |
@@ -384,10 +420,10 @@ namespace OpenSim.Region.Terrain | |||
384 | return true; | 420 | return true; |
385 | } | 421 | } |
386 | 422 | ||
387 | private bool consoleHills(string[] args, ref string resultText) | 423 | private bool ConsoleHills(string[] args, ref string resultText) |
388 | { | 424 | { |
389 | Random RandomClass = new Random(); | 425 | Random RandomClass = new Random(); |
390 | setSeed(RandomClass.Next()); | 426 | SetSeed(RandomClass.Next()); |
391 | int count; | 427 | int count; |
392 | double sizeMin; | 428 | double sizeMin; |
393 | double sizeRange; | 429 | double sizeRange; |
@@ -441,7 +477,7 @@ namespace OpenSim.Region.Terrain | |||
441 | /// </summary> | 477 | /// </summary> |
442 | /// <param name="min">Minimum value of the new array</param> | 478 | /// <param name="min">Minimum value of the new array</param> |
443 | /// <param name="max">Maximum value of the new array</param> | 479 | /// <param name="max">Maximum value of the new array</param> |
444 | public void setRange(float min, float max) | 480 | public void SetRange(float min, float max) |
445 | { | 481 | { |
446 | heightmap.normalise((double)min, (double)max); | 482 | heightmap.normalise((double)min, (double)max); |
447 | tainted++; | 483 | tainted++; |
@@ -452,7 +488,7 @@ namespace OpenSim.Region.Terrain | |||
452 | /// </summary> | 488 | /// </summary> |
453 | /// <remarks>TODO: Move this to libTerrain itself</remarks> | 489 | /// <remarks>TODO: Move this to libTerrain itself</remarks> |
454 | /// <param name="filename">The filename of the double array to import</param> | 490 | /// <param name="filename">The filename of the double array to import</param> |
455 | public void loadFromFileF64(string filename) | 491 | public void LoadFromFileF64(string filename) |
456 | { | 492 | { |
457 | FileInfo file = new FileInfo(filename); | 493 | FileInfo file = new FileInfo(filename); |
458 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 494 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
@@ -477,7 +513,7 @@ namespace OpenSim.Region.Terrain | |||
477 | /// </summary> | 513 | /// </summary> |
478 | /// <remarks>TODO: Move this to libTerrain itself</remarks> | 514 | /// <remarks>TODO: Move this to libTerrain itself</remarks> |
479 | /// <param name="filename">The filename of the float array to import</param> | 515 | /// <param name="filename">The filename of the float array to import</param> |
480 | public void loadFromFileF32(string filename) | 516 | public void LoadFromFileF32(string filename) |
481 | { | 517 | { |
482 | FileInfo file = new FileInfo(filename); | 518 | FileInfo file = new FileInfo(filename); |
483 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 519 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
@@ -502,7 +538,7 @@ namespace OpenSim.Region.Terrain | |||
502 | /// </summary> | 538 | /// </summary> |
503 | /// <remarks>This file format stinks and is best avoided.</remarks> | 539 | /// <remarks>This file format stinks and is best avoided.</remarks> |
504 | /// <param name="filename">A path to the .RAW format</param> | 540 | /// <param name="filename">A path to the .RAW format</param> |
505 | public void loadFromFileSLRAW(string filename) | 541 | public void LoadFromFileSLRAW(string filename) |
506 | { | 542 | { |
507 | FileInfo file = new FileInfo(filename); | 543 | FileInfo file = new FileInfo(filename); |
508 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); | 544 | FileStream s = file.Open(FileMode.Open, FileAccess.Read); |
@@ -527,7 +563,7 @@ namespace OpenSim.Region.Terrain | |||
527 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. | 563 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry double[] array. |
528 | /// </summary> | 564 | /// </summary> |
529 | /// <param name="filename">The desired output filename</param> | 565 | /// <param name="filename">The desired output filename</param> |
530 | public void writeToFileF64(string filename) | 566 | public void WriteToFileF64(string filename) |
531 | { | 567 | { |
532 | FileInfo file = new FileInfo(filename); | 568 | FileInfo file = new FileInfo(filename); |
533 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 569 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
@@ -550,7 +586,7 @@ namespace OpenSim.Region.Terrain | |||
550 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array | 586 | /// Writes the current terrain heightmap to disk, in the format of a 65536 entry float[] array |
551 | /// </summary> | 587 | /// </summary> |
552 | /// <param name="filename">The desired output filename</param> | 588 | /// <param name="filename">The desired output filename</param> |
553 | public void writeToFileF32(string filename) | 589 | public void WriteToFileF32(string filename) |
554 | { | 590 | { |
555 | FileInfo file = new FileInfo(filename); | 591 | FileInfo file = new FileInfo(filename); |
556 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 592 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
@@ -574,7 +610,7 @@ namespace OpenSim.Region.Terrain | |||
574 | /// (is also editable in an image application) | 610 | /// (is also editable in an image application) |
575 | /// </summary> | 611 | /// </summary> |
576 | /// <param name="filename">Filename to write to</param> | 612 | /// <param name="filename">Filename to write to</param> |
577 | public void writeToFileRAW(string filename) | 613 | public void WriteToFileRAW(string filename) |
578 | { | 614 | { |
579 | FileInfo file = new FileInfo(filename); | 615 | FileInfo file = new FileInfo(filename); |
580 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 616 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
@@ -639,7 +675,7 @@ namespace OpenSim.Region.Terrain | |||
639 | /// </summary> | 675 | /// </summary> |
640 | /// <remarks>Does not calculate the revert map</remarks> | 676 | /// <remarks>Does not calculate the revert map</remarks> |
641 | /// <param name="filename">The filename to output to</param> | 677 | /// <param name="filename">The filename to output to</param> |
642 | public void writeToFileHiRAW(string filename) | 678 | public void WriteToFileHiRAW(string filename) |
643 | { | 679 | { |
644 | FileInfo file = new FileInfo(filename); | 680 | FileInfo file = new FileInfo(filename); |
645 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); | 681 | FileStream s = file.Open(FileMode.CreateNew, FileAccess.Write); |
@@ -712,7 +748,7 @@ namespace OpenSim.Region.Terrain | |||
712 | /// Sets the random seed to be used by procedural functions which involve random numbers. | 748 | /// Sets the random seed to be used by procedural functions which involve random numbers. |
713 | /// </summary> | 749 | /// </summary> |
714 | /// <param name="val">The desired seed</param> | 750 | /// <param name="val">The desired seed</param> |
715 | public void setSeed(int val) | 751 | public void SetSeed(int val) |
716 | { | 752 | { |
717 | heightmap.seed = val; | 753 | heightmap.seed = val; |
718 | } | 754 | } |
@@ -724,7 +760,7 @@ namespace OpenSim.Region.Terrain | |||
724 | /// <param name="ry">Center of the sphere on the Y axis</param> | 760 | /// <param name="ry">Center of the sphere on the Y axis</param> |
725 | /// <param name="size">The radius of the sphere</param> | 761 | /// <param name="size">The radius of the sphere</param> |
726 | /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> | 762 | /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> |
727 | public void raise(double rx, double ry, double size, double amount) | 763 | public void RaiseTerrain(double rx, double ry, double size, double amount) |
728 | { | 764 | { |
729 | lock (heightmap) | 765 | lock (heightmap) |
730 | { | 766 | { |
@@ -741,7 +777,7 @@ namespace OpenSim.Region.Terrain | |||
741 | /// <param name="ry">The center of the sphere at the Y axis</param> | 777 | /// <param name="ry">The center of the sphere at the Y axis</param> |
742 | /// <param name="size">The radius of the sphere in meters</param> | 778 | /// <param name="size">The radius of the sphere in meters</param> |
743 | /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> | 779 | /// <param name="amount">Scale the height of the sphere by this amount (recommended 0..2)</param> |
744 | public void lower(double rx, double ry, double size, double amount) | 780 | public void LowerTerrain(double rx, double ry, double size, double amount) |
745 | { | 781 | { |
746 | lock (heightmap) | 782 | lock (heightmap) |
747 | { | 783 | { |
@@ -758,7 +794,7 @@ namespace OpenSim.Region.Terrain | |||
758 | /// <param name="ry">Center of sphere</param> | 794 | /// <param name="ry">Center of sphere</param> |
759 | /// <param name="size">Radius of the sphere</param> | 795 | /// <param name="size">Radius of the sphere</param> |
760 | /// <param name="amount">Thickness of the mask (0..2 recommended)</param> | 796 | /// <param name="amount">Thickness of the mask (0..2 recommended)</param> |
761 | public void flatten(double rx, double ry, double size, double amount) | 797 | public void FlattenTerrain(double rx, double ry, double size, double amount) |
762 | { | 798 | { |
763 | lock (heightmap) | 799 | lock (heightmap) |
764 | { | 800 | { |
@@ -775,7 +811,7 @@ namespace OpenSim.Region.Terrain | |||
775 | /// <param name="ry">Center of the bounding sphere</param> | 811 | /// <param name="ry">Center of the bounding sphere</param> |
776 | /// <param name="size">The radius of the sphere</param> | 812 | /// <param name="size">The radius of the sphere</param> |
777 | /// <param name="amount">Strength of the mask (0..2) recommended</param> | 813 | /// <param name="amount">Strength of the mask (0..2) recommended</param> |
778 | public void noise(double rx, double ry, double size, double amount) | 814 | public void NoiseTerrain(double rx, double ry, double size, double amount) |
779 | { | 815 | { |
780 | lock (heightmap) | 816 | lock (heightmap) |
781 | { | 817 | { |
@@ -798,7 +834,7 @@ namespace OpenSim.Region.Terrain | |||
798 | /// <param name="ry">Center of the bounding sphere</param> | 834 | /// <param name="ry">Center of the bounding sphere</param> |
799 | /// <param name="size">The radius of the sphere</param> | 835 | /// <param name="size">The radius of the sphere</param> |
800 | /// <param name="amount">Strength of the mask (0..2) recommended</param> | 836 | /// <param name="amount">Strength of the mask (0..2) recommended</param> |
801 | public void revert(double rx, double ry, double size, double amount) | 837 | public void RevertTerrain(double rx, double ry, double size, double amount) |
802 | { | 838 | { |
803 | lock (heightmap) | 839 | lock (heightmap) |
804 | { | 840 | { |
@@ -818,7 +854,7 @@ namespace OpenSim.Region.Terrain | |||
818 | /// <param name="ry">Center of the sphere</param> | 854 | /// <param name="ry">Center of the sphere</param> |
819 | /// <param name="size">Radius of the sphere</param> | 855 | /// <param name="size">Radius of the sphere</param> |
820 | /// <param name="amount">Thickness of the mask (0..2 recommended)</param> | 856 | /// <param name="amount">Thickness of the mask (0..2 recommended)</param> |
821 | public void smooth(double rx, double ry, double size, double amount) | 857 | public void SmoothTerrain(double rx, double ry, double size, double amount) |
822 | { | 858 | { |
823 | lock (heightmap) | 859 | lock (heightmap) |
824 | { | 860 | { |
@@ -837,7 +873,7 @@ namespace OpenSim.Region.Terrain | |||
837 | /// <summary> | 873 | /// <summary> |
838 | /// Generates a simple set of hills in the shape of an island | 874 | /// Generates a simple set of hills in the shape of an island |
839 | /// </summary> | 875 | /// </summary> |
840 | public void hills() | 876 | public void HillsGenerator() |
841 | { | 877 | { |
842 | lock (heightmap) | 878 | lock (heightmap) |
843 | { | 879 | { |
@@ -855,7 +891,7 @@ namespace OpenSim.Region.Terrain | |||
855 | /// <param name="x">X coord</param> | 891 | /// <param name="x">X coord</param> |
856 | /// <param name="y">Y coord</param> | 892 | /// <param name="y">Y coord</param> |
857 | /// <returns>Height at specified coordinates</returns> | 893 | /// <returns>Height at specified coordinates</returns> |
858 | public double get(int x, int y) | 894 | public double GetHeight(int x, int y) |
859 | { | 895 | { |
860 | return heightmap.get(x, y); | 896 | return heightmap.get(x, y); |
861 | } | 897 | } |
@@ -866,11 +902,11 @@ namespace OpenSim.Region.Terrain | |||
866 | /// <param name="meep">The heightfield</param> | 902 | /// <param name="meep">The heightfield</param> |
867 | /// <param name="val">The multiplier</param> | 903 | /// <param name="val">The multiplier</param> |
868 | /// <returns></returns> | 904 | /// <returns></returns> |
869 | public static TerrainEngine operator *(TerrainEngine meep, Double val) | 905 | public static TerrainEngine operator *(TerrainEngine terrain, Double val) |
870 | { | 906 | { |
871 | meep.heightmap *= val; | 907 | terrain.heightmap *= val; |
872 | meep.tainted++; | 908 | terrain.tainted++; |
873 | return meep; | 909 | return terrain; |
874 | } | 910 | } |
875 | 911 | ||
876 | /// <summary> | 912 | /// <summary> |
@@ -878,7 +914,7 @@ namespace OpenSim.Region.Terrain | |||
878 | /// </summary> | 914 | /// </summary> |
879 | /// <param name="filename">The destination filename for the image</param> | 915 | /// <param name="filename">The destination filename for the image</param> |
880 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> | 916 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> |
881 | public void exportImage(string filename, string gradientmap) | 917 | public void ExportImage(string filename, string gradientmap) |
882 | { | 918 | { |
883 | try | 919 | try |
884 | { | 920 | { |
@@ -917,7 +953,7 @@ namespace OpenSim.Region.Terrain | |||
917 | /// Exports the current heightmap in Jpeg2000 format to a byte[] | 953 | /// Exports the current heightmap in Jpeg2000 format to a byte[] |
918 | /// </summary> | 954 | /// </summary> |
919 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> | 955 | /// <param name="gradientmap">A 1x*height* image which contains the colour gradient to export with. Must be at least 1x2 pixels, 1x256 or more is ideal.</param> |
920 | public byte[] exportJpegImage(string gradientmap) | 956 | public byte[] ExportJpegImage(string gradientmap) |
921 | { | 957 | { |
922 | byte[] imageData = null; | 958 | byte[] imageData = null; |
923 | try | 959 | try |