diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/UuidGatherer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 81 |
1 files changed, 55 insertions, 26 deletions
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs index 3e074b9..75a51b5 100644 --- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs +++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs | |||
@@ -38,6 +38,7 @@ using OpenMetaverse.StructuredData; | |||
38 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
39 | using OpenSim.Region.Framework.Scenes.Serialization; | 39 | using OpenSim.Region.Framework.Scenes.Serialization; |
40 | using OpenSim.Services.Interfaces; | 40 | using OpenSim.Services.Interfaces; |
41 | using OpenSimAssetType = OpenSim.Framework.SLUtil.OpenSimAssetType; | ||
41 | 42 | ||
42 | namespace OpenSim.Region.Framework.Scenes | 43 | namespace 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 | assetUuids[textureEntry.DefaultTexture.TextureID] = (sbyte)AssetType.Texture; |
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 | assetUuids[texture.TextureID] = (sbyte)AssetType.Texture; |
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,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
225 | } | 232 | } |
226 | } | 233 | } |
227 | } | 234 | } |
228 | 235 | ||
229 | // /// <summary> | 236 | // /// <summary> |
230 | // /// The callback made when we request the asset for an object from the asset service. | 237 | // /// The callback made when we request the asset for an object from the asset service. |
231 | // /// </summary> | 238 | // /// </summary> |
@@ -241,10 +248,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
241 | 248 | ||
242 | /// <summary> | 249 | /// <summary> |
243 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps | 250 | /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps |
251 | /// stored in legacy format in part.DynAttrs | ||
244 | /// </summary> | 252 | /// </summary> |
245 | /// <param name="part"></param> | 253 | /// <param name="part"></param> |
246 | /// <param name="assetUuids"></param> | 254 | /// <param name="assetUuids"></param> |
247 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) | 255 | //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) |
256 | public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> assetUuids) | ||
248 | { | 257 | { |
249 | // scan thru the dynAttrs map of this part for any textures used as materials | 258 | // scan thru the dynAttrs map of this part for any textures used as materials |
250 | OSD osdMaterials = null; | 259 | OSD osdMaterials = null; |
@@ -280,7 +289,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
280 | UUID normalMapId = mat["NormMap"].AsUUID(); | 289 | UUID normalMapId = mat["NormMap"].AsUUID(); |
281 | if (normalMapId != UUID.Zero) | 290 | if (normalMapId != UUID.Zero) |
282 | { | 291 | { |
283 | assetUuids[normalMapId] = AssetType.Texture; | 292 | assetUuids[normalMapId] = (sbyte)AssetType.Texture; |
284 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); | 293 | //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString()); |
285 | } | 294 | } |
286 | } | 295 | } |
@@ -289,7 +298,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
289 | UUID specularMapId = mat["SpecMap"].AsUUID(); | 298 | UUID specularMapId = mat["SpecMap"].AsUUID(); |
290 | if (specularMapId != UUID.Zero) | 299 | if (specularMapId != UUID.Zero) |
291 | { | 300 | { |
292 | assetUuids[specularMapId] = AssetType.Texture; | 301 | assetUuids[specularMapId] = (sbyte)AssetType.Texture; |
293 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); | 302 | //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString()); |
294 | } | 303 | } |
295 | } | 304 | } |
@@ -344,7 +353,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
344 | /// </summary> | 353 | /// </summary> |
345 | /// <param name="scriptUuid"></param> | 354 | /// <param name="scriptUuid"></param> |
346 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 355 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
347 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, AssetType> assetUuids) | 356 | private void GetTextEmbeddedAssetUuids(UUID embeddingAssetId, IDictionary<UUID, sbyte> assetUuids) |
348 | { | 357 | { |
349 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); | 358 | // m_log.DebugFormat("[ASSET GATHERER]: Getting assets for uuid references in asset {0}", embeddingAssetId); |
350 | 359 | ||
@@ -364,7 +373,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
364 | 373 | ||
365 | // Embedded asset references (if not false positives) could be for many types of asset, so we will | 374 | // Embedded asset references (if not false positives) could be for many types of asset, so we will |
366 | // label these as unknown. | 375 | // label these as unknown. |
367 | assetUuids[uuid] = AssetType.Unknown; | 376 | assetUuids[uuid] = (sbyte)AssetType.Unknown; |
368 | } | 377 | } |
369 | } | 378 | } |
370 | } | 379 | } |
@@ -374,7 +383,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
374 | /// </summary> | 383 | /// </summary> |
375 | /// <param name="wearableAssetUuid"></param> | 384 | /// <param name="wearableAssetUuid"></param> |
376 | /// <param name="assetUuids">Dictionary in which to record the references</param> | 385 | /// <param name="assetUuids">Dictionary in which to record the references</param> |
377 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, AssetType> assetUuids) | 386 | private void GetWearableAssetUuids(UUID wearableAssetUuid, IDictionary<UUID, sbyte> assetUuids) |
378 | { | 387 | { |
379 | AssetBase assetBase = GetAsset(wearableAssetUuid); | 388 | AssetBase assetBase = GetAsset(wearableAssetUuid); |
380 | 389 | ||
@@ -389,7 +398,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
389 | 398 | ||
390 | foreach (UUID uuid in wearableAsset.Textures.Values) | 399 | foreach (UUID uuid in wearableAsset.Textures.Values) |
391 | { | 400 | { |
392 | assetUuids[uuid] = AssetType.Texture; | 401 | assetUuids[uuid] = (sbyte)AssetType.Texture; |
393 | } | 402 | } |
394 | } | 403 | } |
395 | } | 404 | } |
@@ -401,7 +410,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
401 | /// </summary> | 410 | /// </summary> |
402 | /// <param name="sceneObject"></param> | 411 | /// <param name="sceneObject"></param> |
403 | /// <param name="assetUuids"></param> | 412 | /// <param name="assetUuids"></param> |
404 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, AssetType> assetUuids) | 413 | private void GetSceneObjectAssetUuids(UUID sceneObjectUuid, IDictionary<UUID, sbyte> assetUuids) |
405 | { | 414 | { |
406 | AssetBase objectAsset = GetAsset(sceneObjectUuid); | 415 | AssetBase objectAsset = GetAsset(sceneObjectUuid); |
407 | 416 | ||
@@ -430,7 +439,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
430 | /// </summary> | 439 | /// </summary> |
431 | /// <param name="gestureUuid"></param> | 440 | /// <param name="gestureUuid"></param> |
432 | /// <param name="assetUuids"></param> | 441 | /// <param name="assetUuids"></param> |
433 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, AssetType> assetUuids) | 442 | private void GetGestureAssetUuids(UUID gestureUuid, IDictionary<UUID, sbyte> assetUuids) |
434 | { | 443 | { |
435 | AssetBase assetBase = GetAsset(gestureUuid); | 444 | AssetBase assetBase = GetAsset(gestureUuid); |
436 | if (null == assetBase) | 445 | if (null == assetBase) |
@@ -464,9 +473,29 @@ namespace OpenSim.Region.Framework.Scenes | |||
464 | // If it can be parsed as a UUID, it is an asset ID | 473 | // If it can be parsed as a UUID, it is an asset ID |
465 | UUID uuid; | 474 | UUID uuid; |
466 | if (UUID.TryParse(id, out uuid)) | 475 | if (UUID.TryParse(id, out uuid)) |
467 | assetUuids[uuid] = AssetType.Animation; | 476 | assetUuids[uuid] = (sbyte)AssetType.Animation; |
468 | } | 477 | } |
469 | } | 478 | } |
479 | |||
480 | /// <summary> | ||
481 | /// Get the asset uuid's referenced in a material. | ||
482 | /// </summary> | ||
483 | private void GetMaterialAssetUuids(UUID materialUuid, IDictionary<UUID, sbyte> assetUuids) | ||
484 | { | ||
485 | AssetBase assetBase = GetAsset(materialUuid); | ||
486 | if (null == assetBase) | ||
487 | return; | ||
488 | |||
489 | OSDMap mat = (OSDMap)OSDParser.DeserializeLLSDXml(assetBase.Data); | ||
490 | |||
491 | UUID normMap = mat["NormMap"].AsUUID(); | ||
492 | if (normMap != UUID.Zero) | ||
493 | assetUuids[normMap] = (sbyte)AssetType.Texture; | ||
494 | |||
495 | UUID specMap = mat["SpecMap"].AsUUID(); | ||
496 | if (specMap != UUID.Zero) | ||
497 | assetUuids[specMap] = (sbyte)AssetType.Texture; | ||
498 | } | ||
470 | } | 499 | } |
471 | 500 | ||
472 | public class HGUuidGatherer : UuidGatherer | 501 | public class HGUuidGatherer : UuidGatherer |