From 944a785a324c203c7ca5b8bdf770ec024b7b9a14 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Tue, 30 Jul 2019 23:26:29 +0100 Subject: now i can login on win .net4.8, but just a little drop on a large (broken) OSD ocean. some of this changes are actually good even on good JIT. Failure seems to be on same code pattern, but same points seem to vary with each JIT compilation, sometimes work, others don't, others always fail, etc --- .../OptionalModules/Materials/MaterialsModule.cs | 228 ++++++++++----------- 1 file changed, 114 insertions(+), 114 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs index 2aea7f9..4a92120 100644 --- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs +++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs @@ -267,6 +267,7 @@ namespace OpenSim.Region.OptionalModules.Materials if (matsArr == null) return partchanged; + OSD tmpOSD; foreach (OSD elemOsd in matsArr) { if (elemOsd != null && elemOsd is OSDMap) @@ -278,7 +279,8 @@ namespace OpenSim.Region.OptionalModules.Materials { lock (materialslock) { - UUID id = matMap["ID"].AsUUID(); + tmpOSD = matMap["ID"]; + UUID id = tmpOSD.AsUUID(); if(m_Materials.ContainsKey(id)) continue; @@ -459,12 +461,13 @@ namespace OpenSim.Region.OptionalModules.Materials OSDMap resp = new OSDMap(); OSDArray respArr = new OSDArray(); + OSD tmpOSD; - if (req.ContainsKey("Zipped")) + if (req.TryGetValue("Zipped", out tmpOSD)) { OSD osd = null; - byte[] inBytes = req["Zipped"].AsBinary(); + byte[] inBytes = tmpOSD.AsBinary(); try { @@ -531,12 +534,13 @@ namespace OpenSim.Region.OptionalModules.Materials OSDArray respArr = new OSDArray(); + OSD tmpOSD; HashSet parts = new HashSet(); - if (req.ContainsKey("Zipped")) + if (req.TryGetValue("Zipped", out tmpOSD)) { OSD osd = null; - byte[] inBytes = req["Zipped"].AsBinary(); + byte[] inBytes = tmpOSD.AsBinary(); try { @@ -546,145 +550,141 @@ namespace OpenSim.Region.OptionalModules.Materials { materialsFromViewer = osd as OSDMap; - if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) + if (materialsFromViewer.TryGetValue("FullMaterialsPerFace", out tmpOSD) && (tmpOSD is OSDArray)) { - OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; - if (matsOsd is OSDArray) + OSDArray matsArr = tmpOSD as OSDArray; + try { - OSDArray matsArr = matsOsd as OSDArray; - - try + foreach (OSDMap matsMap in matsArr) { - foreach (OSDMap matsMap in matsArr) + uint primLocalID = 0; + try { - uint primLocalID = 0; - try - { - primLocalID = matsMap["ID"].AsUInteger(); - } - catch (Exception e) - { - m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); - continue; - } + tmpOSD = matsMap["ID"]; + primLocalID = tmpOSD.AsUInteger(); + } + catch (Exception e) + { + m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); + continue; + } - SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); - if (sop == null) - { - m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); - continue; - } + SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); + if (sop == null) + { + m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); + continue; + } - if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) - { - m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); - continue; - } + if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) + { + m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); + 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; - } + 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) - { - m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); - continue; - } + Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); + if (te == null) + { + m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); + continue; + } - int face = -1; - UUID oldid = UUID.Zero; - Primitive.TextureEntryFace faceEntry = null; - if (matsMap.ContainsKey("Face")) - { - face = matsMap["Face"].AsInteger(); - faceEntry = te.CreateFace((uint)face); - } - else - faceEntry = te.DefaultTexture; + int face = -1; + UUID oldid = UUID.Zero; + Primitive.TextureEntryFace faceEntry = null; + if (matsMap.TryGetValue("Face", out tmpOSD)) + { + face = tmpOSD.AsInteger(); + faceEntry = te.CreateFace((uint)face); + } + else + faceEntry = te.DefaultTexture; - if (faceEntry == null) - continue; + if (faceEntry == null) + continue; - UUID id; - FaceMaterial newFaceMat = null; - if (mat == null) - { - // This happens then the user removes a material from a prim + UUID id; + FaceMaterial newFaceMat = null; + if (mat == null) + { + // This happens then the user removes a material from a prim + id = UUID.Zero; + } + else + { + newFaceMat = new FaceMaterial(mat); + if(newFaceMat.DiffuseAlphaMode == 1 + && newFaceMat.NormalMapID == UUID.Zero + && newFaceMat.SpecularMapID == UUID.Zero + ) id = UUID.Zero; - } else { - newFaceMat = new FaceMaterial(mat); - if(newFaceMat.DiffuseAlphaMode == 1 - && newFaceMat.NormalMapID == UUID.Zero - && newFaceMat.SpecularMapID == UUID.Zero - ) - id = UUID.Zero; - else - { - newFaceMat.genID(); - id = newFaceMat.ID; - } + newFaceMat.genID(); + id = newFaceMat.ID; } + } - oldid = faceEntry.MaterialID; + oldid = faceEntry.MaterialID; - if(oldid == id) - continue; + if(oldid == id) + continue; - if (faceEntry != null) - { - faceEntry.MaterialID = id; - //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); - // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually - sop.Shape.TextureEntry = te.GetBytes(9); - } + if (faceEntry != null) + { + faceEntry.MaterialID = id; + //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); + // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually + sop.Shape.TextureEntry = te.GetBytes(9); + } - if(oldid != UUID.Zero) - RemoveMaterial(oldid); + if(oldid != UUID.Zero) + RemoveMaterial(oldid); - lock(materialslock) + lock(materialslock) + { + if(id != UUID.Zero) { - if(id != UUID.Zero) + if (m_Materials.ContainsKey(id)) + m_MaterialsRefCount[id]++; + else { - if (m_Materials.ContainsKey(id)) - m_MaterialsRefCount[id]++; - else - { - m_Materials[id] = newFaceMat; - m_MaterialsRefCount[id] = 1; - m_changed[newFaceMat] = Util.GetTimeStamp(); - } + m_Materials[id] = newFaceMat; + m_MaterialsRefCount[id] = 1; + m_changed[newFaceMat] = Util.GetTimeStamp(); } } - - if(!parts.Contains(sop)) - parts.Add(sop); } - foreach(SceneObjectPart sop in parts) - { - if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted) - { - sop.TriggerScriptChangedEvent(Changed.TEXTURE); - sop.ScheduleFullUpdate(); - sop.ParentGroup.HasGroupChanged = true; - } - } + if(!parts.Contains(sop)) + parts.Add(sop); } - catch (Exception e) + + foreach(SceneObjectPart sop in parts) { - m_log.Warn("[Materials]: exception processing received material ", e); + if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted) + { + sop.TriggerScriptChangedEvent(Changed.TEXTURE); + sop.ScheduleFullUpdate(); + sop.ParentGroup.HasGroupChanged = true; + } } } + catch (Exception e) + { + m_log.Warn("[Materials]: exception processing received material ", e); + } } } } -- cgit v1.1