aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs21
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs10
-rw-r--r--OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs13
-rwxr-xr-xOpenSim/Region/Framework/Scenes/Scene.cs62
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs1
5 files changed, 86 insertions, 21 deletions
diff --git a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
index 69fa5f6..e21681d 100644
--- a/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
+++ b/OpenSim/Region/CoreModules/World/Terrain/TerrainModule.cs
@@ -231,20 +231,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
231 // Install terrain module in the simulator 231 // Install terrain module in the simulator
232 lock(m_scene) 232 lock(m_scene)
233 { 233 {
234 if(m_scene.Bakedmap != null)
235 {
236 m_baked = m_scene.Bakedmap;
237 }
234 if (m_scene.Heightmap == null) 238 if (m_scene.Heightmap == null)
235 { 239 {
236 m_channel = new TerrainChannel(m_InitialTerrain, (int)m_scene.RegionInfo.RegionSizeX, 240 if(m_baked != null)
237 (int)m_scene.RegionInfo.RegionSizeY, 241 m_channel = m_baked.MakeCopy();
238 (int)m_scene.RegionInfo.RegionSizeZ); 242 else
243 m_channel = new TerrainChannel(m_InitialTerrain,
244 (int)m_scene.RegionInfo.RegionSizeX,
245 (int)m_scene.RegionInfo.RegionSizeY,
246 (int)m_scene.RegionInfo.RegionSizeZ);
239 m_scene.Heightmap = m_channel; 247 m_scene.Heightmap = m_channel;
240
241 UpdateBakedMap();
242 } 248 }
243 else 249 else
244 { 250 {
245 m_channel = m_scene.Heightmap; 251 m_channel = m_scene.Heightmap;
246 UpdateBakedMap();
247 } 252 }
253 if(m_baked == null)
254 UpdateBakedMap();
248 255
249 m_scene.RegisterModuleInterface<ITerrainModule>(this); 256 m_scene.RegisterModuleInterface<ITerrainModule>(this);
250 m_scene.EventManager.OnNewClient += EventManager_OnNewClient; 257 m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
@@ -724,6 +731,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
724 m_baked = m_channel.MakeCopy(); 731 m_baked = m_channel.MakeCopy();
725 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked); 732 m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
726 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked); 733 m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
734 m_scene.Bakedmap = m_baked;
735 m_scene.SaveBakedTerrain();
727 } 736 }
728 737
729 /// <summary> 738 /// <summary>
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
index 13358cb..f8a6b53 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataService.cs
@@ -64,12 +64,19 @@ namespace OpenSim.Region.Framework.Interfaces
64 List<SceneObjectGroup> LoadObjects(UUID regionUUID); 64 List<SceneObjectGroup> LoadObjects(UUID regionUUID);
65 65
66 /// <summary> 66 /// <summary>
67 /// Store a terrain revision in region storage 67 /// Store terrain in region storage
68 /// </summary> 68 /// </summary>
69 /// <param name="ter">HeightField data</param> 69 /// <param name="ter">HeightField data</param>
70 /// <param name="regionID">region UUID</param> 70 /// <param name="regionID">region UUID</param>
71 void StoreTerrain(TerrainData terrain, UUID regionID); 71 void StoreTerrain(TerrainData terrain, UUID regionID);
72 72
73 /// <summary>
74 /// Store baked terrain in region storage
75 /// </summary>
76 /// <param name="ter">HeightField data</param>
77 /// <param name="regionID">region UUID</param>
78 void StoreBakedTerrain(TerrainData terrain, UUID regionID);
79
73 // Legacy version kept for downward compabibility 80 // Legacy version kept for downward compabibility
74 void StoreTerrain(double[,] terrain, UUID regionID); 81 void StoreTerrain(double[,] terrain, UUID regionID);
75 82
@@ -82,6 +89,7 @@ namespace OpenSim.Region.Framework.Interfaces
82 /// <param name="sizeZ">the Z dimension of the region being filled</param> 89 /// <param name="sizeZ">the Z dimension of the region being filled</param>
83 /// <returns>Heightfield data</returns> 90 /// <returns>Heightfield data</returns>
84 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ); 91 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
92 TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
85 93
86 // Legacy version kept for downward compabibility 94 // Legacy version kept for downward compabibility
87 double[,] LoadTerrain(UUID regionID); 95 double[,] LoadTerrain(UUID regionID);
diff --git a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
index e09f775..8536db0 100644
--- a/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
+++ b/OpenSim/Region/Framework/Interfaces/ISimulationDataStore.cs
@@ -75,17 +75,25 @@ namespace OpenSim.Region.Framework.Interfaces
75 List<SceneObjectGroup> LoadObjects(UUID regionUUID); 75 List<SceneObjectGroup> LoadObjects(UUID regionUUID);
76 76
77 /// <summary> 77 /// <summary>
78 /// Store a terrain revision in region storage 78 /// Store a terrain in region storage
79 /// </summary> 79 /// </summary>
80 /// <param name="ter">HeightField data</param> 80 /// <param name="ter">HeightField data</param>
81 /// <param name="regionID">region UUID</param> 81 /// <param name="regionID">region UUID</param>
82 void StoreTerrain(TerrainData terrain, UUID regionID); 82 void StoreTerrain(TerrainData terrain, UUID regionID);
83 83
84 /// <summary>
85 /// Store baked terrain in region storage
86 /// </summary>
87 /// <param name="ter">HeightField data</param>
88 /// <param name="regionID">region UUID</param>
89 void StoreBakedTerrain(TerrainData terrain, UUID regionID);
90
91
84 // Legacy version kept for downward compabibility 92 // Legacy version kept for downward compabibility
85 void StoreTerrain(double[,] terrain, UUID regionID); 93 void StoreTerrain(double[,] terrain, UUID regionID);
86 94
87 /// <summary> 95 /// <summary>
88 /// Load the latest terrain revision from region storage 96 /// Load terrain from region storage
89 /// </summary> 97 /// </summary>
90 /// <param name="regionID">the region UUID</param> 98 /// <param name="regionID">the region UUID</param>
91 /// <param name="pSizeX">the X dimension of the terrain being filled</param> 99 /// <param name="pSizeX">the X dimension of the terrain being filled</param>
@@ -93,6 +101,7 @@ namespace OpenSim.Region.Framework.Interfaces
93 /// <param name="pSizeZ">the Z dimension of the terrain being filled</param> 101 /// <param name="pSizeZ">the Z dimension of the terrain being filled</param>
94 /// <returns>Heightfield data</returns> 102 /// <returns>Heightfield data</returns>
95 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ); 103 TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
104 TerrainData LoadBakedTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ);
96 105
97 // Legacy version kept for downward compabibility 106 // Legacy version kept for downward compabibility
98 double[,] LoadTerrain(UUID regionID); 107 double[,] LoadTerrain(UUID regionID);
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d77b8ae..168080f 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2172,7 +2172,16 @@ namespace OpenSim.Region.Framework.Scenes
2172 /// </summary> 2172 /// </summary>
2173 public void SaveTerrain() 2173 public void SaveTerrain()
2174 { 2174 {
2175 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2175 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2176 }
2177
2178 /// <summary>
2179 /// Store the terrain in the persistant data store
2180 /// </summary>
2181 public void SaveBakedTerrain()
2182 {
2183 if(Bakedmap != null)
2184 SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
2176 } 2185 }
2177 2186
2178 public void StoreWindlightProfile(RegionLightShareData wl) 2187 public void StoreWindlightProfile(RegionLightShareData wl)
@@ -2195,20 +2204,44 @@ namespace OpenSim.Region.Framework.Scenes
2195 { 2204 {
2196 try 2205 try
2197 { 2206 {
2207 Bakedmap = null;
2208 TerrainData map = SimulationDataService.LoadBakedTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2209 if (map != null)
2210 {
2211 Bakedmap = new TerrainChannel(map);
2212 }
2213 }
2214 catch (Exception e)
2215 {
2216 m_log.WarnFormat(
2217 "[TERRAIN]: Scene.cs: LoadWorldMap() baked terrain - Failed with exception {0}{1}", e.Message, e.StackTrace);
2218 }
2219
2220 try
2221 {
2198 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); 2222 TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2199 if (map == null) 2223 if (map == null)
2200 { 2224 {
2201 // This should be in the Terrain module, but it isn't because 2225 if(Bakedmap != null)
2202 // the heightmap is needed _way_ before the modules are initialized... 2226 {
2203 IConfig terrainConfig = m_config.Configs["Terrain"]; 2227 m_log.Warn("[TERRAIN]: terrain not found. Used stored baked terrain.");
2204 String m_InitialTerrain = "pinhead-island"; 2228 Heightmap = Bakedmap.MakeCopy();
2205 if (terrainConfig != null) 2229 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2206 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); 2230 }
2231 else
2232 {
2233 // This should be in the Terrain module, but it isn't because
2234 // the heightmap is needed _way_ before the modules are initialized...
2235 IConfig terrainConfig = m_config.Configs["Terrain"];
2236 String m_InitialTerrain = "pinhead-island";
2237 if (terrainConfig != null)
2238 m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
2207 2239
2208 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain); 2240 m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
2209 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); 2241 Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
2210 2242
2211 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2243 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2244 }
2212 } 2245 }
2213 else 2246 else
2214 { 2247 {
@@ -2221,13 +2254,12 @@ namespace OpenSim.Region.Framework.Scenes
2221 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}", 2254 "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
2222 e.Message, e.StackTrace); 2255 e.Message, e.StackTrace);
2223 2256
2224 // Non standard region size. If there's an old terrain in the database, it might read past the buffer
2225#pragma warning disable 0162 2257#pragma warning disable 0162
2226 if ((int)Constants.RegionSize != 256) 2258 if ((int)Constants.RegionSize != 256)
2227 { 2259 {
2228 Heightmap = new TerrainChannel(); 2260 Heightmap = new TerrainChannel();
2229 2261
2230 SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); 2262 SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
2231 } 2263 }
2232 } 2264 }
2233 catch (Exception e) 2265 catch (Exception e)
@@ -2235,6 +2267,12 @@ namespace OpenSim.Region.Framework.Scenes
2235 m_log.WarnFormat( 2267 m_log.WarnFormat(
2236 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace); 2268 "[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
2237 } 2269 }
2270
2271 if(Bakedmap == null && Heightmap != null)
2272 {
2273 Bakedmap = Heightmap.MakeCopy();
2274 SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
2275 }
2238 } 2276 }
2239 2277
2240 /// <summary> 2278 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index f420f69..1de55ec 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes
153 } 153 }
154 154
155 public ITerrainChannel Heightmap; 155 public ITerrainChannel Heightmap;
156 public ITerrainChannel Bakedmap;
156 157
157 /// <value> 158 /// <value>
158 /// Allows retrieval of land information for this scene. 159 /// Allows retrieval of land information for this scene.