diff options
author | Melanie | 2012-03-29 22:34:33 +0200 |
---|---|---|
committer | Melanie | 2012-03-29 22:34:33 +0200 |
commit | 5e3999c84c21116fe9581c3324410ffe712cc83f (patch) | |
tree | 6536d15dec4abbd8f1a39807b0b9f4ce89d8225b /OpenSim/Region/CoreModules/World/Warp3DMap | |
parent | Allow the map tile module to be enabled without also eabling refresh (diff) | |
download | opensim-SC_OLD-5e3999c84c21116fe9581c3324410ffe712cc83f.zip opensim-SC_OLD-5e3999c84c21116fe9581c3324410ffe712cc83f.tar.gz opensim-SC_OLD-5e3999c84c21116fe9581c3324410ffe712cc83f.tar.bz2 opensim-SC_OLD-5e3999c84c21116fe9581c3324410ffe712cc83f.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/CoreModules/World/Warp3DMap')
-rw-r--r-- | OpenSim/Region/CoreModules/World/Warp3DMap/MapImageModule.cs | 30 |
1 files changed, 22 insertions, 8 deletions
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 | |||
64 | private bool m_useAntiAliasing = false; // TODO: Make this a config option | 64 | private bool m_useAntiAliasing = false; // TODO: Make this a config option |
65 | private bool m_Enabled = false; | 65 | private bool m_Enabled = false; |
66 | 66 | ||
67 | private Bitmap lastImage = null; | ||
68 | private DateTime lastImageTime = DateTime.MinValue; | ||
69 | |||
67 | #region IRegionModule Members | 70 | #region IRegionModule Members |
68 | 71 | ||
69 | public void Initialise(IConfigSource source) | 72 | public void Initialise(IConfigSource source) |
@@ -86,14 +89,9 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
86 | 89 | ||
87 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | 90 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); |
88 | if (renderers.Count > 0) | 91 | if (renderers.Count > 0) |
89 | { | 92 | m_log.Info("[MAPTILE]: Loaded prim mesher " + renderers[0]); |
90 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
91 | m_log.Info("[MAPTILE]: Loaded prim mesher " + m_primMesher.ToString()); | ||
92 | } | ||
93 | else | 93 | else |
94 | { | ||
95 | m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); | 94 | m_log.Info("[MAPTILE]: No prim mesher loaded, prim rendering will be disabled"); |
96 | } | ||
97 | 95 | ||
98 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); | 96 | m_scene.RegisterModuleInterface<IMapImageGenerator>(this); |
99 | } | 97 | } |
@@ -126,9 +124,25 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
126 | 124 | ||
127 | public Bitmap CreateMapTile() | 125 | public Bitmap CreateMapTile() |
128 | { | 126 | { |
127 | if ((DateTime.Now - lastImageTime).TotalSeconds < 3600) | ||
128 | { | ||
129 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
130 | } | ||
131 | |||
132 | List<string> renderers = RenderingLoader.ListRenderers(Util.ExecutingDirectory()); | ||
133 | if (renderers.Count > 0) | ||
134 | { | ||
135 | m_primMesher = RenderingLoader.LoadRenderer(renderers[0]); | ||
136 | } | ||
137 | |||
129 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); | 138 | Vector3 camPos = new Vector3(127.5f, 127.5f, 221.7025033688163f); |
130 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); | 139 | Viewport viewport = new Viewport(camPos, -Vector3.UnitZ, 1024f, 0.1f, (int)Constants.RegionSize, (int)Constants.RegionSize, (float)Constants.RegionSize, (float)Constants.RegionSize); |
131 | return CreateMapTile(viewport, false); | 140 | Bitmap tile = CreateMapTile(viewport, false); |
141 | m_primMesher = null; | ||
142 | |||
143 | lastImage = tile; | ||
144 | lastImageTime = DateTime.Now; | ||
145 | return lastImage.Clone(new Rectangle(0, 0, 256, 256), lastImage.PixelFormat); | ||
132 | } | 146 | } |
133 | 147 | ||
134 | public Bitmap CreateViewImage(Vector3 camPos, Vector3 camDir, float fov, int width, int height, bool useTextures) | 148 | 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 | |||
655 | return result; | 669 | return result; |
656 | } | 670 | } |
657 | } | 671 | } |
658 | } \ No newline at end of file | 672 | } |