diff options
Diffstat (limited to 'OpenSim/Region')
21 files changed, 596 insertions, 65 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index 7d7176f..d698239 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | |||
@@ -49,12 +49,8 @@ using OpenSim.Region.Framework.Scenes; | |||
49 | using OpenSim.Services.Interfaces; | 49 | using OpenSim.Services.Interfaces; |
50 | 50 | ||
51 | 51 | ||
52 | [assembly: Addin("FlotsamAssetCache", "1.1")] | 52 | namespace OpenSim.Region.CoreModules.Asset |
53 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
54 | |||
55 | namespace Flotsam.RegionModules.AssetCache | ||
56 | { | 53 | { |
57 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
58 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService | 54 | public class FlotsamAssetCache : ISharedRegionModule, IImprovedAssetCache, IAssetService |
59 | { | 55 | { |
60 | private static readonly ILog m_log = | 56 | private static readonly ILog m_log = |
diff --git a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs index c91b25f..9276d1a 100644 --- a/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs +++ b/OpenSim/Region/CoreModules/Asset/Tests/FlotsamAssetCacheTests.cs | |||
@@ -35,7 +35,7 @@ using Nini.Config; | |||
35 | using NUnit.Framework; | 35 | using NUnit.Framework; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.Assets; | 37 | using OpenMetaverse.Assets; |
38 | using Flotsam.RegionModules.AssetCache; | 38 | using OpenSim.Region.CoreModules.Asset; |
39 | using OpenSim.Framework; | 39 | using OpenSim.Framework; |
40 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index 424e0ab..a09945e 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml | |||
@@ -34,6 +34,7 @@ | |||
34 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> | 34 | <RegionModule id="LureModule" type="OpenSim.Region.CoreModules.Avatar.Lure.LureModule" /> |
35 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> | 35 | <RegionModule id="InventoryTransferModule" type="OpenSim.Region.CoreModules.Avatar.Inventory.Transfer.InventoryTransferModule" /> |
36 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> | 36 | <RegionModule id="CoreAssetCache" type="OpenSim.Region.CoreModules.Asset.CoreAssetCache" /> |
37 | <RegionModule id="FlotsamAssetCache" type="OpenSim.Region.CoreModules.Asset.FlotsamAssetCache" /> | ||
37 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> | 38 | <RegionModule id="GlynnTuckerAssetCache" type="OpenSim.Region.CoreModules.Asset.GlynnTuckerAssetCache" /> |
38 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> | 39 | <RegionModule id="CenomeMemoryAssetCache" type="OpenSim.Region.CoreModules.Asset.CenomeMemoryAssetCache"/> |
39 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> | 40 | <RegionModule id="LibraryModule" type="OpenSim.Region.CoreModules.Framework.Library.LibraryModule"/> |
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs new file mode 100644 index 0000000..fce9490 --- /dev/null +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTexture.cs | |||
@@ -0,0 +1,61 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Drawing; | ||
30 | using OpenSim.Region.Framework.Interfaces; | ||
31 | |||
32 | namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | ||
33 | { | ||
34 | public class DynamicTexture : IDynamicTexture | ||
35 | { | ||
36 | public string InputCommands { get; private set; } | ||
37 | public Uri InputUri { get; private set; } | ||
38 | public string InputParams { get; private set; } | ||
39 | public byte[] Data { get; private set; } | ||
40 | public Size Size { get; private set; } | ||
41 | public bool IsReuseable { get; private set; } | ||
42 | |||
43 | public DynamicTexture(string inputCommands, string inputParams, byte[] data, Size size, bool isReuseable) | ||
44 | { | ||
45 | InputCommands = inputCommands; | ||
46 | InputParams = inputParams; | ||
47 | Data = data; | ||
48 | Size = size; | ||
49 | IsReuseable = isReuseable; | ||
50 | } | ||
51 | |||
52 | public DynamicTexture(Uri inputUri, string inputParams, byte[] data, Size size, bool isReuseable) | ||
53 | { | ||
54 | InputUri = inputUri; | ||
55 | InputParams = inputParams; | ||
56 | Data = data; | ||
57 | Size = size; | ||
58 | IsReuseable = isReuseable; | ||
59 | } | ||
60 | } | ||
61 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs index 3eedf49..1f340df 100644 --- a/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/DynamicTexture/DynamicTextureModule.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
42 | { | 42 | { |
43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager | 43 | public class DynamicTextureModule : IRegionModule, IDynamicTextureManager |
44 | { | 44 | { |
45 | //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 45 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
46 | 46 | ||
47 | private const int ALL_SIDES = -1; | 47 | private const int ALL_SIDES = -1; |
48 | 48 | ||
@@ -54,6 +54,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
54 | /// </summary> | 54 | /// </summary> |
55 | public bool ReuseTextures { get; set; } | 55 | public bool ReuseTextures { get; set; } |
56 | 56 | ||
57 | /// <summary> | ||
58 | /// If false, then textures which have a low data size are not reused when ReuseTextures = true. | ||
59 | /// </summary> | ||
60 | /// <remarks> | ||
61 | /// LL viewers 3.3.4 and before appear to not fully render textures pulled from the viewer cache if those | ||
62 | /// textures have a relatively high pixel surface but a small data size. Typically, this appears to happen | ||
63 | /// if the data size is smaller than the viewer's discard level 2 size estimate. So if this is setting is | ||
64 | /// false, textures smaller than the calculation in IsSizeReuseable are always regenerated rather than reused | ||
65 | /// to work around this problem.</remarks> | ||
66 | public bool ReuseLowDataTextures { get; set; } | ||
67 | |||
57 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); | 68 | private Dictionary<UUID, Scene> RegisteredScenes = new Dictionary<UUID, Scene>(); |
58 | 69 | ||
59 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = | 70 | private Dictionary<string, IDynamicTextureRender> RenderPlugins = |
@@ -83,18 +94,17 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
83 | /// <summary> | 94 | /// <summary> |
84 | /// Called by code which actually renders the dynamic texture to supply texture data. | 95 | /// Called by code which actually renders the dynamic texture to supply texture data. |
85 | /// </summary> | 96 | /// </summary> |
86 | /// <param name="id"></param> | 97 | /// <param name="updaterId"></param> |
87 | /// <param name="data"></param> | 98 | /// <param name="texture"></param> |
88 | /// <param name="isReuseable">True if the data generated can be reused for subsequent identical requests</param> | 99 | public void ReturnData(UUID updaterId, IDynamicTexture texture) |
89 | public void ReturnData(UUID id, byte[] data, bool isReuseable) | ||
90 | { | 100 | { |
91 | DynamicTextureUpdater updater = null; | 101 | DynamicTextureUpdater updater = null; |
92 | 102 | ||
93 | lock (Updaters) | 103 | lock (Updaters) |
94 | { | 104 | { |
95 | if (Updaters.ContainsKey(id)) | 105 | if (Updaters.ContainsKey(updaterId)) |
96 | { | 106 | { |
97 | updater = Updaters[id]; | 107 | updater = Updaters[updaterId]; |
98 | } | 108 | } |
99 | } | 109 | } |
100 | 110 | ||
@@ -103,11 +113,16 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
103 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) | 113 | if (RegisteredScenes.ContainsKey(updater.SimUUID)) |
104 | { | 114 | { |
105 | Scene scene = RegisteredScenes[updater.SimUUID]; | 115 | Scene scene = RegisteredScenes[updater.SimUUID]; |
106 | UUID newTextureID = updater.DataReceived(data, scene); | 116 | UUID newTextureID = updater.DataReceived(texture.Data, scene); |
107 | 117 | ||
108 | if (ReuseTextures && isReuseable && !updater.BlendWithOldTexture) | 118 | if (ReuseTextures |
119 | && !updater.BlendWithOldTexture | ||
120 | && texture.IsReuseable | ||
121 | && (ReuseLowDataTextures || IsDataSizeReuseable(texture))) | ||
122 | { | ||
109 | m_reuseableDynamicTextures.Store( | 123 | m_reuseableDynamicTextures.Store( |
110 | GenerateReusableTextureKey(updater.BodyData, updater.Params), newTextureID); | 124 | GenerateReusableTextureKey(texture.InputCommands, texture.InputParams), newTextureID); |
125 | } | ||
111 | } | 126 | } |
112 | } | 127 | } |
113 | 128 | ||
@@ -123,6 +138,27 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
123 | } | 138 | } |
124 | } | 139 | } |
125 | 140 | ||
141 | /// <summary> | ||
142 | /// Determines whether the texture is reuseable based on its data size. | ||
143 | /// </summary> | ||
144 | /// <remarks> | ||
145 | /// This is a workaround for a viewer bug where very small data size textures relative to their pixel size | ||
146 | /// are not redisplayed properly when pulled from cache. The calculation here is based on the typical discard | ||
147 | /// level of 2, a 'rate' of 0.125 and 4 components (which makes for a factor of 0.5). | ||
148 | /// </remarks> | ||
149 | /// <returns></returns> | ||
150 | private bool IsDataSizeReuseable(IDynamicTexture texture) | ||
151 | { | ||
152 | // Console.WriteLine("{0} {1}", texture.Size.Width, texture.Size.Height); | ||
153 | int discardLevel2DataThreshold = (int)Math.Ceiling((texture.Size.Width >> 2) * (texture.Size.Height >> 2) * 0.5); | ||
154 | |||
155 | // m_log.DebugFormat( | ||
156 | // "[DYNAMIC TEXTURE MODULE]: Discard level 2 threshold {0}, texture data length {1}", | ||
157 | // discardLevel2DataThreshold, texture.Data.Length); | ||
158 | |||
159 | return discardLevel2DataThreshold < texture.Data.Length; | ||
160 | } | ||
161 | |||
126 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, | 162 | public UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, |
127 | string extraParams, int updateTimer) | 163 | string extraParams, int updateTimer) |
128 | { | 164 | { |
@@ -249,10 +285,18 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
249 | } | 285 | } |
250 | } | 286 | } |
251 | 287 | ||
288 | // m_log.DebugFormat( | ||
289 | // "[DYNAMIC TEXTURE MODULE]: Requesting generation of new dynamic texture for {0} in {1}", | ||
290 | // part.Name, part.ParentGroup.Scene.Name); | ||
291 | |||
252 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); | 292 | RenderPlugins[contentType].AsyncConvertData(updater.UpdaterID, data, extraParams); |
253 | } | 293 | } |
254 | else | 294 | else |
255 | { | 295 | { |
296 | // m_log.DebugFormat( | ||
297 | // "[DYNAMIC TEXTURE MODULE]: Reusing cached texture {0} for {1} in {2}", | ||
298 | // objReusableTextureUUID, part.Name, part.ParentGroup.Scene.Name); | ||
299 | |||
256 | // No need to add to updaters as the texture is always the same. Not that this functionality | 300 | // No need to add to updaters as the texture is always the same. Not that this functionality |
257 | // apppears to be implemented anyway. | 301 | // apppears to be implemented anyway. |
258 | updater.UpdatePart(part, (UUID)objReusableTextureUUID); | 302 | updater.UpdatePart(part, (UUID)objReusableTextureUUID); |
@@ -285,7 +329,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
285 | { | 329 | { |
286 | IConfig texturesConfig = config.Configs["Textures"]; | 330 | IConfig texturesConfig = config.Configs["Textures"]; |
287 | if (texturesConfig != null) | 331 | if (texturesConfig != null) |
332 | { | ||
288 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); | 333 | ReuseTextures = texturesConfig.GetBoolean("ReuseDynamicTextures", false); |
334 | ReuseLowDataTextures = texturesConfig.GetBoolean("ReuseDynamicLowDataTextures", false); | ||
335 | } | ||
289 | 336 | ||
290 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) | 337 | if (!RegisteredScenes.ContainsKey(scene.RegionInfo.RegionID)) |
291 | { | 338 | { |
@@ -448,8 +495,10 @@ namespace OpenSim.Region.CoreModules.Scripting.DynamicTexture | |||
448 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); | 495 | IJ2KDecoder cacheLayerDecode = scene.RequestModuleInterface<IJ2KDecoder>(); |
449 | if (cacheLayerDecode != null) | 496 | if (cacheLayerDecode != null) |
450 | { | 497 | { |
451 | cacheLayerDecode.Decode(asset.FullID, asset.Data); | 498 | if (!cacheLayerDecode.Decode(asset.FullID, asset.Data)) |
452 | cacheLayerDecode = null; | 499 | m_log.WarnFormat( |
500 | "[DYNAMIC TEXTURE MODULE]: Decoding of dynamically generated asset {0} for {1} in {2} failed", | ||
501 | asset.ID, part.Name, part.ParentGroup.Scene.Name); | ||
453 | } | 502 | } |
454 | 503 | ||
455 | UUID oldID = UpdatePart(part, asset.FullID); | 504 | UUID oldID = UpdatePart(part, asset.FullID); |
diff --git a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs index 2b3a0f2..45e6527 100644 --- a/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LoadImageURL/LoadImageURLModule.cs | |||
@@ -32,6 +32,7 @@ using System.Net; | |||
32 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.Imaging; | 34 | using OpenMetaverse.Imaging; |
35 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using log4net; | 38 | using log4net; |
@@ -73,12 +74,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
73 | // return false; | 74 | // return false; |
74 | // } | 75 | // } |
75 | 76 | ||
76 | public byte[] ConvertUrl(string url, string extraParams) | 77 | public IDynamicTexture ConvertUrl(string url, string extraParams) |
77 | { | 78 | { |
78 | return null; | 79 | return null; |
79 | } | 80 | } |
80 | 81 | ||
81 | public byte[] ConvertData(string bodyData, string extraParams) | 82 | public IDynamicTexture ConvertData(string bodyData, string extraParams) |
82 | { | 83 | { |
83 | return null; | 84 | return null; |
84 | } | 85 | } |
@@ -171,11 +172,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
171 | 172 | ||
172 | private void HttpRequestReturn(IAsyncResult result) | 173 | private void HttpRequestReturn(IAsyncResult result) |
173 | { | 174 | { |
174 | |||
175 | RequestState state = (RequestState) result.AsyncState; | 175 | RequestState state = (RequestState) result.AsyncState; |
176 | WebRequest request = (WebRequest) state.Request; | 176 | WebRequest request = (WebRequest) state.Request; |
177 | Stream stream = null; | 177 | Stream stream = null; |
178 | byte[] imageJ2000 = new byte[0]; | 178 | byte[] imageJ2000 = new byte[0]; |
179 | Size newSize = new Size(0, 0); | ||
179 | 180 | ||
180 | try | 181 | try |
181 | { | 182 | { |
@@ -188,37 +189,43 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
188 | try | 189 | try |
189 | { | 190 | { |
190 | Bitmap image = new Bitmap(stream); | 191 | Bitmap image = new Bitmap(stream); |
191 | Size newsize; | ||
192 | 192 | ||
193 | // TODO: make this a bit less hard coded | 193 | // TODO: make this a bit less hard coded |
194 | if ((image.Height < 64) && (image.Width < 64)) | 194 | if ((image.Height < 64) && (image.Width < 64)) |
195 | { | 195 | { |
196 | newsize = new Size(32, 32); | 196 | newSize.Width = 32; |
197 | newSize.Height = 32; | ||
197 | } | 198 | } |
198 | else if ((image.Height < 128) && (image.Width < 128)) | 199 | else if ((image.Height < 128) && (image.Width < 128)) |
199 | { | 200 | { |
200 | newsize = new Size(64, 64); | 201 | newSize.Width = 64; |
202 | newSize.Height = 64; | ||
201 | } | 203 | } |
202 | else if ((image.Height < 256) && (image.Width < 256)) | 204 | else if ((image.Height < 256) && (image.Width < 256)) |
203 | { | 205 | { |
204 | newsize = new Size(128, 128); | 206 | newSize.Width = 128; |
207 | newSize.Height = 128; | ||
205 | } | 208 | } |
206 | else if ((image.Height < 512 && image.Width < 512)) | 209 | else if ((image.Height < 512 && image.Width < 512)) |
207 | { | 210 | { |
208 | newsize = new Size(256, 256); | 211 | newSize.Width = 256; |
212 | newSize.Height = 256; | ||
209 | } | 213 | } |
210 | else if ((image.Height < 1024 && image.Width < 1024)) | 214 | else if ((image.Height < 1024 && image.Width < 1024)) |
211 | { | 215 | { |
212 | newsize = new Size(512, 512); | 216 | newSize.Width = 512; |
217 | newSize.Height = 512; | ||
213 | } | 218 | } |
214 | else | 219 | else |
215 | { | 220 | { |
216 | newsize = new Size(1024, 1024); | 221 | newSize.Width = 1024; |
222 | newSize.Height = 1024; | ||
217 | } | 223 | } |
218 | 224 | ||
219 | Bitmap resize = new Bitmap(image, newsize); | 225 | using (Bitmap resize = new Bitmap(image, newSize)) |
220 | 226 | { | |
221 | imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); | 227 | imageJ2000 = OpenJPEG.EncodeFromImage(resize, true); |
228 | } | ||
222 | } | 229 | } |
223 | catch (Exception) | 230 | catch (Exception) |
224 | { | 231 | { |
@@ -233,7 +240,6 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
233 | } | 240 | } |
234 | catch (WebException) | 241 | catch (WebException) |
235 | { | 242 | { |
236 | |||
237 | } | 243 | } |
238 | finally | 244 | finally |
239 | { | 245 | { |
@@ -243,10 +249,13 @@ namespace OpenSim.Region.CoreModules.Scripting.LoadImageURL | |||
243 | } | 249 | } |
244 | } | 250 | } |
245 | 251 | ||
246 | m_log.DebugFormat("[LOADIMAGEURLMODULE] Returning {0} bytes of image data for request {1}", | 252 | m_log.DebugFormat("[LOADIMAGEURLMODULE]: Returning {0} bytes of image data for request {1}", |
247 | imageJ2000.Length, state.RequestID); | 253 | imageJ2000.Length, state.RequestID); |
248 | 254 | ||
249 | m_textureManager.ReturnData(state.RequestID, imageJ2000, false); | 255 | m_textureManager.ReturnData( |
256 | state.RequestID, | ||
257 | new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( | ||
258 | request.RequestUri, null, imageJ2000, newSize, false)); | ||
250 | } | 259 | } |
251 | 260 | ||
252 | #region Nested type: RequestState | 261 | #region Nested type: RequestState |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs index b50c0bd..41baccc 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/Tests/VectorRenderModuleTests.cs | |||
@@ -57,6 +57,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
57 | 57 | ||
58 | m_dtm = new DynamicTextureModule(); | 58 | m_dtm = new DynamicTextureModule(); |
59 | m_dtm.ReuseTextures = reuseTextures; | 59 | m_dtm.ReuseTextures = reuseTextures; |
60 | // m_dtm.ReuseLowDataTextures = reuseTextures; | ||
60 | 61 | ||
61 | m_vrm = new VectorRenderModule(); | 62 | m_vrm = new VectorRenderModule(); |
62 | 63 | ||
@@ -201,6 +202,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
201 | public void TestRepeatSameDrawReusingTexture() | 202 | public void TestRepeatSameDrawReusingTexture() |
202 | { | 203 | { |
203 | TestHelpers.InMethod(); | 204 | TestHelpers.InMethod(); |
205 | // TestHelpers.EnableLogging(); | ||
204 | 206 | ||
205 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; | 207 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; |
206 | 208 | ||
@@ -228,6 +230,46 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender.Tests | |||
228 | Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); | 230 | Assert.That(firstDynamicTextureID, Is.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); |
229 | } | 231 | } |
230 | 232 | ||
233 | /// <summary> | ||
234 | /// Test a low data dynamically generated texture such that it is treated as a low data texture that causes | ||
235 | /// problems for current viewers. | ||
236 | /// </summary> | ||
237 | /// <remarks> | ||
238 | /// As we do not set DynamicTextureModule.ReuseLowDataTextures = true in this test, it should not reuse the | ||
239 | /// texture | ||
240 | /// </remarks> | ||
241 | [Test] | ||
242 | public void TestRepeatSameDrawLowDataTexture() | ||
243 | { | ||
244 | TestHelpers.InMethod(); | ||
245 | // TestHelpers.EnableLogging(); | ||
246 | |||
247 | string dtText = "PenColour BLACK; MoveTo 40,220; FontSize 32; Text Hello World;"; | ||
248 | |||
249 | SetupScene(true); | ||
250 | SceneObjectGroup so = SceneHelpers.AddSceneObject(m_scene); | ||
251 | |||
252 | m_dtm.AddDynamicTextureData( | ||
253 | m_scene.RegionInfo.RegionID, | ||
254 | so.UUID, | ||
255 | m_vrm.GetContentType(), | ||
256 | dtText, | ||
257 | "1024", | ||
258 | 0); | ||
259 | |||
260 | UUID firstDynamicTextureID = so.RootPart.Shape.Textures.GetFace(0).TextureID; | ||
261 | |||
262 | m_dtm.AddDynamicTextureData( | ||
263 | m_scene.RegionInfo.RegionID, | ||
264 | so.UUID, | ||
265 | m_vrm.GetContentType(), | ||
266 | dtText, | ||
267 | "1024", | ||
268 | 0); | ||
269 | |||
270 | Assert.That(firstDynamicTextureID, Is.Not.EqualTo(so.RootPart.Shape.Textures.GetFace(0).TextureID)); | ||
271 | } | ||
272 | |||
231 | [Test] | 273 | [Test] |
232 | public void TestRepeatSameDrawDifferentExtraParamsReusingTexture() | 274 | public void TestRepeatSameDrawDifferentExtraParamsReusingTexture() |
233 | { | 275 | { |
diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index f687646..1e17b02 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs | |||
@@ -35,6 +35,7 @@ using System.Net; | |||
35 | using Nini.Config; | 35 | using Nini.Config; |
36 | using OpenMetaverse; | 36 | using OpenMetaverse; |
37 | using OpenMetaverse.Imaging; | 37 | using OpenMetaverse.Imaging; |
38 | using OpenSim.Region.CoreModules.Scripting.DynamicTexture; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 39 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 40 | using OpenSim.Region.Framework.Scenes; |
40 | using log4net; | 41 | using log4net; |
@@ -46,6 +47,11 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
46 | { | 47 | { |
47 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender | 48 | public class VectorRenderModule : IRegionModule, IDynamicTextureRender |
48 | { | 49 | { |
50 | // These fields exist for testing purposes, please do not remove. | ||
51 | // private static bool s_flipper; | ||
52 | // private static byte[] s_asset1Data; | ||
53 | // private static byte[] s_asset2Data; | ||
54 | |||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 55 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
50 | 56 | ||
51 | private Scene m_scene; | 57 | private Scene m_scene; |
@@ -80,20 +86,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
80 | // return lines.Any((str, r) => str.StartsWith("Image")); | 86 | // return lines.Any((str, r) => str.StartsWith("Image")); |
81 | // } | 87 | // } |
82 | 88 | ||
83 | public byte[] ConvertUrl(string url, string extraParams) | 89 | public IDynamicTexture ConvertUrl(string url, string extraParams) |
84 | { | 90 | { |
85 | return null; | 91 | return null; |
86 | } | 92 | } |
87 | 93 | ||
88 | public byte[] ConvertData(string bodyData, string extraParams) | 94 | public IDynamicTexture ConvertData(string bodyData, string extraParams) |
89 | { | ||
90 | bool reuseable; | ||
91 | return Draw(bodyData, extraParams, out reuseable); | ||
92 | } | ||
93 | |||
94 | private byte[] ConvertData(string bodyData, string extraParams, out bool reuseable) | ||
95 | { | 95 | { |
96 | return Draw(bodyData, extraParams, out reuseable); | 96 | return Draw(bodyData, extraParams); |
97 | } | 97 | } |
98 | 98 | ||
99 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) | 99 | public bool AsyncConvertUrl(UUID id, string url, string extraParams) |
@@ -104,10 +104,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) | 104 | public bool AsyncConvertData(UUID id, string bodyData, string extraParams) |
105 | { | 105 | { |
106 | // XXX: This isn't actually being done asynchronously! | 106 | // XXX: This isn't actually being done asynchronously! |
107 | bool reuseable; | 107 | m_textureManager.ReturnData(id, ConvertData(bodyData, extraParams)); |
108 | byte[] data = ConvertData(bodyData, extraParams, out reuseable); | ||
109 | |||
110 | m_textureManager.ReturnData(id, data, reuseable); | ||
111 | 108 | ||
112 | return true; | 109 | return true; |
113 | } | 110 | } |
@@ -161,6 +158,13 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
161 | { | 158 | { |
162 | m_textureManager.RegisterRender(GetContentType(), this); | 159 | m_textureManager.RegisterRender(GetContentType(), this); |
163 | } | 160 | } |
161 | |||
162 | // This code exists for testing purposes, please do not remove. | ||
163 | // s_asset1Data = m_scene.AssetService.Get("00000000-0000-1111-9999-000000000001").Data; | ||
164 | // s_asset1Data = m_scene.AssetService.Get("9f4acf0d-1841-4e15-bdb8-3a12efc9dd8f").Data; | ||
165 | |||
166 | // Terrain dirt - smallest bin/assets file (6004 bytes) | ||
167 | // s_asset2Data = m_scene.AssetService.Get("b8d3965a-ad78-bf43-699b-bff8eca6c975").Data; | ||
164 | } | 168 | } |
165 | 169 | ||
166 | public void Close() | 170 | public void Close() |
@@ -179,7 +183,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
179 | 183 | ||
180 | #endregion | 184 | #endregion |
181 | 185 | ||
182 | private byte[] Draw(string data, string extraParams, out bool reuseable) | 186 | private IDynamicTexture Draw(string data, string extraParams) |
183 | { | 187 | { |
184 | // We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha | 188 | // We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha |
185 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 | 189 | // we will now support multiple comma seperated params in the form width:256,height:512,alpha:255 |
@@ -322,6 +326,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
322 | 326 | ||
323 | Bitmap bitmap = null; | 327 | Bitmap bitmap = null; |
324 | Graphics graph = null; | 328 | Graphics graph = null; |
329 | bool reuseable = false; | ||
325 | 330 | ||
326 | try | 331 | try |
327 | { | 332 | { |
@@ -364,6 +369,14 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
364 | } | 369 | } |
365 | 370 | ||
366 | byte[] imageJ2000 = new byte[0]; | 371 | byte[] imageJ2000 = new byte[0]; |
372 | |||
373 | // This code exists for testing purposes, please do not remove. | ||
374 | // if (s_flipper) | ||
375 | // imageJ2000 = s_asset1Data; | ||
376 | // else | ||
377 | // imageJ2000 = s_asset2Data; | ||
378 | // | ||
379 | // s_flipper = !s_flipper; | ||
367 | 380 | ||
368 | try | 381 | try |
369 | { | 382 | { |
@@ -376,7 +389,8 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender | |||
376 | e.Message, e.StackTrace); | 389 | e.Message, e.StackTrace); |
377 | } | 390 | } |
378 | 391 | ||
379 | return imageJ2000; | 392 | return new OpenSim.Region.CoreModules.Scripting.DynamicTexture.DynamicTexture( |
393 | data, extraParams, imageJ2000, new Size(width, height), reuseable); | ||
380 | } | 394 | } |
381 | finally | 395 | finally |
382 | { | 396 | { |
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index b286d17..57ae549 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | |||
@@ -43,7 +43,7 @@ using OpenSim.Tests.Common; | |||
43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests | 43 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests |
44 | { | 44 | { |
45 | [TestFixture] | 45 | [TestFixture] |
46 | public class GridConnectorsTests | 46 | public class GridConnectorsTests : OpenSimTestCase |
47 | { | 47 | { |
48 | LocalGridServicesConnector m_LocalConnector; | 48 | LocalGridServicesConnector m_LocalConnector; |
49 | private void SetUp() | 49 | private void SetUp() |
diff --git a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs index 5deaf52..904110e 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/Tests/ArchiverTests.cs | |||
@@ -51,7 +51,7 @@ using RegionSettings = OpenSim.Framework.RegionSettings; | |||
51 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests | 51 | namespace OpenSim.Region.CoreModules.World.Archiver.Tests |
52 | { | 52 | { |
53 | [TestFixture] | 53 | [TestFixture] |
54 | public class ArchiverTests | 54 | public class ArchiverTests : OpenSimTestCase |
55 | { | 55 | { |
56 | private Guid m_lastRequestId; | 56 | private Guid m_lastRequestId; |
57 | private string m_lastErrorMessage; | 57 | private string m_lastErrorMessage; |
diff --git a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs index 3c48d07..33f6c3f 100644 --- a/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs +++ b/OpenSim/Region/CoreModules/World/Warp3DMap/Warp3DImageModule.cs | |||
@@ -222,6 +222,13 @@ namespace OpenSim.Region.CoreModules.World.Warp3DMap | |||
222 | bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); | 222 | bitmap = ImageUtils.ResizeImage(origBitmap, viewport.Width, viewport.Height); |
223 | } | 223 | } |
224 | 224 | ||
225 | // XXX: It shouldn't really be necesary to force a GC here as one should occur anyway pretty shortly | ||
226 | // afterwards. It's generally regarded as a bad idea to manually GC. If Warp3D is using lots of memory | ||
227 | // then this may be some issue with the Warp3D code itself, though it's also quite possible that generating | ||
228 | // this map tile simply takes a lot of memory. | ||
229 | GC.Collect(); | ||
230 | m_log.Debug("[WARP 3D IMAGE MODULE]: GC.Collect()"); | ||
231 | |||
225 | return bitmap; | 232 | return bitmap; |
226 | } | 233 | } |
227 | 234 | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs index 1a3bcbb..6df5cc2 100644 --- a/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs +++ b/OpenSim/Region/Framework/Interfaces/IDynamicTextureManager.cs | |||
@@ -25,6 +25,8 @@ | |||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | ||
29 | using System.Drawing; | ||
28 | using System.IO; | 30 | using System.IO; |
29 | using OpenMetaverse; | 31 | using OpenMetaverse; |
30 | 32 | ||
@@ -33,7 +35,14 @@ namespace OpenSim.Region.Framework.Interfaces | |||
33 | public interface IDynamicTextureManager | 35 | public interface IDynamicTextureManager |
34 | { | 36 | { |
35 | void RegisterRender(string handleType, IDynamicTextureRender render); | 37 | void RegisterRender(string handleType, IDynamicTextureRender render); |
36 | void ReturnData(UUID id, byte[] data, bool isReuseable); | 38 | |
39 | /// <summary> | ||
40 | /// Used by IDynamicTextureRender implementations to return renders | ||
41 | /// </summary> | ||
42 | /// <param name='id'></param> | ||
43 | /// <param name='data'></param> | ||
44 | /// <param name='isReuseable'></param> | ||
45 | void ReturnData(UUID id, IDynamicTexture texture); | ||
37 | 46 | ||
38 | UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, | 47 | UUID AddDynamicTextureURL(UUID simID, UUID primID, string contentType, string url, string extraParams, |
39 | int updateTimer); | 48 | int updateTimer); |
@@ -125,11 +134,53 @@ namespace OpenSim.Region.Framework.Interfaces | |||
125 | // /// <param name='extraParams'></param> | 134 | // /// <param name='extraParams'></param> |
126 | // bool AlwaysIdenticalConversion(string bodyData, string extraParams); | 135 | // bool AlwaysIdenticalConversion(string bodyData, string extraParams); |
127 | 136 | ||
128 | byte[] ConvertUrl(string url, string extraParams); | 137 | IDynamicTexture ConvertUrl(string url, string extraParams); |
129 | byte[] ConvertData(string bodyData, string extraParams); | 138 | IDynamicTexture ConvertData(string bodyData, string extraParams); |
139 | |||
130 | bool AsyncConvertUrl(UUID id, string url, string extraParams); | 140 | bool AsyncConvertUrl(UUID id, string url, string extraParams); |
131 | bool AsyncConvertData(UUID id, string bodyData, string extraParams); | 141 | bool AsyncConvertData(UUID id, string bodyData, string extraParams); |
142 | |||
132 | void GetDrawStringSize(string text, string fontName, int fontSize, | 143 | void GetDrawStringSize(string text, string fontName, int fontSize, |
133 | out double xSize, out double ySize); | 144 | out double xSize, out double ySize); |
134 | } | 145 | } |
146 | |||
147 | public interface IDynamicTexture | ||
148 | { | ||
149 | /// <summary> | ||
150 | /// Input commands used to generate this data. | ||
151 | /// </summary> | ||
152 | /// <remarks> | ||
153 | /// Null if input commands were not used. | ||
154 | /// </remarks> | ||
155 | string InputCommands { get; } | ||
156 | |||
157 | /// <summary> | ||
158 | /// Uri used to generate this data. | ||
159 | /// </summary> | ||
160 | /// <remarks> | ||
161 | /// Null if a uri was not used. | ||
162 | /// </remarks> | ||
163 | Uri InputUri { get; } | ||
164 | |||
165 | /// <summary> | ||
166 | /// Extra input params used to generate this data. | ||
167 | /// </summary> | ||
168 | string InputParams { get; } | ||
169 | |||
170 | /// <summary> | ||
171 | /// Texture data. | ||
172 | /// </summary> | ||
173 | byte[] Data { get; } | ||
174 | |||
175 | /// <summary> | ||
176 | /// Size of texture. | ||
177 | /// </summary> | ||
178 | Size Size { get; } | ||
179 | |||
180 | /// <summary> | ||
181 | /// Signal whether the texture is reuseable (i.e. whether the same input data will always generate the same | ||
182 | /// texture). | ||
183 | /// </summary> | ||
184 | bool IsReuseable { get; } | ||
185 | } | ||
135 | } | 186 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index 8fb6c3b..d94d5ef 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4811,6 +4811,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4811 | } | 4811 | } |
4812 | 4812 | ||
4813 | /// <summary> | 4813 | /// <summary> |
4814 | /// Attempt to get the SOG via its UUID | ||
4815 | /// </summary> | ||
4816 | /// <param name="fullID"></param> | ||
4817 | /// <param name="sog"></param> | ||
4818 | /// <returns></returns> | ||
4819 | public bool TryGetSceneObjectGroup(UUID fullID, out SceneObjectGroup sog) | ||
4820 | { | ||
4821 | sog = GetSceneObjectGroup(fullID); | ||
4822 | return sog != null; | ||
4823 | } | ||
4824 | |||
4825 | /// <summary> | ||
4814 | /// Get a prim by name from the scene (will return the first | 4826 | /// Get a prim by name from the scene (will return the first |
4815 | /// found, if there are more than one prim with the same name) | 4827 | /// found, if there are more than one prim with the same name) |
4816 | /// </summary> | 4828 | /// </summary> |
@@ -4842,6 +4854,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
4842 | } | 4854 | } |
4843 | 4855 | ||
4844 | /// <summary> | 4856 | /// <summary> |
4857 | /// Attempt to get a prim via its UUID | ||
4858 | /// </summary> | ||
4859 | /// <param name="fullID"></param> | ||
4860 | /// <param name="sop"></param> | ||
4861 | /// <returns></returns> | ||
4862 | public bool TryGetSceneObjectPart(UUID fullID, out SceneObjectPart sop) | ||
4863 | { | ||
4864 | sop = GetSceneObjectPart(fullID); | ||
4865 | return sop != null; | ||
4866 | } | ||
4867 | |||
4868 | /// <summary> | ||
4845 | /// Get a scene object group that contains the prim with the given local id | 4869 | /// Get a scene object group that contains the prim with the given local id |
4846 | /// </summary> | 4870 | /// </summary> |
4847 | /// <param name="localID"></param> | 4871 | /// <param name="localID"></param> |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 3e8c7e5..0176921 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -3631,13 +3631,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
3631 | public List<SceneObjectGroup> GetAttachments(uint attachmentPoint) | 3631 | public List<SceneObjectGroup> GetAttachments(uint attachmentPoint) |
3632 | { | 3632 | { |
3633 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); | 3633 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); |
3634 | 3634 | ||
3635 | lock (m_attachments) | 3635 | if (attachmentPoint >= 0) |
3636 | { | 3636 | { |
3637 | foreach (SceneObjectGroup so in m_attachments) | 3637 | lock (m_attachments) |
3638 | { | 3638 | { |
3639 | if (attachmentPoint == so.AttachmentPoint) | 3639 | foreach (SceneObjectGroup so in m_attachments) |
3640 | attachments.Add(so); | 3640 | { |
3641 | if (attachmentPoint == so.AttachmentPoint) | ||
3642 | attachments.Add(so); | ||
3643 | } | ||
3641 | } | 3644 | } |
3642 | } | 3645 | } |
3643 | 3646 | ||
diff --git a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs index 3144d76..190fca0 100644 --- a/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs +++ b/OpenSim/Region/RegionCombinerModule/RegionCombinerModule.cs | |||
@@ -39,11 +39,8 @@ using OpenSim.Framework.Console; | |||
39 | using OpenSim.Region.Physics.Manager; | 39 | using OpenSim.Region.Physics.Manager; |
40 | using Mono.Addins; | 40 | using Mono.Addins; |
41 | 41 | ||
42 | [assembly: Addin("RegionCombinerModule", "0.1")] | ||
43 | [assembly: AddinDependency("OpenSim", "0.5")] | ||
44 | namespace OpenSim.Region.RegionCombinerModule | 42 | namespace OpenSim.Region.RegionCombinerModule |
45 | { | 43 | { |
46 | [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] | ||
47 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule | 44 | public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule |
48 | { | 45 | { |
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 46 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
diff --git a/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml new file mode 100644 index 0000000..13cb8b6 --- /dev/null +++ b/OpenSim/Region/RegionCombinerModule/Resources/RegionCombinerModule.addin.xml | |||
@@ -0,0 +1,14 @@ | |||
1 | <Addin id="OpenSim.RegionModules.RegionCombinerModule" version="0.3"> | ||
2 | <Runtime> | ||
3 | <Import assembly="OpenSim.Region.RegionCombinerModule.dll"/> | ||
4 | </Runtime> | ||
5 | |||
6 | <Dependencies> | ||
7 | <Addin id="OpenSim" version="0.5" /> | ||
8 | </Dependencies> | ||
9 | |||
10 | <Extension path = "/OpenSim/RegionModules"> | ||
11 | <RegionModule id="RegionCombinerModule" type="OpenSim.Region.RegionCombinerModule.RegionCombinerModule" /> | ||
12 | </Extension> | ||
13 | |||
14 | </Addin> | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs index 84cf6ca..cde2d9f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/MOD_Api.cs | |||
@@ -310,7 +310,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
310 | // ---------- Integer ---------- | 310 | // ---------- Integer ---------- |
311 | else if (lslparm is LSL_Integer) | 311 | else if (lslparm is LSL_Integer) |
312 | { | 312 | { |
313 | if (type == typeof(int)) | 313 | if (type == typeof(int) || type == typeof(float)) |
314 | return (int)(LSL_Integer)lslparm; | 314 | return (int)(LSL_Integer)lslparm; |
315 | } | 315 | } |
316 | 316 | ||
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs index 7aacfd4..a44ced4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/OSSL_Api.cs | |||
@@ -1682,6 +1682,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
1682 | return; | 1682 | return; |
1683 | } | 1683 | } |
1684 | 1684 | ||
1685 | MessageObject(objUUID, message); | ||
1686 | } | ||
1687 | |||
1688 | private void MessageObject(UUID objUUID, string message) | ||
1689 | { | ||
1685 | object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; | 1690 | object[] resobj = new object[] { new LSL_Types.LSLString(m_host.UUID.ToString()), new LSL_Types.LSLString(message) }; |
1686 | 1691 | ||
1687 | SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); | 1692 | SceneObjectPart sceneOP = World.GetSceneObjectPart(objUUID); |
@@ -3272,6 +3277,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3272 | } | 3277 | } |
3273 | } | 3278 | } |
3274 | 3279 | ||
3280 | #region Attachment commands | ||
3281 | |||
3275 | public void osForceAttachToAvatar(int attachmentPoint) | 3282 | public void osForceAttachToAvatar(int attachmentPoint) |
3276 | { | 3283 | { |
3277 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); | 3284 | CheckThreatLevel(ThreatLevel.High, "osForceAttachToAvatar"); |
@@ -3361,6 +3368,175 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
3361 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); | 3368 | ((LSL_Api)m_LSL_Api).DetachFromAvatar(); |
3362 | } | 3369 | } |
3363 | 3370 | ||
3371 | public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints) | ||
3372 | { | ||
3373 | CheckThreatLevel(ThreatLevel.Moderate, "osGetNumberOfAttachments"); | ||
3374 | |||
3375 | m_host.AddScriptLPS(1); | ||
3376 | |||
3377 | UUID targetUUID; | ||
3378 | ScenePresence target; | ||
3379 | LSL_List resp = new LSL_List(); | ||
3380 | |||
3381 | if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) | ||
3382 | { | ||
3383 | foreach (object point in attachmentPoints.Data) | ||
3384 | { | ||
3385 | LSL_Integer ipoint = new LSL_Integer( | ||
3386 | (point is LSL_Integer || point is int || point is uint) ? | ||
3387 | (int)point : | ||
3388 | 0 | ||
3389 | ); | ||
3390 | resp.Add(ipoint); | ||
3391 | if (ipoint == 0) | ||
3392 | { | ||
3393 | // indicates zero attachments | ||
3394 | resp.Add(new LSL_Integer(0)); | ||
3395 | } | ||
3396 | else | ||
3397 | { | ||
3398 | // gets the number of attachments on the attachment point | ||
3399 | resp.Add(new LSL_Integer(target.GetAttachments((uint)ipoint).Count)); | ||
3400 | } | ||
3401 | } | ||
3402 | } | ||
3403 | |||
3404 | return resp; | ||
3405 | } | ||
3406 | |||
3407 | public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int options) | ||
3408 | { | ||
3409 | CheckThreatLevel(ThreatLevel.Moderate, "osMessageAttachments"); | ||
3410 | m_host.AddScriptLPS(1); | ||
3411 | |||
3412 | UUID targetUUID; | ||
3413 | ScenePresence target; | ||
3414 | |||
3415 | if (attachmentPoints.Length >= 1 && UUID.TryParse(avatar.ToString(), out targetUUID) && World.TryGetScenePresence(targetUUID, out target)) | ||
3416 | { | ||
3417 | List<int> aps = new List<int>(); | ||
3418 | foreach (object point in attachmentPoints.Data) | ||
3419 | { | ||
3420 | int ipoint; | ||
3421 | if (int.TryParse(point.ToString(), out ipoint)) | ||
3422 | { | ||
3423 | aps.Add(ipoint); | ||
3424 | } | ||
3425 | } | ||
3426 | |||
3427 | List<SceneObjectGroup> attachments = new List<SceneObjectGroup>(); | ||
3428 | |||
3429 | bool msgAll = aps.Contains(ScriptBaseClass.OS_ATTACH_MSG_ALL); | ||
3430 | bool invertPoints = (options & ScriptBaseClass.OS_ATTACH_MSG_INVERT_POINTS) != 0; | ||
3431 | |||
3432 | if (msgAll && invertPoints) | ||
3433 | { | ||
3434 | return; | ||
3435 | } | ||
3436 | else if (msgAll || invertPoints) | ||
3437 | { | ||
3438 | attachments = target.GetAttachments(); | ||
3439 | } | ||
3440 | else | ||
3441 | { | ||
3442 | foreach (int point in aps) | ||
3443 | { | ||
3444 | if (point > 0) | ||
3445 | { | ||
3446 | attachments.AddRange(target.GetAttachments((uint)point)); | ||
3447 | } | ||
3448 | } | ||
3449 | } | ||
3450 | |||
3451 | // if we have no attachments at this point, exit now | ||
3452 | if (attachments.Count == 0) | ||
3453 | { | ||
3454 | return; | ||
3455 | } | ||
3456 | |||
3457 | List<SceneObjectGroup> ignoreThese = new List<SceneObjectGroup>(); | ||
3458 | |||
3459 | if (invertPoints) | ||
3460 | { | ||
3461 | foreach (SceneObjectGroup attachment in attachments) | ||
3462 | { | ||
3463 | if (aps.Contains((int)attachment.AttachmentPoint)) | ||
3464 | { | ||
3465 | ignoreThese.Add(attachment); | ||
3466 | } | ||
3467 | } | ||
3468 | } | ||
3469 | |||
3470 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3471 | { | ||
3472 | attachments.Remove(attachment); | ||
3473 | } | ||
3474 | ignoreThese.Clear(); | ||
3475 | |||
3476 | // if inverting removed all attachments to check, exit now | ||
3477 | if (attachments.Count < 1) | ||
3478 | { | ||
3479 | return; | ||
3480 | } | ||
3481 | |||
3482 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_OBJECT_CREATOR) != 0) | ||
3483 | { | ||
3484 | foreach (SceneObjectGroup attachment in attachments) | ||
3485 | { | ||
3486 | if (attachment.RootPart.CreatorID != m_host.CreatorID) | ||
3487 | { | ||
3488 | ignoreThese.Add(attachment); | ||
3489 | } | ||
3490 | } | ||
3491 | |||
3492 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3493 | { | ||
3494 | attachments.Remove(attachment); | ||
3495 | } | ||
3496 | ignoreThese.Clear(); | ||
3497 | |||
3498 | // if filtering by same object creator removed all | ||
3499 | // attachments to check, exit now | ||
3500 | if (attachments.Count == 0) | ||
3501 | { | ||
3502 | return; | ||
3503 | } | ||
3504 | } | ||
3505 | |||
3506 | if ((options & ScriptBaseClass.OS_ATTACH_MSG_SCRIPT_CREATOR) != 0) | ||
3507 | { | ||
3508 | foreach (SceneObjectGroup attachment in attachments) | ||
3509 | { | ||
3510 | if (attachment.RootPart.CreatorID != m_item.CreatorID) | ||
3511 | { | ||
3512 | ignoreThese.Add(attachment); | ||
3513 | } | ||
3514 | } | ||
3515 | |||
3516 | foreach (SceneObjectGroup attachment in ignoreThese) | ||
3517 | { | ||
3518 | attachments.Remove(attachment); | ||
3519 | } | ||
3520 | ignoreThese.Clear(); | ||
3521 | |||
3522 | // if filtering by object creator must match originating | ||
3523 | // script creator removed all attachments to check, | ||
3524 | // exit now | ||
3525 | if (attachments.Count == 0) | ||
3526 | { | ||
3527 | return; | ||
3528 | } | ||
3529 | } | ||
3530 | |||
3531 | foreach (SceneObjectGroup attachment in attachments) | ||
3532 | { | ||
3533 | MessageObject(attachment.RootPart.UUID, message); | ||
3534 | } | ||
3535 | } | ||
3536 | } | ||
3537 | |||
3538 | #endregion | ||
3539 | |||
3364 | /// <summary> | 3540 | /// <summary> |
3365 | /// Checks if thing is a UUID. | 3541 | /// Checks if thing is a UUID. |
3366 | /// </summary> | 3542 | /// </summary> |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs index 07149b6..0ea363a 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Interface/IOSSL_Api.cs | |||
@@ -157,7 +157,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
157 | void osAvatarPlayAnimation(string avatar, string animation); | 157 | void osAvatarPlayAnimation(string avatar, string animation); |
158 | void osAvatarStopAnimation(string avatar, string animation); | 158 | void osAvatarStopAnimation(string avatar, string animation); |
159 | 159 | ||
160 | // Attachment commands | 160 | #region Attachment commands |
161 | 161 | ||
162 | /// <summary> | 162 | /// <summary> |
163 | /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH | 163 | /// Attach the object containing this script to the avatar that owns it without asking for PERMISSION_ATTACH |
@@ -192,6 +192,29 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces | |||
192 | /// <remarks>Nothing happens if the object is not attached.</remarks> | 192 | /// <remarks>Nothing happens if the object is not attached.</remarks> |
193 | void osForceDetachFromAvatar(); | 193 | void osForceDetachFromAvatar(); |
194 | 194 | ||
195 | /// <summary> | ||
196 | /// Returns a strided list of the specified attachment points and the number of attachments on those points. | ||
197 | /// </summary> | ||
198 | /// <param name="avatar">avatar UUID</param> | ||
199 | /// <param name="attachmentPoints">list of ATTACH_* constants</param> | ||
200 | /// <returns></returns> | ||
201 | LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints); | ||
202 | |||
203 | /// <summary> | ||
204 | /// Sends a specified message to the specified avatar's attachments on | ||
205 | /// the specified attachment points. | ||
206 | /// </summary> | ||
207 | /// <remarks> | ||
208 | /// Behaves as osMessageObject(), without the sending script needing to know the attachment keys in advance. | ||
209 | /// </remarks> | ||
210 | /// <param name="avatar">avatar UUID</param> | ||
211 | /// <param name="message">message string</param> | ||
212 | /// <param name="attachmentPoints">list of ATTACH_* constants, or -1 for all attachments. If -1 is specified and OS_ATTACH_MSG_INVERT_POINTS is present in flags, no action is taken.</param> | ||
213 | /// <param name="flags">flags further constraining the attachments to deliver the message to.</param> | ||
214 | void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags); | ||
215 | |||
216 | #endregion | ||
217 | |||
195 | //texture draw functions | 218 | //texture draw functions |
196 | string osMovePen(string drawList, int x, int y); | 219 | string osMovePen(string drawList, int x, int y); |
197 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); | 220 | string osDrawLine(string drawList, int startX, int startY, int endX, int endY); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs index 05ba222..c788407 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/LSL_Constants.cs | |||
@@ -237,6 +237,58 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
237 | public const int ATTACH_HUD_BOTTOM = 37; | 237 | public const int ATTACH_HUD_BOTTOM = 37; |
238 | public const int ATTACH_HUD_BOTTOM_RIGHT = 38; | 238 | public const int ATTACH_HUD_BOTTOM_RIGHT = 38; |
239 | 239 | ||
240 | #region osMessageAttachments constants | ||
241 | |||
242 | /// <summary> | ||
243 | /// Instructs osMessageAttachements to send the message to attachments | ||
244 | /// on every point. | ||
245 | /// </summary> | ||
246 | /// <remarks> | ||
247 | /// One might expect this to be named OS_ATTACH_ALL, but then one might | ||
248 | /// also expect functions designed to attach or detach or get | ||
249 | /// attachments to work with it too. Attaching a no-copy item to | ||
250 | /// many attachments could be dangerous. | ||
251 | /// when combined with OS_ATTACH_MSG_INVERT_POINTS, will prevent the | ||
252 | /// message from being sent. | ||
253 | /// if combined with OS_ATTACH_MSG_OBJECT_CREATOR or | ||
254 | /// OS_ATTACH_MSG_SCRIPT_CREATOR, could result in no message being | ||
255 | /// sent- this is expected behaviour. | ||
256 | /// </remarks> | ||
257 | public const int OS_ATTACH_MSG_ALL = -65535; | ||
258 | |||
259 | /// <summary> | ||
260 | /// Instructs osMessageAttachements to invert how the attachment points | ||
261 | /// list should be treated (e.g. go from inclusive operation to | ||
262 | /// exclusive operation). | ||
263 | /// </summary> | ||
264 | /// <remarks> | ||
265 | /// This might be used if you want to deliver a message to one set of | ||
266 | /// attachments and a different message to everything else. With | ||
267 | /// this flag, you only need to build one explicit list for both calls. | ||
268 | /// </remarks> | ||
269 | public const int OS_ATTACH_MSG_INVERT_POINTS = 1; | ||
270 | |||
271 | /// <summary> | ||
272 | /// Instructs osMessageAttachments to only send the message to | ||
273 | /// attachments with a CreatorID that matches the host object CreatorID | ||
274 | /// </summary> | ||
275 | /// <remarks> | ||
276 | /// This would be used if distributed in an object vendor/updater server. | ||
277 | /// </remarks> | ||
278 | public const int OS_ATTACH_MSG_OBJECT_CREATOR = 2; | ||
279 | |||
280 | /// <summary> | ||
281 | /// Instructs osMessageAttachments to only send the message to | ||
282 | /// attachments with a CreatorID that matches the sending script CreatorID | ||
283 | /// </summary> | ||
284 | /// <remarks> | ||
285 | /// This might be used if the script is distributed independently of a | ||
286 | /// containing object. | ||
287 | /// </remarks> | ||
288 | public const int OS_ATTACH_MSG_SCRIPT_CREATOR = 4; | ||
289 | |||
290 | #endregion | ||
291 | |||
240 | public const int LAND_LEVEL = 0; | 292 | public const int LAND_LEVEL = 0; |
241 | public const int LAND_RAISE = 1; | 293 | public const int LAND_RAISE = 1; |
242 | public const int LAND_LOWER = 2; | 294 | public const int LAND_LOWER = 2; |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs index ba1ade2..52ca3da 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Runtime/OSSL_Stub.cs | |||
@@ -289,7 +289,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); | 289 | m_OSSL_Functions.osAvatarStopAnimation(avatar, animation); |
290 | } | 290 | } |
291 | 291 | ||
292 | // Avatar functions | 292 | #region Attachment commands |
293 | 293 | ||
294 | public void osForceAttachToAvatar(int attachmentPoint) | 294 | public void osForceAttachToAvatar(int attachmentPoint) |
295 | { | 295 | { |
@@ -311,6 +311,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase | |||
311 | m_OSSL_Functions.osForceDetachFromAvatar(); | 311 | m_OSSL_Functions.osForceDetachFromAvatar(); |
312 | } | 312 | } |
313 | 313 | ||
314 | public LSL_List osGetNumberOfAttachments(LSL_Key avatar, LSL_List attachmentPoints) | ||
315 | { | ||
316 | return m_OSSL_Functions.osGetNumberOfAttachments(avatar, attachmentPoints); | ||
317 | } | ||
318 | |||
319 | public void osMessageAttachments(LSL_Key avatar, string message, LSL_List attachmentPoints, int flags) | ||
320 | { | ||
321 | m_OSSL_Functions.osMessageAttachments(avatar, message, attachmentPoints, flags); | ||
322 | } | ||
323 | |||
324 | #endregion | ||
325 | |||
314 | // Texture Draw functions | 326 | // Texture Draw functions |
315 | 327 | ||
316 | public string osMovePen(string drawList, int x, int y) | 328 | public string osMovePen(string drawList, int x, int y) |