refactor: move more map tile generation code from scene to IWorldMapModule
parent
39a748b47a
commit
5f5c65e4ba
|
@ -347,9 +347,13 @@ namespace OpenSim
|
||||||
// Prims have to be loaded after module configuration since some modules may be invoked during the load
|
// Prims have to be loaded after module configuration since some modules may be invoked during the load
|
||||||
scene.LoadPrimsFromStorage(regionInfo.originRegionID);
|
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.
|
// 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
|
// TODO : Try setting resource for region xstats here on scene
|
||||||
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
|
MainServer.Instance.AddStreamHandler(new Region.Framework.Scenes.RegionStatsHandler(regionInfo));
|
||||||
|
|
|
@ -1000,11 +1000,24 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
||||||
return responsemap;
|
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;
|
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();
|
m_scene.RegionInfo.RegionSettings.TerrainImageID = UUID.Random();
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
{
|
{
|
||||||
public interface IWorldMapModule
|
public interface IWorldMapModule
|
||||||
{
|
{
|
||||||
void RegenerateMaptile(byte[] data);
|
/// <summary>
|
||||||
|
/// Generate a map tile for the scene. a terrain texture for this scene
|
||||||
|
/// </summary>
|
||||||
|
void GenerateMaptile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
#endregion
|
||||||
|
|
||||||
#region Load Land
|
#region Load Land
|
||||||
|
|
Loading…
Reference in New Issue