aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs2
-rw-r--r--OpenSim/Framework/Constants.cs1
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs2
-rw-r--r--OpenSim/Region/Environment/EstateManager.cs3
-rw-r--r--OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs1
-rw-r--r--OpenSim/Region/Environment/LandManagement/Land.cs8
-rw-r--r--OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs94
-rw-r--r--OpenSim/Region/Environment/Modules/TreePopulatorModule.cs2
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs23
-rw-r--r--OpenSim/Region/Environment/Scenes/Scene.cs84
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneBase.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneEvents.cs13
-rw-r--r--OpenSim/Region/Environment/Scenes/SceneManager.cs25
-rw-r--r--OpenSim/Region/Examples/SimpleApp/MyWorld.cs8
-rw-r--r--OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs60
-rw-r--r--OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs2
16 files changed, 127 insertions, 214 deletions
diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
index fba0c3b..44f4113 100644
--- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
+++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs
@@ -164,7 +164,7 @@ namespace OpenSim.ApplicationPlugins.LoadRegions
164 164
165 if (m_app.SceneManager.TryGetScene(regionID, out region)) 165 if (m_app.SceneManager.TryGetScene(regionID, out region))
166 { 166 {
167 region.LoadWorldMap(file); 167 //region.LoadWorldMap(file);
168 responseData["success"] = "true"; 168 responseData["success"] = "true";
169 } 169 }
170 else 170 else
diff --git a/OpenSim/Framework/Constants.cs b/OpenSim/Framework/Constants.cs
index 9eca152..1a4e08b 100644
--- a/OpenSim/Framework/Constants.cs
+++ b/OpenSim/Framework/Constants.cs
@@ -35,5 +35,6 @@ namespace OpenSim.Framework
35 public class Constants 35 public class Constants
36 { 36 {
37 public const uint RegionSize = 256; 37 public const uint RegionSize = 256;
38 public const byte TerrainPatchSize = 16;
38 } 39 }
39} 40}
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index 660c3b3..43f630d 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -126,7 +126,7 @@ namespace OpenSim.Region.ClientStack
126 scene.RegisterRegionWithGrid(); 126 scene.RegisterRegionWithGrid();
127 127
128 scene.PhysicsScene = GetPhysicsScene(); 128 scene.PhysicsScene = GetPhysicsScene();
129 scene.PhysicsScene.SetTerrain(scene.Terrain.GetHeights1D()); 129 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
130 130
131 //Master Avatar Setup 131 //Master Avatar Setup
132 UserProfileData masterAvatar; 132 UserProfileData masterAvatar;
diff --git a/OpenSim/Region/Environment/EstateManager.cs b/OpenSim/Region/Environment/EstateManager.cs
index 96baf21..bfa6d59 100644
--- a/OpenSim/Region/Environment/EstateManager.cs
+++ b/OpenSim/Region/Environment/EstateManager.cs
@@ -137,13 +137,10 @@ namespace OpenSim.Region.Environment
137 { 137 {
138 // Water Height 138 // Water Height
139 m_regInfo.EstateSettings.waterHeight = WaterHeight; 139 m_regInfo.EstateSettings.waterHeight = WaterHeight;
140 m_scene.Terrain.watermap.Fill(WaterHeight);
141 140
142 // Terraforming limits 141 // Terraforming limits
143 m_regInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit; 142 m_regInfo.EstateSettings.terrainRaiseLimit = TerrainRaiseLimit;
144 m_regInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit; 143 m_regInfo.EstateSettings.terrainLowerLimit = TerrainLowerLimit;
145 m_scene.Terrain.maxRaise = TerrainRaiseLimit;
146 m_scene.Terrain.minLower = TerrainLowerLimit;
147 144
148 // Time of day / fixed sun 145 // Time of day / fixed sun
149 m_regInfo.EstateSettings.useFixedSun = UseFixedSun; 146 m_regInfo.EstateSettings.useFixedSun = UseFixedSun;
diff --git a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
index 62074cb..fb83e63 100644
--- a/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
+++ b/OpenSim/Region/Environment/Interfaces/ITerrainChannel.cs
@@ -34,6 +34,7 @@ namespace OpenSim.Region.Environment.Interfaces
34 double this[int x, int y] { get; set; } 34 double this[int x, int y] { get; set; }
35 int Width { get; } 35 int Width { get; }
36 float[] GetFloatsSerialised(); 36 float[] GetFloatsSerialised();
37 double[,] GetDoubles();
37 bool Tainted(int x, int y); 38 bool Tainted(int x, int y);
38 } 39 }
39} 40}
diff --git a/OpenSim/Region/Environment/LandManagement/Land.cs b/OpenSim/Region/Environment/LandManagement/Land.cs
index 1c4697c..4c6168d 100644
--- a/OpenSim/Region/Environment/LandManagement/Land.cs
+++ b/OpenSim/Region/Environment/LandManagement/Land.cs
@@ -440,11 +440,11 @@ namespace OpenSim.Region.Environment.LandManagement
440 } 440 }
441 } 441 }
442 landData.AABBMin = 442 landData.AABBMin =
443 new LLVector3((float) (min_x*4), (float) (min_y*4), 443 new LLVector3((float)(min_x * 4), (float)(min_y * 4),
444 (float) m_scene.Terrain.GetHeight((min_x*4), (min_y*4))); 444 (float)m_scene.Heightmap[(min_x * 4), (min_y * 4)]);
445 landData.AABBMax = 445 landData.AABBMax =
446 new LLVector3((float) (max_x*4), (float) (max_y*4), 446 new LLVector3((float)(max_x * 4), (float)(max_y * 4),
447 (float) m_scene.Terrain.GetHeight((max_x*4), (max_y*4))); 447 (float)m_scene.Heightmap[(max_x * 4), (max_y * 4)]);
448 landData.area = tempArea; 448 landData.area = tempArea;
449 } 449 }
450 450
diff --git a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
index 2cf77ff..7ab1e2b 100644
--- a/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/Environment/Modules/Terrain/TerrainModule.cs
@@ -96,6 +96,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
96 return heights; 96 return heights;
97 } 97 }
98 98
99 public double[,] GetDoubles()
100 {
101 return map;
102 }
103
99 public double this[int x, int y] 104 public double this[int x, int y]
100 { 105 {
101 get 106 get
@@ -104,14 +109,25 @@ namespace OpenSim.Region.Environment.Modules.Terrain
104 } 109 }
105 set 110 set
106 { 111 {
107 taint[x / 16, y / 16] = true; 112 if (map[x, y] != value)
108 map[x, y] = value; 113 {
114 taint[x / 16, y / 16] = true;
115 map[x, y] = value;
116 }
109 } 117 }
110 } 118 }
111 119
112 public bool Tainted(int x, int y) 120 public bool Tainted(int x, int y)
113 { 121 {
114 return taint[x / 16, y / 16]; 122 if (taint[x / 16, y / 16] != false)
123 {
124 taint[x / 16, y / 16] = false;
125 return true;
126 }
127 else
128 {
129 return false;
130 }
115 } 131 }
116 132
117 public TerrainChannel() 133 public TerrainChannel()
@@ -163,6 +179,7 @@ namespace OpenSim.Region.Environment.Modules.Terrain
163 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>(); 179 private Dictionary<string, ITerrainLoader> m_loaders = new Dictionary<string, ITerrainLoader>();
164 Scene m_scene; 180 Scene m_scene;
165 ITerrainChannel m_channel; 181 ITerrainChannel m_channel;
182 bool m_tainted = false;
166 private IConfigSource m_gConfig; 183 private IConfigSource m_gConfig;
167 184
168 private void InstallDefaultEffects() 185 private void InstallDefaultEffects()
@@ -241,6 +258,44 @@ namespace OpenSim.Region.Environment.Modules.Terrain
241 } 258 }
242 259
243 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 260 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
261 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
262 m_scene.EventManager.OnTerrainTick += EventManager_OnTerrainTick;
263 }
264
265 void EventManager_OnTerrainTick()
266 {
267 if (m_tainted)
268 {
269 m_tainted = false;
270 m_scene.PhysicsScene.SetTerrain(m_channel.GetFloatsSerialised());
271 m_scene.SaveTerrain();
272
273 //m_scene.CreateTerrainTexture(true);
274 }
275 }
276
277 void EventManager_OnPluginConsole(string[] args)
278 {
279 if (args[0] == "terrain")
280 {
281 string command = args[1];
282 string param = args[2];
283
284
285 switch (command)
286 {
287 case "load":
288 LoadFromFile(param);
289 SendUpdatedLayerData();
290 break;
291 case "save":
292 SaveToFile(param);
293 break;
294 default:
295 m_log.Warn("Unknown terrain command.");
296 break;
297 }
298 }
244 } 299 }
245 300
246 void EventManager_OnNewClient(IClientAPI client) 301 void EventManager_OnNewClient(IClientAPI client)
@@ -248,6 +303,31 @@ namespace OpenSim.Region.Environment.Modules.Terrain
248 client.OnModifyTerrain += client_OnModifyTerrain; 303 client.OnModifyTerrain += client_OnModifyTerrain;
249 } 304 }
250 305
306 void SendUpdatedLayerData()
307 {
308 bool shouldTaint = false;
309 float[] serialised = m_channel.GetFloatsSerialised();
310 int x, y;
311 for (x = 0; x < m_channel.Width; x += Constants.TerrainPatchSize)
312 {
313 for (y = 0; y < m_channel.Height; y += Constants.TerrainPatchSize)
314 {
315 if (m_channel.Tainted(x, y))
316 {
317 m_scene.ForEachClient(delegate(IClientAPI controller)
318 {
319 controller.SendLayerData(x / Constants.TerrainPatchSize, y / Constants.TerrainPatchSize, serialised);
320 });
321 shouldTaint = true;
322 }
323 }
324 }
325 if (shouldTaint)
326 {
327 m_tainted = true;
328 }
329 }
330
251 void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient) 331 void client_OnModifyTerrain(float height, float seconds, byte size, byte action, float north, float west, float south, float east, IClientAPI remoteClient)
252 { 332 {
253 // Not a good permissions check, if in area mode, need to check the entire area. 333 // Not a good permissions check, if in area mode, need to check the entire area.
@@ -261,11 +341,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
261 m_painteffects[(StandardTerrainEffects)action].PaintEffect( 341 m_painteffects[(StandardTerrainEffects)action].PaintEffect(
262 m_channel, west, south, Math.Pow(size, 2.0), seconds); 342 m_channel, west, south, Math.Pow(size, 2.0), seconds);
263 343
264 bool usingTerrainModule = false; 344 bool usingTerrainModule = true;
265 345
266 if (usingTerrainModule) 346 if (usingTerrainModule)
267 { 347 {
268 remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); 348 SendUpdatedLayerData();
269 } 349 }
270 } 350 }
271 else 351 else
@@ -298,11 +378,11 @@ namespace OpenSim.Region.Environment.Modules.Terrain
298 378
299 m_floodeffects[(StandardTerrainEffects)action].FloodEffect( 379 m_floodeffects[(StandardTerrainEffects)action].FloodEffect(
300 m_channel, fillArea, Math.Pow(size, 2.0)); 380 m_channel, fillArea, Math.Pow(size, 2.0));
301 bool usingTerrainModule = false; 381 bool usingTerrainModule = true;
302 382
303 if (usingTerrainModule) 383 if (usingTerrainModule)
304 { 384 {
305 remoteClient.SendLayerData(m_channel.GetFloatsSerialised()); 385 SendUpdatedLayerData();
306 } 386 }
307 } 387 }
308 else 388 else
diff --git a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
index edd4286..8aa2223 100644
--- a/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
+++ b/OpenSim/Region/Environment/Modules/TreePopulatorModule.cs
@@ -205,7 +205,7 @@ namespace OpenSim.Region.Environment.Modules
205 205
206 private void CreateTree(LLVector3 position) 206 private void CreateTree(LLVector3 position)
207 { 207 {
208 position.Z = (float)m_scene.Terrain.heightmap.Get((int)position.X, (int)position.Y); 208 position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
209 209
210 SceneObjectGroup tree = 210 SceneObjectGroup tree =
211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f), 211 m_scene.AddTree(new LLVector3(0.1f, 0.1f, 0.1f),
diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
index 20154ea..b269e75 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs
@@ -37,29 +37,6 @@ namespace OpenSim.Region.Environment.Scenes
37 public partial class Scene 37 public partial class Scene
38 { 38 {
39 /// <summary> 39 /// <summary>
40 /// Modifies terrain using the specified information
41 /// </summary>
42 /// <param name="height">The height at which the user started modifying the terrain</param>
43 /// <param name="seconds">The number of seconds the modify button was pressed</param>
44 /// <param name="brushsize">The size of the brush used</param>
45 /// <param name="action">The action to be performed</param>
46 /// <param name="north">Distance from the north border where the cursor is located</param>
47 /// <param name="west">Distance from the west border where the cursor is located</param>
48 public void ModifyTerrain(float height, float seconds, byte brushsize, byte action, float north, float west,
49 float south, float east,
50 IClientAPI remoteUser)
51 {
52 // Do a permissions check before allowing terraforming.
53 // random users are now no longer allowed to terraform
54 // if permissions are enabled.
55 if (!PermissionsMngr.CanTerraform(remoteUser.AgentId, new LLVector3(north, west, 0)))
56 return;
57
58 //if it wasn't for the permission checking we could have the terrain module directly subscribe to the OnModifyTerrain event
59 Terrain.ModifyTerrain(height, seconds, brushsize, action, north, west, south, east, remoteUser);
60 }
61
62 /// <summary>
63 /// 40 ///
64 /// </summary> 41 /// </summary>
65 /// <param name="message"></param> 42 /// <param name="message"></param>
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 29f1af4..ec1563a 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -283,9 +283,6 @@ namespace OpenSim.Region.Environment.Scenes
283 //m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>(); 283 //m_sceneObjects = new Dictionary<LLUUID, SceneObjectGroup>();
284 m_restorePresences = new Dictionary<LLUUID, ScenePresence>(); 284 m_restorePresences = new Dictionary<LLUUID, ScenePresence>();
285 285
286 m_log.Info("[SCENE]: Creating LandMap");
287 Terrain = new TerrainEngine((int)RegionInfo.RegionLocX, (int)RegionInfo.RegionLocY);
288
289 m_httpListener = httpServer; 286 m_httpListener = httpServer;
290 m_dumpAssetsToFile = dumpAssetsToFile; 287 m_dumpAssetsToFile = dumpAssetsToFile;
291 288
@@ -843,43 +840,7 @@ namespace OpenSim.Region.Environment.Scenes
843 840
844 private void UpdateTerrain() 841 private void UpdateTerrain()
845 { 842 {
846 if (Terrain.IsTainted() && !Terrain.IsUserStillEditing()) 843 EventManager.TriggerTerrainTick();
847 {
848 CreateTerrainTexture(true);
849
850 lock (Terrain.heightmap)
851 {
852 lock (SyncRoot)
853 {
854 PhysicsScene.SetTerrain(Terrain.GetHeights1D());
855 }
856
857 m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
858
859 SendTerrainUpdate(true);
860
861 Terrain.ResetTaint();
862 }
863 }
864 }
865
866 public void SendTerrainUpdate(bool checkForTainted)
867 {
868 float[] terData = Heightmap.GetFloatsSerialised();
869
870 Broadcast(delegate(IClientAPI client)
871 {
872 for (int x = 0; x < 16; x++)
873 {
874 for (int y = 0; y < 16; y++)
875 {
876 if ((!checkForTainted) || (Terrain.IsTainted(x * 16, y * 16)))
877 {
878 client.SendLayerData(x, y, terData);
879 }
880 }
881 }
882 });
883 } 844 }
884 845
885 private void UpdateStorageBackup() 846 private void UpdateStorageBackup()
@@ -963,14 +924,9 @@ namespace OpenSim.Region.Environment.Scenes
963 mapTexture.Save(fileName, ImageFormat.Jpeg); 924 mapTexture.Save(fileName, ImageFormat.Jpeg);
964 } 925 }
965 926
966 /// <summary> 927 public void SaveTerrain()
967 /// Loads a world map from a specified R32 file
968 /// </summary>
969 /// <param name="filename">A working R32 file</param>
970 public void LoadWorldMap(string filename)
971 { 928 {
972 Terrain.LoadFromFileF32(filename); 929 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
973 Terrain.SaveRevertMap();
974 } 930 }
975 931
976 /// <summary> 932 /// <summary>
@@ -984,37 +940,15 @@ namespace OpenSim.Region.Environment.Scenes
984 double[,] map = m_storageManager.DataStore.LoadTerrain(RegionInfo.RegionID); 940 double[,] map = m_storageManager.DataStore.LoadTerrain(RegionInfo.RegionID);
985 if (map == null) 941 if (map == null)
986 { 942 {
987 if (string.IsNullOrEmpty(m_regInfo.EstateSettings.terrainFile)) 943 m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain.");
988 { 944 Heightmap = new Modules.Terrain.TerrainChannel();
989 m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain.");
990 Terrain.SetDefaultTerrain();
991 945
992 m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID); 946 m_storageManager.DataStore.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
993 }
994 else
995 {
996 try
997 {
998 Terrain.LoadFromFileF32(m_regInfo.EstateSettings.terrainFile);
999 Terrain *= m_regInfo.EstateSettings.terrainMultiplier;
1000 }
1001 catch
1002 {
1003 m_log.Info("[TERRAIN]: No terrain found in database or default. Generating a new terrain.");
1004 Terrain.SetDefaultTerrain();
1005 }
1006 m_storageManager.DataStore.StoreTerrain(Terrain.GetHeights2DD(), RegionInfo.RegionID);
1007 }
1008 } 947 }
1009 else 948 else
1010 { 949 {
1011 // TODO: Install 'GetDefaultTerrainProvider' method here?
1012 Heightmap = new Modules.Terrain.TerrainChannel(map); 950 Heightmap = new Modules.Terrain.TerrainChannel(map);
1013 Terrain.SetHeights2D(map);
1014 } 951 }
1015
1016 CreateTerrainTexture(true);
1017 //CommsManager.GridService.RegisterRegion(RegionInfo); //hack to update the terrain texture in grid mode so it shows on world map
1018 } 952 }
1019 catch (Exception e) 953 catch (Exception e)
1020 { 954 {
@@ -1049,6 +983,8 @@ namespace OpenSim.Region.Environment.Scenes
1049 /// </summary> 983 /// </summary>
1050 public void CreateTerrainTexture(bool temporary) 984 public void CreateTerrainTexture(bool temporary)
1051 { 985 {
986 //TODOADAM: Move this to TerrainModule
987 /*
1052 //create a texture asset of the terrain 988 //create a texture asset of the terrain
1053 byte[] data = Terrain.WriteJpegImage("defaultstripe.png"); 989 byte[] data = Terrain.WriteJpegImage("defaultstripe.png");
1054 m_regInfo.EstateSettings.terrainImageID = LLUUID.Random(); 990 m_regInfo.EstateSettings.terrainImageID = LLUUID.Random();
@@ -1060,6 +996,7 @@ namespace OpenSim.Region.Environment.Scenes
1060 asset.Type = 0; 996 asset.Type = 0;
1061 asset.Temporary = temporary; 997 asset.Temporary = temporary;
1062 AssetCache.AddAsset(asset); 998 AssetCache.AddAsset(asset);
999 */
1063 } 1000 }
1064 1001
1065 #endregion 1002 #endregion
@@ -1382,7 +1319,6 @@ namespace OpenSim.Region.Environment.Scenes
1382 { 1319 {
1383 client.OnRegionHandShakeReply += SendLayerData; 1320 client.OnRegionHandShakeReply += SendLayerData;
1384 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims); 1321 //remoteClient.OnRequestWearables += new GenericCall(this.GetInitialPrims);
1385 client.OnModifyTerrain += ModifyTerrain;
1386 // client.OnRequestWearables += InformClientOfNeighbours; 1322 // client.OnRequestWearables += InformClientOfNeighbours;
1387 client.OnAddPrim += AddNewPrim; 1323 client.OnAddPrim += AddNewPrim;
1388 client.OnUpdatePrimGroupPosition += m_innerScene.UpdatePrimPosition; 1324 client.OnUpdatePrimGroupPosition += m_innerScene.UpdatePrimPosition;
@@ -2443,7 +2379,7 @@ namespace OpenSim.Region.Environment.Scenes
2443 2379
2444 public double GetLandHeight(int x, int y) 2380 public double GetLandHeight(int x, int y)
2445 { 2381 {
2446 return Terrain.GetHeight(x, y); 2382 return Heightmap[x, y];
2447 } 2383 }
2448 2384
2449 public LLUUID GetLandOwner(float x, float y) 2385 public LLUUID GetLandOwner(float x, float y)
diff --git a/OpenSim/Region/Environment/Scenes/SceneBase.cs b/OpenSim/Region/Environment/Scenes/SceneBase.cs
index 2a2dea1..12635c8 100644
--- a/OpenSim/Region/Environment/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneBase.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Environment.Scenes
58 protected string m_regionName; 58 protected string m_regionName;
59 protected RegionInfo m_regInfo; 59 protected RegionInfo m_regInfo;
60 60
61 public TerrainEngine Terrain; 61 //public TerrainEngine Terrain;
62 public ITerrainChannel Heightmap; 62 public ITerrainChannel Heightmap;
63 63
64 protected EventManager m_eventManager; 64 protected EventManager m_eventManager;
@@ -112,16 +112,7 @@ namespace OpenSim.Region.Environment.Scenes
112 /// <param name="RemoteClient">Client to send to</param> 112 /// <param name="RemoteClient">Client to send to</param>
113 public virtual void SendLayerData(IClientAPI RemoteClient) 113 public virtual void SendLayerData(IClientAPI RemoteClient)
114 { 114 {
115 bool usingTerrainModule = false; 115 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
116
117 if (usingTerrainModule)
118 {
119 RemoteClient.SendLayerData(Heightmap.GetFloatsSerialised());
120 }
121 else
122 {
123 RemoteClient.SendLayerData(Terrain.GetHeights1D());
124 }
125 } 116 }
126 117
127 #endregion 118 #endregion
diff --git a/OpenSim/Region/Environment/Scenes/SceneEvents.cs b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
index ac8f91e..5f8c977 100644
--- a/OpenSim/Region/Environment/Scenes/SceneEvents.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneEvents.cs
@@ -48,6 +48,10 @@ namespace OpenSim.Region.Environment.Scenes
48 48
49 public event ClientMovement OnClientMovement; 49 public event ClientMovement OnClientMovement;
50 50
51 public delegate void OnTerrainTickDelegate();
52
53 public event OnTerrainTickDelegate OnTerrainTick;
54
51 public delegate void OnBackupDelegate(IRegionDataStore datastore); 55 public delegate void OnBackupDelegate(IRegionDataStore datastore);
52 56
53 public event OnBackupDelegate OnBackup; 57 public event OnBackupDelegate OnBackup;
@@ -189,6 +193,7 @@ namespace OpenSim.Region.Environment.Scenes
189 private NewGridInstantMessage handlerGridInstantMessageToFriends = null; //OnGridInstantMessageToFriendsModule; 193 private NewGridInstantMessage handlerGridInstantMessageToFriends = null; //OnGridInstantMessageToFriendsModule;
190 private ClientClosed handlerClientClosed = null; //OnClientClosed; 194 private ClientClosed handlerClientClosed = null; //OnClientClosed;
191 private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent; 195 private OnNewPresenceDelegate handlerMakeChildAgent = null; //OnMakeChildAgent;
196 private OnTerrainTickDelegate handlerTerrainTick = null; // OnTerainTick;
192 197
193 public void TriggerOnScriptChangedEvent(uint localID, uint change) 198 public void TriggerOnScriptChangedEvent(uint localID, uint change)
194 { 199 {
@@ -277,6 +282,14 @@ namespace OpenSim.Region.Environment.Scenes
277 } 282 }
278 } 283 }
279 284
285 public void TriggerTerrainTick()
286 {
287 handlerTerrainTick = OnTerrainTick;
288 if (handlerTerrainTick != null)
289 {
290 handlerTerrainTick();
291 }
292 }
280 293
281 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) 294 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
282 { 295 {
diff --git a/OpenSim/Region/Environment/Scenes/SceneManager.cs b/OpenSim/Region/Environment/Scenes/SceneManager.cs
index 24f71af..3ad9342 100644
--- a/OpenSim/Region/Environment/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Environment/Scenes/SceneManager.cs
@@ -178,29 +178,8 @@ namespace OpenSim.Region.Environment.Scenes
178 178
179 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result) 179 public bool RunTerrainCmdOnCurrentScene(string[] cmdparams, ref string result)
180 { 180 {
181 if (m_currentScene == null) 181 m_log.Warn("Terrain commands have been depreciated.");
182 { 182 return false;
183 bool success = true;
184 foreach (Scene scene in m_localScenes)
185 {
186 if (!scene.Terrain.RunTerrainCmd(cmdparams, ref result, scene.RegionInfo.RegionName))
187 {
188 success = false;
189 }
190
191 // Messy way of preventing us printing out the same help text for each scene
192 if (cmdparams.Length <= 0 || cmdparams[0] == "help")
193 {
194 break;
195 }
196 }
197
198 return success;
199 }
200 else
201 {
202 return m_currentScene.Terrain.RunTerrainCmd(cmdparams, ref result, m_currentScene.RegionInfo.RegionName);
203 }
204 } 183 }
205 184
206 public void SendCommandToCurrentSceneScripts(string[] cmdparams) 185 public void SendCommandToCurrentSceneScripts(string[] cmdparams)
diff --git a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
index 66727d9..ef0d4d0 100644
--- a/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
+++ b/OpenSim/Region/Examples/SimpleApp/MyWorld.cs
@@ -54,15 +54,7 @@ namespace SimpleApp
54 54
55 public override void LoadWorldMap() 55 public override void LoadWorldMap()
56 { 56 {
57 float[] map = new float[65536];
58 57
59 for (int i = 0; i < 65536; i++)
60 {
61 map[i] = 25f;
62 }
63
64 Terrain.GetHeights1D(map);
65 CreateTerrainTexture(true);
66 } 58 }
67 59
68 public override void AddNewClient(IClientAPI client, bool child) 60 public override void AddNewClient(IClientAPI client, bool child)
diff --git a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
index d516aa5..9c7f868 100644
--- a/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
+++ b/OpenSim/Region/ScriptEngine/Common/LSL_BuiltIn_Commands.cs
@@ -1851,61 +1851,7 @@ namespace OpenSim.Region.ScriptEngine.Common
1851 double dsize; 1851 double dsize;
1852 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0))) 1852 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, 0)))
1853 { 1853 {
1854 switch (brush) 1854 NotImplemented("llModifyLand");
1855 {
1856 case 1:
1857 dsize = 2;
1858 break;
1859 case 2:
1860 dsize = 4;
1861 break;
1862 case 3:
1863 dsize = 8;
1864 break;
1865 default:
1866 if (brush < 0)
1867 {
1868 dsize = (double)(-1 * brush);
1869 }
1870 else
1871 {
1872 LSLError("Invalid brush size");
1873 dsize = 0; // Should cease execution, but get unassigned local variable dsize on compile.
1874 }
1875 break;
1876 }
1877 switch (action)
1878 {
1879 case 0:
1880 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) < m_host.AbsolutePosition.Z)
1881 {
1882 World.Terrain.FlattenTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1883 }
1884 break;
1885 case 1:
1886 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) < (double)m_host.AbsolutePosition.Z)
1887 {
1888 World.Terrain.RaiseTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 0.1);
1889 }
1890 break;
1891 case 2:
1892 if (World.Terrain.GetHeight((int)m_host.AbsolutePosition.X, (int)m_host.AbsolutePosition.Y) > 0)
1893 {
1894 World.Terrain.LowerTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1895 }
1896 break;
1897 case 3:
1898 World.Terrain.SmoothTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1899 break;
1900 case 4:
1901 World.Terrain.NoiseTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1902 break;
1903 case 5:
1904 World.Terrain.RevertTerrain(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y, dsize, 1);
1905 break;
1906 default:
1907 break;
1908 }
1909 } 1855 }
1910 } 1856 }
1911 1857
@@ -4162,7 +4108,7 @@ namespace OpenSim.Region.ScriptEngine.Common
4162 4108
4163 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0))) 4109 if (World.PermissionsMngr.CanTerraform(m_host.OwnerID, new LLVector3(x, y, 0)))
4164 { 4110 {
4165 World.Terrain.Set(x, y, val); 4111 World.Heightmap[x, y] = val;
4166 return 1; 4112 return 1;
4167 } 4113 }
4168 else 4114 else
@@ -4177,7 +4123,7 @@ namespace OpenSim.Region.ScriptEngine.Common
4177 if (x > 255 || x < 0 || y > 255 || y < 0) 4123 if (x > 255 || x < 0 || y > 255 || y < 0)
4178 LSLError("osTerrainGetHeight: Coordinate out of bounds"); 4124 LSLError("osTerrainGetHeight: Coordinate out of bounds");
4179 4125
4180 return World.Terrain.GetHeight(x, y); 4126 return World.Heightmap[x, y];
4181 } 4127 }
4182 4128
4183 public int osRegionRestart(double seconds) 4129 public int osRegionRestart(double seconds)
diff --git a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
index c6feb03..78764fe 100644
--- a/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
+++ b/OpenSim/Region/Terrain.BasicTerrain/TerrainEngine.cs
@@ -299,7 +299,7 @@ namespace OpenSim.Region.Terrain
299 { 299 {
300 if (IsTainted(x * 16, y * 16)) 300 if (IsTainted(x * 16, y * 16))
301 { 301 {
302 bool usingTerrainModule = false; 302 bool usingTerrainModule = true;
303 303
304 if (!usingTerrainModule) 304 if (!usingTerrainModule)
305 { 305 {