refactor: move more map tile generation code from scene to IWorldMapModule

prebuild-update
Justin Clark-Casey (justincc) 2010-08-13 20:34:46 +01:00
parent 39a748b47a
commit 5f5c65e4ba
4 changed files with 25 additions and 32 deletions

View File

@ -347,9 +347,13 @@ namespace OpenSim
// Prims have to be loaded after module configuration since some modules may be invoked during the load
scene.LoadPrimsFromStorage(regionInfo.originRegionID);
// moved these here as the terrain texture has to be created after the modules are initialized
// moved these here as the map texture has to be created after the modules are initialized
// and has to happen before the region is registered with the grid.
scene.CreateTerrainTexture();
IWorldMapModule mapModule = scene.RequestModuleInterface<IWorldMapModule>();
if (mapModule != null)
mapModule.GenerateMaptile();
else
m_log.WarnFormat("[STARTUP]: No map module available to generate map tile");
// TODO : Try setting resource for region xstats here on scene
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));

View File

@ -1000,11 +1000,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
return responsemap;
}
public void RegenerateMaptile(byte[] data)
public void GenerateMaptile()
{
// Cannot create a map for a nonexistant heightmap
if (m_scene.Heightmap == null)
return;
//create a texture asset of the terrain
IMapImageGenerator terrain = m_scene.RequestModuleInterface<IMapImageGenerator>();
if (terrain == null)
return;
byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png");
if (data == null)
return;
UUID lastMapRegionUUID = m_scene.RegionInfo.RegionSettings.TerrainImageID;
m_log.Debug("[MAPTILE]: STORING MAPTILE IMAGE");
m_log.Debug("[WORLDMAP]: STORING MAPTILE IMAGE");
m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();

View File

@ -29,6 +29,9 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface IWorldMapModule
{
void RegenerateMaptile(byte[] data);
/// <summary>
/// Generate a map tile for the scene. a terrain texture for this scene
/// </summary>
void GenerateMaptile();
}
}

View File

@ -1812,33 +1812,6 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
/// Create a terrain texture for this scene
/// </summary>
public void CreateTerrainTexture()
{
//create a texture asset of the terrain
IMapImageGenerator terrain = RequestModuleInterface<IMapImageGenerator>();
// Cannot create a map for a nonexistant heightmap yet.
if (Heightmap == null)
return;
if (terrain == null)
return;
byte[] data = terrain.WriteJpeg2000Image("defaultstripe.png");
if (data != null)
{
IWorldMapModule mapModule = RequestModuleInterface<IWorldMapModule>();
if (mapModule != null)
mapModule.RegenerateMaptile(data);
else
m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile");
}
}
#endregion
#region Load Land