aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules/ServiceConnectorsOut
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2014-09-26 01:02:19 +0100
committerJustin Clark-Casey (justincc)2014-09-26 01:02:19 +0100
commit9fcee7332638a8008140b77641a957ec9268e828 (patch)
tree10f9397ddb6ef8faf35446819284ada20fea65d0 /OpenSim/Region/CoreModules/ServiceConnectorsOut
parentAdd "debug lludp data out" console command for logging outgoing data just bef... (diff)
downloadopensim-SC_OLD-9fcee7332638a8008140b77641a957ec9268e828.zip
opensim-SC_OLD-9fcee7332638a8008140b77641a957ec9268e828.tar.gz
opensim-SC_OLD-9fcee7332638a8008140b77641a957ec9268e828.tar.bz2
opensim-SC_OLD-9fcee7332638a8008140b77641a957ec9268e828.tar.xz
Make "generate map" console command also trigger upload to maptiles as well as asset generation without performing tile generation twice.
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut')
-rw-r--r--OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs87
1 files changed, 47 insertions, 40 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs
index cf41754..7dfe53a 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 56 public class MapImageServiceModule : IMapImageUploadModule, ISharedRegionModule
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);
@@ -152,6 +152,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
152 m_scenes[scene.RegionInfo.RegionID] = scene; 152 m_scenes[scene.RegionInfo.RegionID] = scene;
153 153
154 scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); }; 154 scene.EventManager.OnRegionReadyStatusChange += s => { if (s.Ready) UploadMapTile(s); };
155
156 scene.RegisterModuleInterface<IMapImageUploadModule>(this);
155 } 157 }
156 158
157 ///<summary> 159 ///<summary>
@@ -198,14 +200,53 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
198 m_lastrefresh = Util.EnvironmentTickCount(); 200 m_lastrefresh = Util.EnvironmentTickCount();
199 } 201 }
200 202
203 public void UploadMapTile(IScene scene, Bitmap mapTile)
204 {
205 m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.Name);
206
207 // mapTile.Save( // DEBUG DEBUG
208 // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY),
209 // ImageFormat.Jpeg);
210 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
211 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
212 {
213 ConvertAndUploadMaptile(mapTile,
214 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
215 scene.RegionInfo.RegionName);
216 }
217 else
218 {
219 // For larger regions (varregion) we must cut the region image into legacy sized
220 // pieces since that is how the maptile system works.
221 // Note the assumption that varregions are always a multiple of legacy size.
222 for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
223 {
224 for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
225 {
226 // Images are addressed from the upper left corner so have to do funny
227 // math to pick out the sub-tile since regions are numbered from
228 // the lower left.
229 Rectangle rect = new Rectangle(
230 (int)xx,
231 mapTile.Height - (int)yy - (int)Constants.RegionSize,
232 (int)Constants.RegionSize, (int)Constants.RegionSize);
233 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
234 {
235 ConvertAndUploadMaptile(subMapTile,
236 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
237 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
238 scene.Name);
239 }
240 }
241 }
242 }
243 }
244
201 ///<summary> 245 ///<summary>
202 /// 246 ///
203 ///</summary> 247 ///</summary>
204 private void UploadMapTile(IScene scene) 248 private void UploadMapTile(IScene scene)
205 { 249 {
206 m_log.DebugFormat("{0} Upload maptile for {1}", LogHeader, scene.RegionInfo.RegionName);
207 string regionName = scene.RegionInfo.RegionName;
208
209 // Create a JPG map tile and upload it to the AddMapTile API 250 // Create a JPG map tile and upload it to the AddMapTile API
210 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>(); 251 IMapImageGenerator tileGenerator = scene.RequestModuleInterface<IMapImageGenerator>();
211 if (tileGenerator == null) 252 if (tileGenerator == null)
@@ -213,46 +254,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage
213 m_log.WarnFormat("{0} Cannot upload map tile without an ImageGenerator", LogHeader); 254 m_log.WarnFormat("{0} Cannot upload map tile without an ImageGenerator", LogHeader);
214 return; 255 return;
215 } 256 }
257
216 using (Bitmap mapTile = tileGenerator.CreateMapTile()) 258 using (Bitmap mapTile = tileGenerator.CreateMapTile())
217 { 259 {
218 if (mapTile != null) 260 if (mapTile != null)
219 { 261 {
220 // mapTile.Save( // DEBUG DEBUG 262 UploadMapTile(scene, mapTile);
221 // String.Format("maptiles/raw-{0}-{1}-{2}.jpg", regionName, scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY),
222 // ImageFormat.Jpeg);
223 // If the region/maptile is legacy sized, just upload the one tile like it has always been done
224 if (mapTile.Width == Constants.RegionSize && mapTile.Height == Constants.RegionSize)
225 {
226 ConvertAndUploadMaptile(mapTile,
227 scene.RegionInfo.RegionLocX, scene.RegionInfo.RegionLocY,
228 scene.RegionInfo.RegionName);
229 }
230 else
231 {
232 // For larger regions (varregion) we must cut the region image into legacy sized
233 // pieces since that is how the maptile system works.
234 // Note the assumption that varregions are always a multiple of legacy size.
235 for (uint xx = 0; xx < mapTile.Width; xx += Constants.RegionSize)
236 {
237 for (uint yy = 0; yy < mapTile.Height; yy += Constants.RegionSize)
238 {
239 // Images are addressed from the upper left corner so have to do funny
240 // math to pick out the sub-tile since regions are numbered from
241 // the lower left.
242 Rectangle rect = new Rectangle(
243 (int)xx,
244 mapTile.Height - (int)yy - (int)Constants.RegionSize,
245 (int)Constants.RegionSize, (int)Constants.RegionSize);
246 using (Bitmap subMapTile = mapTile.Clone(rect, mapTile.PixelFormat))
247 {
248 ConvertAndUploadMaptile(subMapTile,
249 scene.RegionInfo.RegionLocX + (xx / Constants.RegionSize),
250 scene.RegionInfo.RegionLocY + (yy / Constants.RegionSize),
251 regionName);
252 }
253 }
254 }
255 }
256 } 263 }
257 else 264 else
258 { 265 {