From b9d61d5413e7189ddc6f7a335f792abf870a92c8 Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 29 Mar 2012 15:38:12 +0200 Subject: Allow the map tile module to be enabled without also eabling refresh --- .../MapImage/MapImageServiceModule.cs | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs index 6d3ace9..3b862da 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/MapImage/MapImageServiceModule.cs @@ -93,8 +93,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage if (config == null) return; - int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime")); - if (refreshminutes <= 0) + int refreshminutes = Convert.ToInt32(config.GetString("RefreshTime", "-1")); + if (refreshminutes < 0) { m_log.WarnFormat("[MAP IMAGE SERVICE MODULE]: No refresh time given in config. Module disabled."); return; @@ -117,12 +117,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage return; } - m_refreshTimer.Enabled = true; - m_refreshTimer.AutoReset = true; - m_refreshTimer.Interval = m_refreshtime; - m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); + if (m_refreshtime > 0) + { + m_refreshTimer.Enabled = true; + m_refreshTimer.AutoReset = true; + m_refreshTimer.Interval = m_refreshtime; + m_refreshTimer.Elapsed += new ElapsedEventHandler(HandleMaptileRefresh); + } - m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0}min and service object {1}", + m_log.InfoFormat("[MAP IMAGE SERVICE MODULE]: enabled with refresh time {0} min and service object {1}", refreshminutes, service); m_enabled = true; @@ -238,4 +241,4 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.MapImage } } } -} \ No newline at end of file +} -- cgit v1.1 From 5e3999c84c21116fe9581c3324410ffe712cc83f Mon Sep 17 00:00:00 2001 From: Melanie Date: Thu, 29 Mar 2012 22:34:33 +0200 Subject: Cache the last maptile and return the cachrd tile if the last request is less than an hour ago. Avoids generating the maptile twice on startup. --- .../CoreModules/World/Warp3DMap/MapImageModule.cs | 30 ++++++++++++++++------ 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'OpenSim/Region/CoreModules') diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs index 6163fd1..e6f2855 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs @@ -64,6 +64,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap private bool m_useAntiAliasing = false; // TODO: Make this a config option private bool m_Enabled = false; + private Bitmap lastImage = null; + private DateTime lastImageTime = DateTime.MinValue; + #region IRegionModule Members public void Initialise(IConfigSource source) @@ -86,14 +89,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap List renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); if (renderers.Count > 0) - { - m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); - m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); - } + m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); else - { m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); - } m_scene.RegisterModuleInterface(this); } @@ -126,9 +124,25 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap public Bitmap CreateMapTile() { + if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) + { + return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); + } + + List renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); + if (renderers.Count > 0) + { + m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); + } + Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); - return CreateMapTile(viewport, false); + Bitmap tile = CreateMapTile(viewport, false); + m_primMesher = null; + + lastImage = tile; + lastImageTime = DateTime.Now; + return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); } public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) @@ -655,4 +669,4 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap return result; } } -} \ No newline at end of file +} -- cgit v1.1