let viewers pre cache materials, again

This commit is contained in:
UbitUmarov
2022-08-09 20:19:06 +01:00
parent 0f052f775d
commit a8932b9beb

View File

@@ -753,33 +753,44 @@ namespace OpenSim.Region.OptionalModules.Materials
return asset;
}
private byte[] CacheGet = null;
private object CacheGetLock = new object();
private double CacheGetTime = 0;
public void RenderMaterialsGetCap(IOSHttpRequest request, IOSHttpResponse response)
{
//OSDMap resp = new OSDMap();
//OSDArray allOsd = new OSDArray();
/*
// this violates all idea of caching and geting things only if needed, so disabled
int matsCount = 0;
lock (m_Materials)
lock(CacheGetLock)
{
foreach (KeyValuePair<UUID, FaceMaterial> kvp in m_Materials)
OSDArray allOsd = new OSDArray();
double now = Util.GetTimeStamp();
if(CacheGet == null || now - CacheGetTime > 30)
{
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes());
matMap["Material"] = kvp.Value.toOSD();
allOsd.Add(matMap);
matsCount++;
CacheGetTime = now;
lock (m_Materials)
{
foreach (KeyValuePair<UUID, FaceMaterial> kvp in m_Materials)
{
OSDMap matMap = new OSDMap
{
["ID"] = OSD.FromBinary(kvp.Key.GetBytes()),
["Material"] = kvp.Value.toOSD()
};
allOsd.Add(matMap);
}
}
OSDMap resp = new OSDMap
{
["Zipped"] = ZCompressOSD(allOsd, false)
};
CacheGet = OSDParser.SerializeLLSDXmlToBytes(resp);
}
response.RawBuffer = CacheGet ?? GetPutEmptyResponseBytes;
}
*/
//resp["Zipped"] = ZCompressOSD(allOsd, false);
//string tmp = OSDParser.SerializeLLSDXmlString(resp);
//response.RawBuffer = Encoding.UTF8.GetBytes(tmp);
response.RawBuffer = GetPutEmptyResponseBytes;
}
private static string ZippedOsdBytesToString(byte[] bytes)
{
try