From 592a915d8d9335784998d02418d1eee757f76350 Mon Sep 17 00:00:00 2001
From: UbitUmarov
Date: Sat, 17 Sep 2016 17:56:35 +0100
Subject: add rest of wiring for terrain bake persistent store (mantis 8024
but not using its code). Only did minor testing in MySQL
---
OpenSim/Region/Framework/Scenes/Scene.cs | 58 +++++++++++++++++++++++-----
OpenSim/Region/Framework/Scenes/SceneBase.cs | 1 +
2 files changed, 49 insertions(+), 10 deletions(-)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index f7bfc24..168080f 100755
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -2175,6 +2175,15 @@ namespace OpenSim.Region.Framework.Scenes
SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
}
+ ///
+ /// Store the terrain in the persistant data store
+ ///
+ public void SaveBakedTerrain()
+ {
+ if(Bakedmap != null)
+ SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
+ }
+
public void StoreWindlightProfile(RegionLightShareData wl)
{
RegionInfo.WindlightSettings = wl;
@@ -2195,20 +2204,44 @@ namespace OpenSim.Region.Framework.Scenes
{
try
{
+ Bakedmap = null;
+ TerrainData map = SimulationDataService.LoadBakedTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
+ if (map != null)
+ {
+ Bakedmap = new TerrainChannel(map);
+ }
+ }
+ catch (Exception e)
+ {
+ m_log.WarnFormat(
+ "[TERRAIN]: Scene.cs: LoadWorldMap() baked terrain - Failed with exception {0}{1}", e.Message, e.StackTrace);
+ }
+
+ try
+ {
TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
if (map == null)
{
- // This should be in the Terrain module, but it isn't because
- // the heightmap is needed _way_ before the modules are initialized...
- IConfig terrainConfig = m_config.Configs["Terrain"];
- String m_InitialTerrain = "pinhead-island";
- if (terrainConfig != null)
- m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
+ if(Bakedmap != null)
+ {
+ m_log.Warn("[TERRAIN]: terrain not found. Used stored baked terrain.");
+ Heightmap = Bakedmap.MakeCopy();
+ SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
+ }
+ else
+ {
+ // This should be in the Terrain module, but it isn't because
+ // the heightmap is needed _way_ before the modules are initialized...
+ IConfig terrainConfig = m_config.Configs["Terrain"];
+ String m_InitialTerrain = "pinhead-island";
+ if (terrainConfig != null)
+ m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
- m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
- Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
+ m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
+ Heightmap = new TerrainChannel(m_InitialTerrain, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
- SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
+ SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
+ }
}
else
{
@@ -2221,7 +2254,6 @@ namespace OpenSim.Region.Framework.Scenes
"[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
e.Message, e.StackTrace);
- // Non standard region size. If there's an old terrain in the database, it might read past the buffer
#pragma warning disable 0162
if ((int)Constants.RegionSize != 256)
{
@@ -2235,6 +2267,12 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat(
"[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace);
}
+
+ if(Bakedmap == null && Heightmap != null)
+ {
+ Bakedmap = Heightmap.MakeCopy();
+ SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
+ }
}
///
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
}
public ITerrainChannel Heightmap;
+ public ITerrainChannel Bakedmap;
///
/// Allows retrieval of land information for this scene.
--
cgit v1.1