add rest of wiring for terrain bake persistent store (mantis 8024 but not

using its code). Only did minor testing in MySQL
LSLKeyTest
UbitUmarov 2016-09-17 17:56:35 +01:00
parent 47ce0f8641
commit 592a915d8d
3 changed files with 64 additions and 16 deletions

View File

@ -231,20 +231,27 @@ namespace OpenSim.Region.CoreModules.World.Terrain
// Install terrain module in the simulator // Install terrain module in the simulator
lock(m_scene) lock(m_scene)
{ {
if(m_scene.Bakedmap != null)
{
m_baked = m_scene.Bakedmap;
}
if (m_scene.Heightmap == null) if (m_scene.Heightmap == null)
{ {
m_channel = new TerrainChannel(m_InitialTerrain, (int)m_scene.RegionInfo.RegionSizeX, if(m_baked != null)
(int)m_scene.RegionInfo.RegionSizeY, m_channel = m_baked.MakeCopy();
(int)m_scene.RegionInfo.RegionSizeZ); else
m_channel = new TerrainChannel(m_InitialTerrain,
(int)m_scene.RegionInfo.RegionSizeX,
(int)m_scene.RegionInfo.RegionSizeY,
(int)m_scene.RegionInfo.RegionSizeZ);
m_scene.Heightmap = m_channel; m_scene.Heightmap = m_channel;
UpdateBakedMap();
} }
else else
{ {
m_channel = m_scene.Heightmap; m_channel = m_scene.Heightmap;
UpdateBakedMap();
} }
if(m_baked == null)
UpdateBakedMap();
m_scene.RegisterModuleInterface<ITerrainModule>(this); m_scene.RegisterModuleInterface<ITerrainModule>(this);
m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnNewClient += EventManager_OnNewClient;
@ -724,6 +731,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
m_baked = m_channel.MakeCopy(); m_baked = m_channel.MakeCopy();
m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked); m_painteffects[StandardTerrainEffects.Revert] = new RevertSphere(m_baked);
m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked); m_floodeffects[StandardTerrainEffects.Revert] = new RevertArea(m_baked);
m_scene.Bakedmap = m_baked;
m_scene.SaveBakedTerrain();
} }
/// <summary> /// <summary>

View File

@ -2175,6 +2175,15 @@ namespace OpenSim.Region.Framework.Scenes
SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID); SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
} }
/// <summary>
/// Store the terrain in the persistant data store
/// </summary>
public void SaveBakedTerrain()
{
if(Bakedmap != null)
SimulationDataService.StoreBakedTerrain(Bakedmap.GetTerrainData(), RegionInfo.RegionID);
}
public void StoreWindlightProfile(RegionLightShareData wl) public void StoreWindlightProfile(RegionLightShareData wl)
{ {
RegionInfo.WindlightSettings = wl; RegionInfo.WindlightSettings = wl;
@ -2193,22 +2202,46 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary> /// </summary>
public override void LoadWorldMap() public override void LoadWorldMap()
{ {
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 try
{ {
TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ); TerrainData map = SimulationDataService.LoadTerrain(RegionInfo.RegionID, (int)RegionInfo.RegionSizeX, (int)RegionInfo.RegionSizeY, (int)RegionInfo.RegionSizeZ);
if (map == null) if (map == null)
{ {
// This should be in the Terrain module, but it isn't because if(Bakedmap != null)
// the heightmap is needed _way_ before the modules are initialized... {
IConfig terrainConfig = m_config.Configs["Terrain"]; m_log.Warn("[TERRAIN]: terrain not found. Used stored baked terrain.");
String m_InitialTerrain = "pinhead-island"; Heightmap = Bakedmap.MakeCopy();
if (terrainConfig != null) SimulationDataService.StoreTerrain(Heightmap.GetTerrainData(), RegionInfo.RegionID);
m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain); }
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); 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); 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 else
{ {
@ -2221,7 +2254,6 @@ namespace OpenSim.Region.Framework.Scenes
"[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}", "[TERRAIN]: Scene.cs: LoadWorldMap() - Regenerating as failed with exception {0}{1}",
e.Message, e.StackTrace); 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 #pragma warning disable 0162
if ((int)Constants.RegionSize != 256) if ((int)Constants.RegionSize != 256)
{ {
@ -2235,6 +2267,12 @@ namespace OpenSim.Region.Framework.Scenes
m_log.WarnFormat( m_log.WarnFormat(
"[TERRAIN]: Scene.cs: LoadWorldMap() - Failed with exception {0}{1}", e.Message, e.StackTrace); "[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);
}
} }
/// <summary> /// <summary>

View File

@ -153,6 +153,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
public ITerrainChannel Heightmap; public ITerrainChannel Heightmap;
public ITerrainChannel Bakedmap;
/// <value> /// <value>
/// Allows retrieval of land information for this scene. /// Allows retrieval of land information for this scene.