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.cs81
1 files changed, 55 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index d8309d8..67655d6 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -38,6 +38,7 @@ using OpenMetaverse.StructuredData;
38using OpenSim.Framework; 38using OpenSim.Framework;
39using OpenSim.Region.Framework.Scenes.Serialization; 39using OpenSim.Region.Framework.Scenes.Serialization;
40using OpenSim.Services.Interfaces; 40using OpenSim.Services.Interfaces;
41using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType;
41 42
42namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
43{ 44{
@@ -83,29 +84,33 @@ namespace OpenSim.Region.Framework.Scenes
83 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param> 84 /// <param name="assetUuid">The uuid of the asset for which to gather referenced assets</param>
84 /// <param name="assetType">The type of the asset for the uuid given</param> 85 /// <param name="assetType">The type of the asset for the uuid given</param>
85 /// <param name="assetUuids">The assets gathered</param> 86 /// <param name="assetUuids">The assets gathered</param>
86 public void GatherAssetUuids(UUID assetUuid, AssetType assetType, IDictionary<UUID, AssetType> assetUuids) 87 public void GatherAssetUuids(UUID assetUuid, sbyte assetType, IDictionary<UUID, sbyte> assetUuids)
87 { 88 {
88 try 89 try
89 { 90 {
90 assetUuids[assetUuid] = assetType; 91 assetUuids[assetUuid] = assetType;
91 92
92 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 93 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
93 { 94 {
94 GetWearableAssetUuids(assetUuid, assetUuids); 95 GetWearableAssetUuids(assetUuid, assetUuids);
95 } 96 }
96 else if (AssetType.Gesture == assetType) 97 else if ((sbyte)AssetType.Gesture == assetType)
97 { 98 {
98 GetGestureAssetUuids(assetUuid, assetUuids); 99 GetGestureAssetUuids(assetUuid, assetUuids);
99 } 100 }
100 else if (AssetType.Notecard == assetType) 101 else if ((sbyte)AssetType.Notecard == assetType)
101 { 102 {
102 GetTextEmbeddedAssetUuids(assetUuid, assetUuids); 103 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
103 } 104 }
104 else if (AssetType.LSLText == assetType) 105 else if ((sbyte)AssetType.LSLText == assetType)
105 { 106 {
106 GetTextEmbeddedAssetUuids(assetUuid, assetUuids); 107 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
107 } 108 }
108 else if (AssetType.Object == assetType) 109 else if ((sbyte)OpenSimAssetType.Material == assetType)
110 {
111 GetMaterialAssetUuids(assetUuid, assetUuids);
112 }
113 else if ((sbyte)AssetType.Object == assetType)
109 { 114 {
110 GetSceneObjectAssetUuids(assetUuid, assetUuids); 115 GetSceneObjectAssetUuids(assetUuid, assetUuids);
111 } 116 }
@@ -132,7 +137,7 @@ namespace OpenSim.Region.Framework.Scenes
132 /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. 137 /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset.
133 /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. 138 /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown.
134 /// </param> 139 /// </param>
135 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) 140 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, sbyte> assetUuids)
136 { 141 {
137// m_log.DebugFormat( 142// m_log.DebugFormat(
138// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 143// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -152,7 +157,7 @@ namespace OpenSim.Region.Framework.Scenes
152 { 157 {
153 // Get the prim's default texture. This will be used for faces which don't have their own texture 158 // Get the prim's default texture. This will be used for faces which don't have their own texture
154 if (textureEntry.DefaultTexture != null) 159 if (textureEntry.DefaultTexture != null)
155 assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; 160 assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture;
156 161
157 if (textureEntry.FaceTextures != null) 162 if (textureEntry.FaceTextures != null)
158 { 163 {
@@ -160,20 +165,20 @@ namespace OpenSim.Region.Framework.Scenes
160 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) 165 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
161 { 166 {
162 if (texture != null) 167 if (texture != null)
163 assetUuids[texture.TextureID] = AssetType.Texture; 168 assetUuids[texture.TextureID] = (sbyte)AssetType.Texture;
164 } 169 }
165 } 170 }
166 } 171 }
167 172
168 // If the prim is a sculpt then preserve this information too 173 // If the prim is a sculpt then preserve this information too
169 if (part.Shape.SculptTexture != UUID.Zero) 174 if (part.Shape.SculptTexture != UUID.Zero)
170 assetUuids[part.Shape.SculptTexture] = AssetType.Texture; 175 assetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
171 176
172 if (part.Shape.ProjectionTextureUUID != UUID.Zero) 177 if (part.Shape.ProjectionTextureUUID != UUID.Zero)
173 assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture; 178 assetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
174 179
175 if (part.CollisionSound != UUID.Zero) 180 if (part.CollisionSound != UUID.Zero)
176 assetUuids[part.CollisionSound] = AssetType.Sound; 181 assetUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
177 182
178 if (part.ParticleSystem.Length > 0) 183 if (part.ParticleSystem.Length > 0)
179 { 184 {
@@ -181,7 +186,7 @@ namespace OpenSim.Region.Framework.Scenes
181 { 186 {
182 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); 187 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
183 if (ps.Texture != UUID.Zero) 188 if (ps.Texture != UUID.Zero)
184 assetUuids[ps.Texture] = AssetType.Texture; 189 assetUuids[ps.Texture] = (sbyte)AssetType.Texture;
185 } 190 }
186 catch (Exception e) 191 catch (Exception e)
187 { 192 {
@@ -201,7 +206,7 @@ namespace OpenSim.Region.Framework.Scenes
201// tii.Name, tii.Type, part.Name, part.UUID); 206// tii.Name, tii.Type, part.Name, part.UUID);
202 207
203 if (!assetUuids.ContainsKey(tii.AssetID)) 208 if (!assetUuids.ContainsKey(tii.AssetID))
204 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); 209 GatherAssetUuids(tii.AssetID, (sbyte)tii.Type, assetUuids);
205 } 210 }
206 211
207 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed 212 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
@@ -210,7 +215,9 @@ namespace OpenSim.Region.Framework.Scenes
210 // Scene.EventManager is present. 215 // Scene.EventManager is present.
211// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); 216// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
212 217
213 GatherMaterialsUuids(part, assetUuids); 218
219 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
220 GatherMaterialsUuids(part, assetUuids);
214 } 221 }
215 catch (Exception e) 222 catch (Exception e)
216 { 223 {
@@ -221,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
221 } 228 }
222 } 229 }
223 } 230 }
224 231
225// /// <summary> 232// /// <summary>
226// /// The callback made when we request the asset for an object from the asset service. 233// /// The callback made when we request the asset for an object from the asset service.
227// /// </summary> 234// /// </summary>
@@ -237,10 +244,12 @@ namespace OpenSim.Region.Framework.Scenes
237 244
238 /// <summary> 245 /// <summary>
239 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps 246 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
247 /// stored in legacy format in part.DynAttrs
240 /// </summary> 248 /// </summary>
241 /// <param name="part"></param> 249 /// <param name="part"></param>
242 /// <param name="assetUuids"></param> 250 /// <param name="assetUuids"></param>
243 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) 251 //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
252 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids)
244 { 253 {
245 // scan thru the dynAttrs map of this part for any textures used as materials 254 // scan thru the dynAttrs map of this part for any textures used as materials
246 OSD osdMaterials = null; 255 OSD osdMaterials = null;
@@ -276,7 +285,7 @@ namespace OpenSim.Region.Framework.Scenes
276 UUID normalMapId = mat["NormMap"].AsUUID(); 285 UUID normalMapId = mat["NormMap"].AsUUID();
277 if (normalMapId != UUID.Zero) 286 if (normalMapId != UUID.Zero)
278 { 287 {
279 assetUuids[normalMapId] = AssetType.Texture; 288 assetUuids[normalMapId] = (sbyte)AssetType.Texture;
280 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); 289 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
281 } 290 }
282 } 291 }
@@ -285,7 +294,7 @@ namespace OpenSim.Region.Framework.Scenes
285 UUID specularMapId = mat["SpecMap"].AsUUID(); 294 UUID specularMapId = mat["SpecMap"].AsUUID();
286 if (specularMapId != UUID.Zero) 295 if (specularMapId != UUID.Zero)
287 { 296 {
288 assetUuids[specularMapId] = AssetType.Texture; 297 assetUuids[specularMapId] = (sbyte)AssetType.Texture;
289 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); 298 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
290 } 299 }
291 } 300 }
@@ -340,7 +349,7 @@ namespace OpenSim.Region.Framework.Scenes
340 /// </summary> 349 /// </summary>
341 /// <param name="scriptUuid"></param> 350 /// <param name="scriptUuid"></param>
342 /// <param name="assetUuids">Dictionary in which to record the references</param> 351 /// <param name="assetUuids">Dictionary in which to record the references</param>
343 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) 352 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids)
344 { 353 {
345// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); 354// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);
346 355
@@ -360,7 +369,7 @@ namespace OpenSim.Region.Framework.Scenes
360 369
361 // Embedded asset references (if not false positives) could be for many types of asset, so we will 370 // Embedded asset references (if not false positives) could be for many types of asset, so we will
362 // label these as unknown. 371 // label these as unknown.
363 assetUuids[uuid] = AssetType.Unknown; 372 assetUuids[uuid] = (sbyte)AssetType.Unknown;
364 } 373 }
365 } 374 }
366 } 375 }
@@ -370,7 +379,7 @@ namespace OpenSim.Region.Framework.Scenes
370 /// </summary> 379 /// </summary>
371 /// <param name="wearableAssetUuid"></param> 380 /// <param name="wearableAssetUuid"></param>
372 /// <param name="assetUuids">Dictionary in which to record the references</param> 381 /// <param name="assetUuids">Dictionary in which to record the references</param>
373 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) 382 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids)
374 { 383 {
375 AssetBase assetBase = GetAsset(wearableAssetUuid); 384 AssetBase assetBase = GetAsset(wearableAssetUuid);
376 385
@@ -385,7 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
385 394
386 foreach (UUID uuid in wearableAsset.Textures.Values) 395 foreach (UUID uuid in wearableAsset.Textures.Values)
387 { 396 {
388 assetUuids[uuid] = AssetType.Texture; 397 assetUuids[uuid] = (sbyte)AssetType.Texture;
389 } 398 }
390 } 399 }
391 } 400 }
@@ -397,7 +406,7 @@ namespace OpenSim.Region.Framework.Scenes
397 /// </summary> 406 /// </summary>
398 /// <param name="sceneObject"></param> 407 /// <param name="sceneObject"></param>
399 /// <param name="assetUuids"></param> 408 /// <param name="assetUuids"></param>
400 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) 409 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids)
401 { 410 {
402 AssetBase objectAsset = GetAsset(sceneObjectUuid); 411 AssetBase objectAsset = GetAsset(sceneObjectUuid);
403 412
@@ -426,7 +435,7 @@ namespace OpenSim.Region.Framework.Scenes
426 /// </summary> 435 /// </summary>
427 /// <param name="gestureUuid"></param> 436 /// <param name="gestureUuid"></param>
428 /// <param name="assetUuids"></param> 437 /// <param name="assetUuids"></param>
429 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) 438 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids)
430 { 439 {
431 AssetBase assetBase = GetAsset(gestureUuid); 440 AssetBase assetBase = GetAsset(gestureUuid);
432 if (null == assetBase) 441 if (null == assetBase)
@@ -460,9 +469,29 @@ namespace OpenSim.Region.Framework.Scenes
460 // If it can be parsed as a UUID, it is an asset ID 469 // If it can be parsed as a UUID, it is an asset ID
461 UUID uuid; 470 UUID uuid;
462 if (UUID.TryParse(id, out uuid)) 471 if (UUID.TryParse(id, out uuid))
463 assetUuids[uuid] = AssetType.Animation; 472 assetUuids[uuid] = (sbyte)AssetType.Animation;
464 } 473 }
465 } 474 }
475
476 /// <summary>
477 /// Get the asset uuid's referenced in a material.
478 /// </summary>
479 private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids)
480 {
481 AssetBase assetBase = GetAsset(materialUuid);
482 if (null == assetBase)
483 return;
484
485 OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data);
486
487 UUID normMap = mat["NormMap"].AsUUID();
488 if (normMap != UUID.Zero)
489 assetUuids[normMap] = (sbyte)AssetType.Texture;
490
491 UUID specMap = mat["SpecMap"].AsUUID();
492 if (specMap != UUID.Zero)
493 assetUuids[specMap] = (sbyte)AssetType.Texture;
494 }
466 } 495 }
467 496
468 public class HGUuidGatherer : UuidGatherer 497 public class HGUuidGatherer : UuidGatherer