From 5f5c65e4bae1f2a84d6972697d0413137f6b1da1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 13 Aug 2010 20:34:46 +0100 Subject: refactor: move more map tile generation code from scene to IWorldMapModule --- OpenSim/Region/Application/OpenSimBase.cs | 8 +++++-- .../CoreModules/World/WorldMap/WorldMapModule.cs | 17 ++++++++++++-- .../Region/Framework/Interfaces/IWorldMapModule.cs | 5 +++- OpenSim/Region/Framework/Scenes/Scene.cs | 27 ---------------------- 4 files changed, 25 insertions(+), 32 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index f535fe8..e148cde 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -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(); + 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)); diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 9d9967a..f036d85 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs @@ -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(); + 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(); diff --git a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs index ac6afed..d6e31f4 100644 --- a/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IWorldMapModule.cs @@ -29,6 +29,9 @@ namespace OpenSim.Region.Framework.Interfaces { public interface IWorldMapModule { - void RegenerateMaptile(byte[] data); + /// + /// Generate a map tile for the scene. a terrain texture for this scene + /// + void GenerateMaptile(); } } diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index afdb95b..4d5c1e7 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs @@ -1812,33 +1812,6 @@ namespace OpenSim.Region.Framework.Scenes } - /// - /// Create a terrain texture for this scene - /// - public void CreateTerrainTexture() - { - //create a texture asset of the terrain - IMapImageGenerator terrain = RequestModuleInterface(); - - // 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(); - - if (mapModule != null) - mapModule.RegenerateMaptile(data); - else - m_log.DebugFormat("[SCENE]: MapModule is null, can't save maptile"); - } - } - #endregion #region Load Land -- cgit v1.1