From 7bd42fc42f0d945fe96b058d06f14c091d96b2d2 Mon Sep 17 00:00:00 2001
From: dahlia
Date: Mon, 20 Jan 2014 15:01:18 -0800
Subject: Add back code to UuidGatherer to retrieve UUIDs for materials stored
in DynAttrs. This is unfortunately still necessary until a better solution
for handling existing legacy materials can be implemented
---
OpenSim/Region/Framework/Scenes/UuidGatherer.cs | 73 +++++++++++++++++++++++++
1 file changed, 73 insertions(+)
(limited to 'OpenSim/Region/Framework/Scenes')
diff --git a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
index 42a1977..75a51b5 100644
--- a/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
+++ b/OpenSim/Region/Framework/Scenes/UuidGatherer.cs
@@ -218,6 +218,10 @@ namespace OpenSim.Region.Framework.Scenes
// inventory transfer. There needs to be a way for a module to register a method without assuming a
// Scene.EventManager is present.
// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
+
+
+ // still needed to retrieve textures used as materials for any parts containing legacy materials stored in DynAttrs
+ GatherMaterialsUuids(part, assetUuids);
}
catch (Exception e)
{
@@ -241,6 +245,75 @@ namespace OpenSim.Region.Framework.Scenes
// Monitor.Pulse(this);
// }
// }
+
+ ///
+ /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
+ /// stored in legacy format in part.DynAttrs
+ ///
+ ///
+ ///
+ //public void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids)
+ public void GatherMaterialsUuids(SceneObjectPart part, IDictionary assetUuids)
+ {
+ // scan thru the dynAttrs map of this part for any textures used as materials
+ OSD osdMaterials = null;
+
+ lock (part.DynAttrs)
+ {
+ if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
+ {
+ OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
+
+ if (materialsStore == null)
+ return;
+
+ materialsStore.TryGetValue("Materials", out osdMaterials);
+ }
+
+ if (osdMaterials != null)
+ {
+ //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
+
+ if (osdMaterials is OSDArray)
+ {
+ OSDArray matsArr = osdMaterials as OSDArray;
+ foreach (OSDMap matMap in matsArr)
+ {
+ try
+ {
+ if (matMap.ContainsKey("Material"))
+ {
+ OSDMap mat = matMap["Material"] as OSDMap;
+ if (mat.ContainsKey("NormMap"))
+ {
+ UUID normalMapId = mat["NormMap"].AsUUID();
+ if (normalMapId != UUID.Zero)
+ {
+ assetUuids[normalMapId] = (sbyte)AssetType.Texture;
+ //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
+ }
+ }
+ if (mat.ContainsKey("SpecMap"))
+ {
+ UUID specularMapId = mat["SpecMap"].AsUUID();
+ if (specularMapId != UUID.Zero)
+ {
+ assetUuids[specularMapId] = (sbyte)AssetType.Texture;
+ //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
+ }
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ m_log.Warn("[UUID Gatherer]: exception getting materials: " + e.Message);
+ }
+ }
+ }
+ }
+ }
+ }
///
/// Get an asset synchronously, potentially using an asynchronous callback. If the
--
cgit v1.1