From fb2380efd6397a1e425393c17a187ee96ecc2ee8 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sun, 9 Feb 2020 19:14:17 +0000 Subject: [PATCH] fix handling of materials maps clear and total removal with SLSL --- .../Shared/Api/Implementation/LSL_Api.cs | 85 ++++++++++--------- 1 file changed, 47 insertions(+), 38 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 561458713e..692630c53b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -10663,8 +10663,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api FaceMaterial mat = null; UUID oldid = texface.MaterialID; - - if(oldid != UUID.Zero) + if (oldid == UUID.Zero) + { + if (materialAlphaMode == 1) + return false; + } + else mat = m_materialsModule.GetMaterialCopy(oldid); if(mat == null) @@ -10673,7 +10677,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api mat.DiffuseAlphaMode = (byte)materialAlphaMode; mat.AlphaMaskCutoff = (byte)materialMaskCutoff; - UUID id = m_materialsModule.AddNewMaterial(mat); + UUID id = m_materialsModule.AddNewMaterial(mat); // id is a hash of entire material hash, so this means no change if(oldid == id) return false; @@ -10717,23 +10721,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api FaceMaterial mat = null; UUID oldid = texface.MaterialID; - if(mapID != UUID.Zero) + if (oldid == UUID.Zero) { - if(oldid != UUID.Zero) - mat = m_materialsModule.GetMaterialCopy(oldid); - - if(mat == null) - mat = new FaceMaterial(); - - mat.NormalMapID = mapID; - mat.NormalOffsetX = offsetX; - mat.NormalOffsetY = offsetY; - mat.NormalRepeatX = repeatX; - mat.NormalRepeatY = repeatY; - mat.NormalRotation = rot; - - mapID = m_materialsModule.AddNewMaterial(mat); + if (mapID == UUID.Zero) + return false; } + else + mat = m_materialsModule.GetMaterialCopy(oldid); + + if(mat == null) + mat = new FaceMaterial(); + + mat.NormalMapID = mapID; + mat.NormalOffsetX = offsetX; + mat.NormalOffsetY = offsetY; + mat.NormalRepeatX = repeatX; + mat.NormalRepeatY = repeatY; + mat.NormalRotation = rot; + + mapID = m_materialsModule.AddNewMaterial(mat); + if(oldid == mapID) return false; @@ -10782,28 +10789,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api FaceMaterial mat = null; UUID oldid = texface.MaterialID; - if (mapID != UUID.Zero) + if(oldid == UUID.Zero) { - if (oldid != UUID.Zero) - mat = m_materialsModule.GetMaterialCopy(oldid); - - if (mat == null) - mat = new FaceMaterial(); - - mat.SpecularMapID = mapID; - mat.SpecularOffsetX = offsetX; - mat.SpecularOffsetY = offsetY; - mat.SpecularRepeatX = repeatX; - mat.SpecularRepeatY = repeatY; - mat.SpecularRotation = rot; - mat.SpecularLightColorR = colorR; - mat.SpecularLightColorG = colorG; - mat.SpecularLightColorB = colorB; - mat.SpecularLightExponent = gloss; - mat.EnvironmentIntensity = env; - - mapID = m_materialsModule.AddNewMaterial(mat); + if(mapID == UUID.Zero) + return false; } + else + mat = m_materialsModule.GetMaterialCopy(oldid); + + if (mat == null) + mat = new FaceMaterial(); + + mat.SpecularMapID = mapID; + mat.SpecularOffsetX = offsetX; + mat.SpecularOffsetY = offsetY; + mat.SpecularRepeatX = repeatX; + mat.SpecularRepeatY = repeatY; + mat.SpecularRotation = rot; + mat.SpecularLightColorR = colorR; + mat.SpecularLightColorG = colorG; + mat.SpecularLightColorB = colorB; + mat.SpecularLightExponent = gloss; + mat.EnvironmentIntensity = env; + + mapID = m_materialsModule.AddNewMaterial(mat); if(oldid == mapID) return false;