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

master-beforevarregion
dahlia 2014-01-20 15:01:18 -08:00
parent af58631f00
commit 7bd42fc42f
1 changed files with 73 additions and 0 deletions

View File

@ -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 // inventory transfer. There needs to be a way for a module to register a method without assuming a
// Scene.EventManager is present. // Scene.EventManager is present.
// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids); // 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) catch (Exception e)
{ {
@ -241,6 +245,75 @@ namespace OpenSim.Region.Framework.Scenes
// Monitor.Pulse(this); // Monitor.Pulse(this);
// } // }
// } // }
/// <summary>
/// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
/// stored in legacy format in part.DynAttrs
/// </summary>
/// <param name="part"></param>
/// <param name="assetUuids"></param>
//public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, sbyte> 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);
}
}
}
}
}
}
/// <summary> /// <summary>
/// Get an asset synchronously, potentially using an asynchronous callback. If the /// Get an asset synchronously, potentially using an asynchronous callback. If the