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.cs94
1 files changed, 68 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 3e074b9..fe6cb84 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,7 +84,7 @@ 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 // avoid infinite loops 89 // avoid infinite loops
89 if (assetUuids.ContainsKey(assetUuid)) 90 if (assetUuids.ContainsKey(assetUuid))
@@ -93,23 +94,27 @@ namespace OpenSim.Region.Framework.Scenes
93 { 94 {
94 assetUuids[assetUuid] = assetType; 95 assetUuids[assetUuid] = assetType;
95 96
96 if (AssetType.Bodypart == assetType || AssetType.Clothing == assetType) 97 if ((sbyte)AssetType.Bodypart == assetType || (sbyte)AssetType.Clothing == assetType)
97 { 98 {
98 GetWearableAssetUuids(assetUuid, assetUuids); 99 GetWearableAssetUuids(assetUuid, assetUuids);
99 } 100 }
100 else if (AssetType.Gesture == assetType) 101 else if ((sbyte)AssetType.Gesture == assetType)
101 { 102 {
102 GetGestureAssetUuids(assetUuid, assetUuids); 103 GetGestureAssetUuids(assetUuid, assetUuids);
103 } 104 }
104 else if (AssetType.Notecard == assetType) 105 else if ((sbyte)AssetType.Notecard == assetType)
105 { 106 {
106 GetTextEmbeddedAssetUuids(assetUuid, assetUuids); 107 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
107 } 108 }
108 else if (AssetType.LSLText == assetType) 109 else if ((sbyte)AssetType.LSLText == assetType)
109 { 110 {
110 GetTextEmbeddedAssetUuids(assetUuid, assetUuids); 111 GetTextEmbeddedAssetUuids(assetUuid, assetUuids);
111 } 112 }
112 else if (AssetType.Object == assetType) 113 else if ((sbyte)OpenSimAssetType.Material == assetType)
114 {
115 GetMaterialAssetUuids(assetUuid, assetUuids);
116 }
117 else if ((sbyte)AssetType.Object == assetType)
113 { 118 {
114 GetSceneObjectAssetUuids(assetUuid, assetUuids); 119 GetSceneObjectAssetUuids(assetUuid, assetUuids);
115 } 120 }
@@ -136,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes
136 /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset. 141 /// A dictionary which is populated with the asset UUIDs gathered and the type of that asset.
137 /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown. 142 /// For assets where the type is not clear (e.g. UUIDs extracted from LSL and notecards), the type is Unknown.
138 /// </param> 143 /// </param>
139 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, AssetType> assetUuids) 144 public void GatherAssetUuids(SceneObjectGroup sceneObject, IDictionary<UUID, sbyte> assetUuids)
140 { 145 {
141// m_log.DebugFormat( 146// m_log.DebugFormat(
142// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID); 147// "[ASSET GATHERER]: Getting assets for object {0}, {1}", sceneObject.Name, sceneObject.UUID);
@@ -156,7 +161,7 @@ namespace OpenSim.Region.Framework.Scenes
156 { 161 {
157 // Get the prim's default texture. This will be used for faces which don't have their own texture 162 // Get the prim's default texture. This will be used for faces which don't have their own texture
158 if (textureEntry.DefaultTexture != null) 163 if (textureEntry.DefaultTexture != null)
159 assetUuids[textureEntry.DefaultTexture.TextureID] = AssetType.Texture; 164 GatherTextureEntryAssets(textureEntry.DefaultTexture, assetUuids);
160 165
161 if (textureEntry.FaceTextures != null) 166 if (textureEntry.FaceTextures != null)
162 { 167 {
@@ -164,20 +169,20 @@ namespace OpenSim.Region.Framework.Scenes
164 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures) 169 foreach (Primitive.TextureEntryFace texture in textureEntry.FaceTextures)
165 { 170 {
166 if (texture != null) 171 if (texture != null)
167 assetUuids[texture.TextureID] = AssetType.Texture; 172 GatherTextureEntryAssets(texture, assetUuids);
168 } 173 }
169 } 174 }
170 } 175 }
171 176
172 // If the prim is a sculpt then preserve this information too 177 // If the prim is a sculpt then preserve this information too
173 if (part.Shape.SculptTexture != UUID.Zero) 178 if (part.Shape.SculptTexture != UUID.Zero)
174 assetUuids[part.Shape.SculptTexture] = AssetType.Texture; 179 assetUuids[part.Shape.SculptTexture] = (sbyte)AssetType.Texture;
175 180
176 if (part.Shape.ProjectionTextureUUID != UUID.Zero) 181 if (part.Shape.ProjectionTextureUUID != UUID.Zero)
177 assetUuids[part.Shape.ProjectionTextureUUID] = AssetType.Texture; 182 assetUuids[part.Shape.ProjectionTextureUUID] = (sbyte)AssetType.Texture;
178 183
179 if (part.CollisionSound != UUID.Zero) 184 if (part.CollisionSound != UUID.Zero)
180 assetUuids[part.CollisionSound] = AssetType.Sound; 185 assetUuids[part.CollisionSound] = (sbyte)AssetType.Sound;
181 186
182 if (part.ParticleSystem.Length > 0) 187 if (part.ParticleSystem.Length > 0)
183 { 188 {
@@ -185,7 +190,7 @@ namespace OpenSim.Region.Framework.Scenes
185 { 190 {
186 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0); 191 Primitive.ParticleSystem ps = new Primitive.ParticleSystem(part.ParticleSystem, 0);
187 if (ps.Texture != UUID.Zero) 192 if (ps.Texture != UUID.Zero)
188 assetUuids[ps.Texture] = AssetType.Texture; 193 assetUuids[ps.Texture] = (sbyte)AssetType.Texture;
189 } 194 }
190 catch (Exception e) 195 catch (Exception e)
191 { 196 {
@@ -205,7 +210,7 @@ namespace OpenSim.Region.Framework.Scenes
205// tii.Name, tii.Type, part.Name, part.UUID); 210// tii.Name, tii.Type, part.Name, part.UUID);
206 211
207 if (!assetUuids.ContainsKey(tii.AssetID)) 212 if (!assetUuids.ContainsKey(tii.AssetID))
208 GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); 213 GatherAssetUuids(tii.AssetID, (sbyte)tii.Type, assetUuids);
209 } 214 }
210 215
211 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed 216 // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
@@ -214,7 +219,9 @@ namespace OpenSim.Region.Framework.Scenes
214 // Scene.EventManager is present. 219 // Scene.EventManager is present.
215// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); 220// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
216 221
217 GatherMaterialsUuids(part, assetUuids); 222
223 // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
224 GatherMaterialsUuids(part, assetUuids);
218 } 225 }
219 catch (Exception e) 226 catch (Exception e)
220 { 227 {
@@ -225,7 +232,20 @@ namespace OpenSim.Region.Framework.Scenes
225 } 232 }
226 } 233 }
227 } 234 }
228 235
236 /// <summary>
237 /// Gather all the asset uuids found in one face of a Texture Entry.
238 /// </summary>
239 private void GatherTextureEntryAssets(Primitive.TextureEntryFace texture, IDictionary<UUID, sbyte> assetUuids)
240 {
241 assetUuids[texture.TextureID] = (sbyte)AssetType.Texture;
242
243 if (texture.MaterialID != UUID.Zero)
244 {
245 GatherAssetUuids(texture.MaterialID, (sbyte)OpenSimAssetType.Material, assetUuids);
246 }
247 }
248
229// /// <summary> 249// /// <summary>
230// /// The callback made when we request the asset for an object from the asset service. 250// /// The callback made when we request the asset for an object from the asset service.
231// /// </summary> 251// /// </summary>
@@ -241,10 +261,12 @@ namespace OpenSim.Region.Framework.Scenes
241 261
242 /// <summary> 262 /// <summary>
243 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps 263 /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
264 /// stored in legacy format in part.DynAttrs
244 /// </summary> 265 /// </summary>
245 /// <param name="part"></param> 266 /// <param name="part"></param>
246 /// <param name="assetUuids"></param> 267 /// <param name="assetUuids"></param>
247 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) 268 //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
269 public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids)
248 { 270 {
249 // scan thru the dynAttrs map of this part for any textures used as materials 271 // scan thru the dynAttrs map of this part for any textures used as materials
250 OSD osdMaterials = null; 272 OSD osdMaterials = null;
@@ -280,7 +302,7 @@ namespace OpenSim.Region.Framework.Scenes
280 UUID normalMapId = mat["NormMap"].AsUUID(); 302 UUID normalMapId = mat["NormMap"].AsUUID();
281 if (normalMapId != UUID.Zero) 303 if (normalMapId != UUID.Zero)
282 { 304 {
283 assetUuids[normalMapId] = AssetType.Texture; 305 assetUuids[normalMapId] = (sbyte)AssetType.Texture;
284 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); 306 //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
285 } 307 }
286 } 308 }
@@ -289,7 +311,7 @@ namespace OpenSim.Region.Framework.Scenes
289 UUID specularMapId = mat["SpecMap"].AsUUID(); 311 UUID specularMapId = mat["SpecMap"].AsUUID();
290 if (specularMapId != UUID.Zero) 312 if (specularMapId != UUID.Zero)
291 { 313 {
292 assetUuids[specularMapId] = AssetType.Texture; 314 assetUuids[specularMapId] = (sbyte)AssetType.Texture;
293 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); 315 //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
294 } 316 }
295 } 317 }
@@ -344,7 +366,7 @@ namespace OpenSim.Region.Framework.Scenes
344 /// </summary> 366 /// </summary>
345 /// <param name="scriptUuid"></param> 367 /// <param name="scriptUuid"></param>
346 /// <param name="assetUuids">Dictionary in which to record the references</param> 368 /// <param name="assetUuids">Dictionary in which to record the references</param>
347 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) 369 private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids)
348 { 370 {
349// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); 371// m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId);
350 372
@@ -364,7 +386,7 @@ namespace OpenSim.Region.Framework.Scenes
364 386
365 // Embedded asset references (if not false positives) could be for many types of asset, so we will 387 // Embedded asset references (if not false positives) could be for many types of asset, so we will
366 // label these as unknown. 388 // label these as unknown.
367 assetUuids[uuid] = AssetType.Unknown; 389 assetUuids[uuid] = (sbyte)AssetType.Unknown;
368 } 390 }
369 } 391 }
370 } 392 }
@@ -374,7 +396,7 @@ namespace OpenSim.Region.Framework.Scenes
374 /// </summary> 396 /// </summary>
375 /// <param name="wearableAssetUuid"></param> 397 /// <param name="wearableAssetUuid"></param>
376 /// <param name="assetUuids">Dictionary in which to record the references</param> 398 /// <param name="assetUuids">Dictionary in which to record the references</param>
377 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) 399 private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids)
378 { 400 {
379 AssetBase assetBase = GetAsset(wearableAssetUuid); 401 AssetBase assetBase = GetAsset(wearableAssetUuid);
380 402
@@ -389,7 +411,7 @@ namespace OpenSim.Region.Framework.Scenes
389 411
390 foreach (UUID uuid in wearableAsset.Textures.Values) 412 foreach (UUID uuid in wearableAsset.Textures.Values)
391 { 413 {
392 assetUuids[uuid] = AssetType.Texture; 414 assetUuids[uuid] = (sbyte)AssetType.Texture;
393 } 415 }
394 } 416 }
395 } 417 }
@@ -401,7 +423,7 @@ namespace OpenSim.Region.Framework.Scenes
401 /// </summary> 423 /// </summary>
402 /// <param name="sceneObject"></param> 424 /// <param name="sceneObject"></param>
403 /// <param name="assetUuids"></param> 425 /// <param name="assetUuids"></param>
404 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) 426 private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids)
405 { 427 {
406 AssetBase objectAsset = GetAsset(sceneObjectUuid); 428 AssetBase objectAsset = GetAsset(sceneObjectUuid);
407 429
@@ -430,7 +452,7 @@ namespace OpenSim.Region.Framework.Scenes
430 /// </summary> 452 /// </summary>
431 /// <param name="gestureUuid"></param> 453 /// <param name="gestureUuid"></param>
432 /// <param name="assetUuids"></param> 454 /// <param name="assetUuids"></param>
433 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) 455 private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids)
434 { 456 {
435 AssetBase assetBase = GetAsset(gestureUuid); 457 AssetBase assetBase = GetAsset(gestureUuid);
436 if (null == assetBase) 458 if (null == assetBase)
@@ -464,9 +486,29 @@ namespace OpenSim.Region.Framework.Scenes
464 // If it can be parsed as a UUID, it is an asset ID 486 // If it can be parsed as a UUID, it is an asset ID
465 UUID uuid; 487 UUID uuid;
466 if (UUID.TryParse(id, out uuid)) 488 if (UUID.TryParse(id, out uuid))
467 assetUuids[uuid] = AssetType.Animation; 489 assetUuids[uuid] = (sbyte)AssetType.Animation;
468 } 490 }
469 } 491 }
492
493 /// <summary>
494 /// Get the asset uuid's referenced in a material.
495 /// </summary>
496 private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids)
497 {
498 AssetBase assetBase = GetAsset(materialUuid);
499 if (null == assetBase)
500 return;
501
502 OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data);
503
504 UUID normMap = mat["NormMap"].AsUUID();
505 if (normMap != UUID.Zero)
506 assetUuids[normMap] = (sbyte)AssetType.Texture;
507
508 UUID specMap = mat["SpecMap"].AsUUID();
509 if (specMap != UUID.Zero)
510 assetUuids[specMap] = (sbyte)AssetType.Texture;
511 }
470 } 512 }
471 513
472 public class HGUuidGatherer : UuidGatherer 514 public class HGUuidGatherer : UuidGatherer