make sure materials are cached. Split POST and PUT handlers for better readability
parent
c37877ed34
commit
6526de04cb
|
@ -133,7 +133,7 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
IRequestHandler renderMaterialsPutHandler
|
||||
= new RestStreamHandler("PUT", capsBase + "/",
|
||||
(request, path, param, httpRequest, httpResponse)
|
||||
=> RenderMaterialsPostCap(request, agentID),
|
||||
=> RenderMaterialsPutCap(request, agentID),
|
||||
"RenderMaterials", null);
|
||||
MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
|
||||
}
|
||||
|
@ -257,13 +257,18 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
if (m_regionMaterials.ContainsKey(id))
|
||||
return;
|
||||
|
||||
byte[] data = m_scene.AssetService.GetData(id.ToString());
|
||||
if (data == null)
|
||||
|
||||
// get all asset so it gets into cache
|
||||
AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
|
||||
|
||||
// byte[] data = m_scene.AssetService.GetData(id.ToString());
|
||||
if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
|
||||
{
|
||||
m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
|
||||
return;
|
||||
}
|
||||
|
||||
byte[] data = matAsset.Data;
|
||||
OSDMap mat;
|
||||
try
|
||||
{
|
||||
|
@ -284,8 +289,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
|
||||
OSDMap materialsFromViewer = null;
|
||||
|
||||
OSDArray respArr = new OSDArray();
|
||||
|
||||
if (req.ContainsKey("Zipped"))
|
||||
|
@ -298,9 +301,7 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
{
|
||||
osd = ZDecompressBytesToOsd(inBytes);
|
||||
|
||||
if (osd != null)
|
||||
{
|
||||
if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries
|
||||
if (osd != null && osd is OSDArray)
|
||||
{
|
||||
foreach (OSD elem in (OSDArray)osd)
|
||||
{
|
||||
|
@ -335,7 +336,43 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (osd is OSDMap) // request to assign a material
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
|
||||
//return "";
|
||||
}
|
||||
}
|
||||
|
||||
resp["Zipped"] = ZCompressOSD(respArr, false);
|
||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||
|
||||
//m_log.Debug("[Materials]: cap request: " + request);
|
||||
//m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
|
||||
//m_log.Debug("[Materials]: cap response: " + response);
|
||||
return response;
|
||||
}
|
||||
|
||||
public string RenderMaterialsPutCap(string request, UUID agentID)
|
||||
{
|
||||
OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
|
||||
OSDMap resp = new OSDMap();
|
||||
|
||||
OSDMap materialsFromViewer = null;
|
||||
|
||||
OSDArray respArr = new OSDArray();
|
||||
|
||||
if (req.ContainsKey("Zipped"))
|
||||
{
|
||||
OSD osd = null;
|
||||
|
||||
byte[] inBytes = req["Zipped"].AsBinary();
|
||||
|
||||
try
|
||||
{
|
||||
osd = ZDecompressBytesToOsd(inBytes);
|
||||
|
||||
if (osd != null && osd is OSDMap)
|
||||
{
|
||||
materialsFromViewer = osd as OSDMap;
|
||||
|
||||
|
@ -359,17 +396,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
continue;
|
||||
}
|
||||
|
||||
OSDMap mat = null;
|
||||
try
|
||||
{
|
||||
mat = matsMap["Material"] as OSDMap;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
|
||||
continue;
|
||||
}
|
||||
|
||||
SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
|
||||
if (sop == null)
|
||||
{
|
||||
|
@ -383,6 +409,17 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
continue;
|
||||
}
|
||||
|
||||
OSDMap mat = null;
|
||||
try
|
||||
{
|
||||
mat = matsMap["Material"] as OSDMap;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
|
||||
continue;
|
||||
}
|
||||
|
||||
Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
|
||||
if (te == null)
|
||||
{
|
||||
|
@ -390,7 +427,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
continue;
|
||||
}
|
||||
|
||||
|
||||
UUID id;
|
||||
if (mat == null)
|
||||
{
|
||||
|
@ -402,7 +438,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
id = StoreMaterialAsAsset(agentID, mat, sop);
|
||||
}
|
||||
|
||||
|
||||
int face = -1;
|
||||
|
||||
if (matsMap.ContainsKey("Face"))
|
||||
|
@ -427,7 +462,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
if (sop.ParentGroup != null)
|
||||
{
|
||||
sop.TriggerScriptChangedEvent(Changed.TEXTURE);
|
||||
sop.UpdateFlag = UpdateRequired.FULL;
|
||||
sop.ParentGroup.HasGroupChanged = true;
|
||||
sop.ScheduleFullUpdate();
|
||||
}
|
||||
|
@ -441,8 +475,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
|
||||
|
@ -450,7 +482,6 @@ namespace OpenSim.Region.OptionalModules.Materials
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
resp["Zipped"] = ZCompressOSD(respArr, false);
|
||||
string response = OSDParser.SerializeLLSDXmlString(resp);
|
||||
|
||||
|
|
Loading…
Reference in New Issue