aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/UuidGatherer.cs76
1 files changed, 76 insertions, 0 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index b09ae39..e60a025 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -34,6 +34,7 @@ using System.Threading;
34using log4net; 34using log4net;
35using OpenMetaverse; 35using OpenMetaverse;
36using OpenMetaverse.Assets; 36using OpenMetaverse.Assets;
37using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Region.Framework.Scenes.Serialization; 39using OpenSim.Region.Framework.Scenes.Serialization;
39using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
@@ -180,6 +181,14 @@ namespace OpenSim.Region.Framework.Scenes
180 if (!assetUuids.ContainsKey(tii.AssetID)) 181 if (!assetUuids.ContainsKey(tii.AssetID))
181 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); 182 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
182 } 183 }
184
185 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
186 // to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
187 // inventory transfer. There needs to be a way for a module to register a method without assuming a
188 // Scene.EventManager is present.
189// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
190
191 GatherMaterialsUuids(part, assetUuids);
183 } 192 }
184 catch (Exception e) 193 catch (Exception e)
185 { 194 {
@@ -205,6 +214,73 @@ namespace OpenSim.Region.Framework.Scenes
205// } 214// }
206 215
207 /// <summary> 216 /// <summary>
217 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
218 /// </summary>
219 /// <param name="part"></param>
220 /// <param name="assetUuids"></param>
221 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
222 {
223 // scan thru the dynAttrs map of this part for any textures used as materials
224 OSD osdMaterials = null;
225
226 lock (part.DynAttrs)
227 {
228 if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
229 {
230 OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
231
232 if (materialsStore == null)
233 return;
234
235 materialsStore.TryGetValue("Materials", out osdMaterials);
236 }
237
238 if (osdMaterials != null)
239 {
240 //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
241
242 if (osdMaterials is OSDArray)
243 {
244 OSDArray matsArr = osdMaterials as OSDArray;
245 foreach (OSDMap matMap in matsArr)
246 {
247 try
248 {
249 if (matMap.ContainsKey("Material"))
250 {
251 OSDMap mat = matMap["Material"] as OSDMap;
252 if (mat.ContainsKey("NormMap"))
253 {
254 UUID normalMapId = mat["NormMap"].AsUUID();
255 if (normalMapId != UUID.Zero)
256 {
257 assetUuids[normalMapId] = AssetType.Texture;
258 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
259 }
260 }
261 if (mat.ContainsKey("SpecMap"))
262 {
263 UUID specularMapId = mat["SpecMap"].AsUUID();
264 if (specularMapId != UUID.Zero)
265 {
266 assetUuids[specularMapId] = AssetType.Texture;
267 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
268 }
269 }
270 }
271
272 }
273 catch (Exception e)
274 {
275 m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message);
276 }
277 }
278 }
279 }
280 }
281 }
282
283 /// <summary>
208 /// Get an asset synchronously, potentially using an asynchronous callback. If the 284 /// Get an asset synchronously, potentially using an asynchronous callback. If the
209 /// asynchronous callback is used, we will wait for it to complete. 285 /// asynchronous callback is used, we will wait for it to complete.
210 /// </summary> 286 /// </summary>