From af58631f00b95081dc99f4f75e8ec6b031b8cf2a Mon Sep 17 00:00:00 2001
From: dahlia
Date: Mon, 20 Jan 2014 13:57:14 -0800
Subject: rather than converting existing materials to assets, just retrieve
them and make them available for viewing. Any new materials added to the
scene will become assets.
---
.../OptionalModules/Materials/MaterialsModule.cs | 44 ++++++----------------
1 file changed, 12 insertions(+), 32 deletions(-)
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index c4bc8a0..afb788b 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -149,12 +149,10 @@ namespace OpenSim.Region.OptionalModules.Materials
}
///
- /// Searches the part for any legacy materials stored in DynAttrs and converts them to assets, replacing
- /// the MaterialIDs in the TextureEntries for the part.
- /// Deletes the legacy materials from the part as they are no longer needed.
+ /// Finds any legacy materials stored in DynAttrs that may exist for this part and add them to 'm_regionMaterials'.
///
///
- private void ConvertLegacyMaterialsInPart(SceneObjectPart part)
+ private void GetLegacyStoredMaterialsInPart(SceneObjectPart part)
{
if (part.DynAttrs == null)
return;
@@ -183,10 +181,6 @@ namespace OpenSim.Region.OptionalModules.Materials
if (matsArr == null)
return;
- var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
- if (te == null)
- return;
-
foreach (OSD elemOsd in matsArr)
{
if (elemOsd != null && elemOsd is OSDMap)
@@ -194,32 +188,18 @@ namespace OpenSim.Region.OptionalModules.Materials
OSDMap matMap = elemOsd as OSDMap;
if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
{
- UUID id = matMap["ID"].AsUUID();
- OSDMap material = (OSDMap)matMap["Material"];
- bool used = false;
-
- foreach (var face in te.FaceTextures)
- if (face != null && face.MaterialID == id)
- used = true;
-
- if (used)
- { // store legacy material in new asset format, and update the part texture entry with the new hashed UUID
-
- var newId = StoreMaterialAsAsset(part.CreatorID, material, part);
- foreach (var face in te.FaceTextures)
- if (face != null && face.MaterialID == id)
- face.MaterialID = newId;
+ try
+ {
+ lock (m_regionMaterials)
+ m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
+ }
+ catch (Exception e)
+ {
+ m_log.Warn("[Materials]: exception decoding persisted legacy material: " + e.ToString());
}
}
}
}
-
- part.Shape.TextureEntry = te.GetBytes();
- part.ParentGroup.HasGroupChanged = true;
- part.ScheduleFullUpdate();
-
- lock (part.DynAttrs)
- part.DynAttrs.RemoveStore("OpenSim", "Materials");
}
///
@@ -230,12 +210,12 @@ namespace OpenSim.Region.OptionalModules.Materials
if (part.Shape == null)
return;
- ConvertLegacyMaterialsInPart(part);
-
var te = new Primitive.TextureEntry(part.Shape.TextureEntry, 0, part.Shape.TextureEntry.Length);
if (te == null)
return;
+ GetLegacyStoredMaterialsInPart(part);
+
GetStoredMaterialInFace(part, te.DefaultTexture);
foreach (Primitive.TextureEntryFace face in te.FaceTextures)
--
cgit v1.1