diff options
author | Adam Frisby | 2008-03-06 15:49:53 +0000 |
---|---|---|
committer | Adam Frisby | 2008-03-06 15:49:53 +0000 |
commit | a3601165029f8484988b5c322798a341ff1e9400 (patch) | |
tree | 4b761e7d0694dffb0b67018915fc240e7bbaa154 /OpenSim/Region/Environment/Scenes | |
parent | * Killed 4 more warnings (at 16 now) (diff) | |
download | opensim-SC-a3601165029f8484988b5c322798a341ff1e9400.zip opensim-SC-a3601165029f8484988b5c322798a341ff1e9400.tar.gz opensim-SC-a3601165029f8484988b5c322798a341ff1e9400.tar.bz2 opensim-SC-a3601165029f8484988b5c322798a341ff1e9400.tar.xz |
* Disabled ancient TerrainEngine.
* Enabled new TerrainModule. (The king is dead, long live the king!)
* Use the console command: "script terrain save file.r32" / "script terrain load file.r32" to load/save terrain. Now uses the extension to determine file format.
* MANY of the old terrain features do not have a replacement function in the new module yet, this needs to be corrected, but has not been done so far. This being said, the new module is faster and more efficient and should be a good replacement.
Diffstat (limited to 'OpenSim/Region/Environment/Scenes')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs | 23 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 84 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneBase.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneEvents.cs | 13 | ||||
-rw-r--r-- | OpenSim/Region/Environment/Scenes/SceneManager.cs | 25 |
5 files changed, 27 insertions, 131 deletions
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) |