Warp3D map now seems to work
parent
d22d46ee96
commit
5da9979024
|
@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
|||
/// </remarks>
|
||||
|
||||
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")]
|
||||
public class MapImageServiceModule : ISharedRegionModule, IMapTileModule
|
||||
public class MapImageServiceModule : ISharedRegionModule, IMapTileModule
|
||||
{
|
||||
private static readonly ILog m_log =
|
||||
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
@ -204,7 +204,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
|||
if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
|
||||
{
|
||||
ConvertAndUploadMaptile(mapTile, scene,
|
||||
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY);
|
||||
scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
|
||||
scene.RegionInfo.RegionName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -226,8 +227,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
|||
{
|
||||
ConvertAndUploadMaptile(subMapTile, scene,
|
||||
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;
|
||||
|
||||
|
@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
|
|||
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,
|
||||
scene.RegionInfo.RegionName, locX, locY, reason);
|
||||
regionName, locX, locY, reason);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -72,6 +72,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false);
|
||||
private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>();
|
||||
|
||||
private IMapImageGenerator m_mapImageGenerator;
|
||||
private IMapTileModule m_mapImageServiceModule;
|
||||
|
||||
protected Scene m_scene;
|
||||
private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>();
|
||||
private int cachedTime = 0;
|
||||
|
@ -139,6 +142,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
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)
|
||||
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)
|
||||
|
@ -1514,20 +1532,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
|
|||
|
||||
public void GenerateMaptile()
|
||||
{
|
||||
// Cannot create a map for a nonexistant heightmap
|
||||
// Cannot create a map for a nonexistent heightmap
|
||||
if (m_scene.Heightmap == null)
|
||||
return;
|
||||
|
||||
//create a texture asset of the terrain
|
||||
IMapImageGenerator terrain = m_scene.RequestModuleInterface<IMapImageGenerator>();
|
||||
if (terrain == null)
|
||||
return;
|
||||
m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name);
|
||||
|
||||
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();
|
||||
if (data == null)
|
||||
// v2/3 (MapImageServiceModule)
|
||||
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;
|
||||
}
|
||||
|
||||
byte[] overlay = GenerateOverlay();
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
using OpenMetaverse;
|
||||
using OpenSim.Framework;
|
||||
using System.Drawing;
|
||||
|
||||
namespace OpenSim.Region.Framework.Interfaces
|
||||
{
|
||||
|
@ -36,5 +37,6 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// Upload a new maptile
|
||||
/// </summary>
|
||||
void UploadMapTile(IScene scene);
|
||||
void UploadMapTile(IScene scene, Bitmap mapTile);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue