diff options
Diffstat (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs')
-rw-r--r-- | OpenSim/Region/Environment/Scenes/Scene.cs | 84 |
1 files changed, 10 insertions, 74 deletions
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) |