Warp3D map now seems to work

avinationmerge
UbitUmarov 2015-08-22 16:35:49 +01:00
parent d22d46ee96
commit 5da9979024
3 changed files with 51 additions and 15 deletions

View File

@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
/// </remarks> /// </remarks>
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")]
public class MapImageServiceModule : ISharedRegionModule, IMapTileModule public class MapImageServiceModule : ISharedRegionModule, IMapTileModule
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@ -204,7 +204,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
{ {
ConvertAndUploadMaptile(mapTile, scene, ConvertAndUploadMaptile(mapTile, scene,
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY); scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
scene.RegionInfo.RegionName);
} }
else else
{ {
@ -226,8 +227,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
{ {
ConvertAndUploadMaptile(subMapTile, scene, ConvertAndUploadMaptile(subMapTile, scene,
scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize) scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
); scene.Name);
} }
} }
} }
@ -260,7 +261,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
} }
} }
private void ConvertAndUploadMaptile(Image tileImage, IScene scene, uint locX, uint locY) private void ConvertAndUploadMaptile(Image tileImage, IScene scene, uint locX, uint locY, string regionName)
{ {
byte[] jpgData = Utils.EmptyBytes; byte[] jpgData = Utils.EmptyBytes;
@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason))
{ {
m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader,
scene.RegionInfo.RegionName, locX, locY, reason); regionName, locX, locY, reason);
} }
} }
else else

View File

@ -72,6 +72,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false);
private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>();
private IMapImageGenerator m_mapImageGenerator;
private IMapTileModule m_mapImageServiceModule;
protected Scene m_scene; protected Scene m_scene;
private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
private int cachedTime = 0; private int cachedTime = 0;
@ -139,6 +142,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public virtual void RegionLoaded (Scene scene) public virtual void RegionLoaded (Scene scene)
{ {
if (!m_Enabled)
return;
m_mapImageGenerator = m_scene.RequestModuleInterface<IMapImageGenerator>();
m_mapImageServiceModule = m_scene.RequestModuleInterface<IMapTileModule>();
} }
@ -1391,7 +1399,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
if (consoleScene != null && consoleScene != m_scene) if (consoleScene != null && consoleScene != m_scene)
return; return;
GenerateMaptile(); if (m_mapImageGenerator == null)
{
Console.WriteLine("No map image generator available for {0}", m_scene.Name);
return;
}
using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
{
GenerateMaptile(mapbmp);
// m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
}
} }
public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint)
@ -1514,20 +1532,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
public void GenerateMaptile() public void GenerateMaptile()
{ {
// Cannot create a map for a nonexistant heightmap // Cannot create a map for a nonexistent heightmap
if (m_scene.Heightmap == null) if (m_scene.Heightmap == null)
return; return;
//create a texture asset of the terrain m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name);
IMapImageGenerator terrain = m_scene.RequestModuleInterface<IMapImageGenerator>();
if (terrain == null)
return;
m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName); using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile())
{
// V1 (This Module)
GenerateMaptile(mapbmp);
byte[] data = terrain.WriteJpeg2000Image(); // v2/3 (MapImageServiceModule)
if (data == null) m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp);
}
}
private void GenerateMaptile(Bitmap mapbmp)
{
byte[] data;
try
{
data = OpenJPEG.EncodeFromImage(mapbmp, true);
}
catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke
{
m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e);
return; return;
}
byte[] overlay = GenerateOverlay(); byte[] overlay = GenerateOverlay();

View File

@ -27,6 +27,7 @@
using OpenMetaverse; using OpenMetaverse;
using OpenSim.Framework; using OpenSim.Framework;
using System.Drawing;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
{ {
@ -36,5 +37,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// Upload a new maptile /// Upload a new maptile
/// </summary> /// </summary>
void UploadMapTile(IScene scene); void UploadMapTile(IScene scene);
void UploadMapTile(IScene scene, Bitmap mapTile);
} }
} }