diff options
author | UbitUmarov | 2015-08-22 16:35:49 +0100 |
---|---|---|
committer | UbitUmarov | 2015-08-22 16:35:49 +0100 |
commit | 5da99790241a38d63d7b4f765bb8ad4b4b024546 (patch) | |
tree | 5b09223c62fa24e2869e4276e2648c1e467fd89b /OpenSim/Region | |
parent | update MapSearchModule (diff) | |
download | opensim-SC-5da99790241a38d63d7b4f765bb8ad4b4b024546.zip opensim-SC-5da99790241a38d63d7b4f765bb8ad4b4b024546.tar.gz opensim-SC-5da99790241a38d63d7b4f765bb8ad4b4b024546.tar.bz2 opensim-SC-5da99790241a38d63d7b4f765bb8ad4b4b024546.tar.xz |
Warp3D map now seems to work
Diffstat (limited to '')
3 files changed, 51 insertions, 15 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index da74f30..8484809 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs | |||
@@ -53,7 +53,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
53 | /// </remarks> | 53 | /// </remarks> |
54 | 54 | ||
55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] | 55 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MapImageServiceModule")] |
56 | public class MapImageServiceModule : ISharedRegionModule, IMapTileModule | 56 | public class MapImageServiceModule : ISharedRegionModule, IMapTileModule |
57 | { | 57 | { |
58 | private static readonly ILog m_log = | 58 | private static readonly ILog m_log = |
59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 59 | LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -204,7 +204,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
204 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) | 204 | if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize) |
205 | { | 205 | { |
206 | ConvertAndUploadMaptile(mapTile, scene, | 206 | ConvertAndUploadMaptile(mapTile, scene, |
207 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY); | 207 | scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY, |
208 | scene.RegionInfo.RegionName); | ||
208 | } | 209 | } |
209 | else | 210 | else |
210 | { | 211 | { |
@@ -226,8 +227,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
226 | { | 227 | { |
227 | ConvertAndUploadMaptile(subMapTile, scene, | 228 | ConvertAndUploadMaptile(subMapTile, scene, |
228 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), | 229 | scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize), |
229 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize) | 230 | scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize), |
230 | ); | 231 | scene.Name); |
231 | } | 232 | } |
232 | } | 233 | } |
233 | } | 234 | } |
@@ -260,7 +261,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
260 | } | 261 | } |
261 | } | 262 | } |
262 | 263 | ||
263 | private void ConvertAndUploadMaptile(Image tileImage, IScene scene, uint locX, uint locY) | 264 | private void ConvertAndUploadMaptile(Image tileImage, IScene scene, uint locX, uint locY, string regionName) |
264 | { | 265 | { |
265 | byte[] jpgData = Utils.EmptyBytes; | 266 | byte[] jpgData = Utils.EmptyBytes; |
266 | 267 | ||
@@ -275,7 +276,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage | |||
275 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) | 276 | if (!m_MapService.AddMapTile((int)locX, (int)locY, jpgData, scene.RegionInfo.ScopeID, out reason)) |
276 | { | 277 | { |
277 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, | 278 | m_log.DebugFormat("{0} Unable to upload tile image for {1} at {2}-{3}: {4}", LogHeader, |
278 | scene.RegionInfo.RegionName, locX, locY, reason); | 279 | regionName, locX, locY, reason); |
279 | } | 280 | } |
280 | } | 281 | } |
281 | else | 282 | else |
diff --git a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs index 31b1c35..9a6ee99 100644 --- a/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs +++ b/OpenSim/Region/CoreModules/World/WorldMap/WorldMapModule.cs | |||
@@ -72,6 +72,9 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
72 | private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); | 72 | private ManualResetEvent m_mapBlockRequestEvent = new ManualResetEvent(false); |
73 | private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); | 73 | private Dictionary<UUID, Queue<MapBlockRequestData>> m_mapBlockRequests = new Dictionary<UUID, Queue<MapBlockRequestData>>(); |
74 | 74 | ||
75 | private IMapImageGenerator m_mapImageGenerator; | ||
76 | private IMapTileModule m_mapImageServiceModule; | ||
77 | |||
75 | protected Scene m_scene; | 78 | protected Scene m_scene; |
76 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); | 79 | private List<MapBlockData> cachedMapBlocks = new List<MapBlockData>(); |
77 | private int cachedTime = 0; | 80 | private int cachedTime = 0; |
@@ -139,6 +142,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
139 | 142 | ||
140 | public virtual void RegionLoaded (Scene scene) | 143 | public virtual void RegionLoaded (Scene scene) |
141 | { | 144 | { |
145 | if (!m_Enabled) | ||
146 | return; | ||
147 | |||
148 | m_mapImageGenerator = m_scene.RequestModuleInterface<IMapImageGenerator>(); | ||
149 | m_mapImageServiceModule = m_scene.RequestModuleInterface<IMapTileModule>(); | ||
142 | } | 150 | } |
143 | 151 | ||
144 | 152 | ||
@@ -1391,7 +1399,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1391 | if (consoleScene != null && consoleScene != m_scene) | 1399 | if (consoleScene != null && consoleScene != m_scene) |
1392 | return; | 1400 | return; |
1393 | 1401 | ||
1394 | GenerateMaptile(); | 1402 | if (m_mapImageGenerator == null) |
1403 | { | ||
1404 | Console.WriteLine("No map image generator available for {0}", m_scene.Name); | ||
1405 | return; | ||
1406 | } | ||
1407 | |||
1408 | using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile()) | ||
1409 | { | ||
1410 | GenerateMaptile(mapbmp); | ||
1411 | // m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp); | ||
1412 | } | ||
1395 | } | 1413 | } |
1396 | 1414 | ||
1397 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) | 1415 | public OSD HandleRemoteMapItemRequest(string path, OSD request, string endpoint) |
@@ -1514,20 +1532,35 @@ namespace OpenSim.Region.CoreModules.World.WorldMap | |||
1514 | 1532 | ||
1515 | public void GenerateMaptile() | 1533 | public void GenerateMaptile() |
1516 | { | 1534 | { |
1517 | // Cannot create a map for a nonexistant heightmap | 1535 | // Cannot create a map for a nonexistent heightmap |
1518 | if (m_scene.Heightmap == null) | 1536 | if (m_scene.Heightmap == null) |
1519 | return; | 1537 | return; |
1520 | 1538 | ||
1521 | //create a texture asset of the terrain | 1539 | m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.Name); |
1522 | IMapImageGenerator terrain = m_scene.RequestModuleInterface<IMapImageGenerator>(); | ||
1523 | if (terrain == null) | ||
1524 | return; | ||
1525 | 1540 | ||
1526 | m_log.DebugFormat("[WORLD MAP]: Generating map image for {0}", m_scene.RegionInfo.RegionName); | 1541 | using (Bitmap mapbmp = m_mapImageGenerator.CreateMapTile()) |
1542 | { | ||
1543 | // V1 (This Module) | ||
1544 | GenerateMaptile(mapbmp); | ||
1545 | |||
1546 | // v2/3 (MapImageServiceModule) | ||
1547 | m_mapImageServiceModule.UploadMapTile(m_scene, mapbmp); | ||
1548 | } | ||
1549 | } | ||
1550 | |||
1551 | private void GenerateMaptile(Bitmap mapbmp) | ||
1552 | { | ||
1553 | byte[] data; | ||
1527 | 1554 | ||
1528 | byte[] data = terrain.WriteJpeg2000Image(); | 1555 | try |
1529 | if (data == null) | 1556 | { |
1557 | data = OpenJPEG.EncodeFromImage(mapbmp, true); | ||
1558 | } | ||
1559 | catch (Exception e) // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
1560 | { | ||
1561 | m_log.Error("[WORLD MAP]: Failed generating terrain map: " + e); | ||
1530 | return; | 1562 | return; |
1563 | } | ||
1531 | 1564 | ||
1532 | byte[] overlay = GenerateOverlay(); | 1565 | byte[] overlay = GenerateOverlay(); |
1533 | 1566 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IMapTileModule.cs b/OpenSim/Region/Framework/Interfaces/IMapTileModule.cs index 4d64236..857d923 100644 --- a/OpenSim/Region/Framework/Interfaces/IMapTileModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IMapTileModule.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using OpenMetaverse; | 28 | using OpenMetaverse; |
29 | using OpenSim.Framework; | 29 | using OpenSim.Framework; |
30 | using System.Drawing; | ||
30 | 31 | ||
31 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
32 | { | 33 | { |
@@ -36,5 +37,6 @@ namespace OpenSim.Region.Framework.Interfaces | |||
36 | /// Upload a new maptile | 37 | /// Upload a new maptile |
37 | /// </summary> | 38 | /// </summary> |
38 | void UploadMapTile(IScene scene); | 39 | void UploadMapTile(IScene scene); |
40 | void UploadMapTile(IScene scene, Bitmap mapTile); | ||
39 | } | 41 | } |
40 | } | 42 | } |