mantis 8517: let texture argument of PRIM_TEXTURE only change the other parameters. On PRIM_NORMAL and PRIM_SPECULAR will be as NULL_KEY removing the material. This may be changed for coerence in future

0.9.1.0-post-fixes
UbitUmarov 2019-04-18 13:17:40 +01:00
parent 11cad57c9c
commit 2b4e5fcded
1 changed files with 72 additions and 53 deletions

View File

@ -2410,13 +2410,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return;
UUID textureID = new UUID();
bool dotexture = true;
if(String.IsNullOrEmpty(texture))
dotexture = false;
else
{
textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
if (textureID == UUID.Zero)
{
if (!UUID.TryParse(texture, out textureID))
return;
}
}
Primitive.TextureEntry tex = part.Shape.Textures;
int nsides = GetNumberOfSides(part);
@ -2424,6 +2429,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face >= 0 && face < nsides)
{
Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
if (dotexture)
texface.TextureID = textureID;
texface.RepeatU = (float)scaleU;
texface.RepeatV = (float)ScaleV;
@ -2440,6 +2446,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
if (tex.FaceTextures[i] != null)
{
if (dotexture)
tex.FaceTextures[i].TextureID = textureID;
tex.FaceTextures[i].RepeatU = (float)scaleU;
tex.FaceTextures[i].RepeatV = (float)ScaleV;
@ -2448,6 +2455,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
tex.FaceTextures[i].Rotation = (float)rotation;
}
}
if (dotexture)
tex.DefaultTexture.TextureID = textureID;
tex.DefaultTexture.RepeatU = (float)scaleU;
tex.DefaultTexture.RepeatV = (float)ScaleV;
@ -10422,8 +10430,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
string mapname = rules.Data[idx++].ToString();
UUID mapID = ScriptUtils.GetAssetIdFromItemName(m_host, mapname, (int)AssetType.Texture);
UUID mapID = UUID.Zero;
if (!string.IsNullOrEmpty(mapname))
{
mapID = ScriptUtils.GetAssetIdFromItemName(m_host, mapname, (int)AssetType.Texture);
if (mapID == UUID.Zero)
{
if (!UUID.TryParse(mapname, out mapID))
@ -10432,7 +10442,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_List();
}
}
}
LSL_Vector mnrepeat;
try
{
@ -10489,8 +10499,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
string smapname = rules.Data[idx++].ToString();
UUID smapID = ScriptUtils.GetAssetIdFromItemName(m_host, smapname, (int)AssetType.Texture);
UUID smapID = UUID.Zero;
if(!string.IsNullOrEmpty(smapname))
{
smapID = ScriptUtils.GetAssetIdFromItemName(m_host, smapname, (int)AssetType.Texture);
if (smapID == UUID.Zero)
{
if (!UUID.TryParse(smapname, out smapID))
@ -10499,7 +10511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_List();
}
}
}
LSL_Vector msrepeat;
try
{
@ -10715,6 +10727,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
FaceMaterial mat = null;
UUID oldid = texface.MaterialID;
if(mapID != UUID.Zero)
{
if(oldid != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid);
@ -10728,11 +10742,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
mat.NormalRepeatY = repeatY;
mat.NormalRotation = rot;
UUID id = m_materialsModule.AddNewMaterial(mat);
if(oldid == id)
mapID = m_materialsModule.AddNewMaterial(mat);
}
if(oldid == mapID)
return false;
texface.MaterialID = id;
texface.MaterialID = mapID;
part.Shape.TextureEntry = tex.GetBytes(9);
m_materialsModule.RemoveMaterial(oldid);
return true;
@ -10777,6 +10792,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
FaceMaterial mat = null;
UUID oldid = texface.MaterialID;
if (mapID != UUID.Zero)
{
if (oldid != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid);
@ -10795,11 +10812,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
mat.SpecularLightExponent = gloss;
mat.EnvironmentIntensity = env;
UUID id = m_materialsModule.AddNewMaterial(mat);
if(oldid == id)
mapID = m_materialsModule.AddNewMaterial(mat);
}
if(oldid == mapID)
return false;
texface.MaterialID = id;
texface.MaterialID = mapID;
part.Shape.TextureEntry = tex.GetBytes(9);
m_materialsModule.RemoveMaterial(oldid);
return true;