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,12 +2410,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return; return;
UUID textureID = new UUID(); UUID textureID = new UUID();
bool dotexture = true;
textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture); if(String.IsNullOrEmpty(texture))
if (textureID == UUID.Zero) dotexture = false;
else
{ {
if (!UUID.TryParse(texture, out textureID)) textureID = ScriptUtils.GetAssetIdFromItemName(m_host, texture, (int)AssetType.Texture);
return; if (textureID == UUID.Zero)
{
if (!UUID.TryParse(texture, out textureID))
return;
}
} }
Primitive.TextureEntry tex = part.Shape.Textures; Primitive.TextureEntry tex = part.Shape.Textures;
@ -2424,7 +2429,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face >= 0 && face < nsides) if (face >= 0 && face < nsides)
{ {
Primitive.TextureEntryFace texface = tex.CreateFace((uint)face); Primitive.TextureEntryFace texface = tex.CreateFace((uint)face);
texface.TextureID = textureID; if (dotexture)
texface.TextureID = textureID;
texface.RepeatU = (float)scaleU; texface.RepeatU = (float)scaleU;
texface.RepeatV = (float)ScaleV; texface.RepeatV = (float)ScaleV;
texface.OffsetU = (float)offsetU; texface.OffsetU = (float)offsetU;
@ -2440,7 +2446,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
tex.FaceTextures[i].TextureID = textureID; if (dotexture)
tex.FaceTextures[i].TextureID = textureID;
tex.FaceTextures[i].RepeatU = (float)scaleU; tex.FaceTextures[i].RepeatU = (float)scaleU;
tex.FaceTextures[i].RepeatV = (float)ScaleV; tex.FaceTextures[i].RepeatV = (float)ScaleV;
tex.FaceTextures[i].OffsetU = (float)offsetU; tex.FaceTextures[i].OffsetU = (float)offsetU;
@ -2448,7 +2455,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
tex.FaceTextures[i].Rotation = (float)rotation; tex.FaceTextures[i].Rotation = (float)rotation;
} }
} }
tex.DefaultTexture.TextureID = textureID; if (dotexture)
tex.DefaultTexture.TextureID = textureID;
tex.DefaultTexture.RepeatU = (float)scaleU; tex.DefaultTexture.RepeatU = (float)scaleU;
tex.DefaultTexture.RepeatV = (float)ScaleV; tex.DefaultTexture.RepeatV = (float)ScaleV;
tex.DefaultTexture.OffsetU = (float)offsetU; tex.DefaultTexture.OffsetU = (float)offsetU;
@ -10422,17 +10430,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
string mapname = rules.Data[idx++].ToString(); string mapname = rules.Data[idx++].ToString();
UUID mapID = UUID.Zero;
UUID mapID = ScriptUtils.GetAssetIdFromItemName(m_host, mapname, (int)AssetType.Texture); if (!string.IsNullOrEmpty(mapname))
if (mapID == UUID.Zero)
{ {
if (!UUID.TryParse(mapname, out mapID)) mapID = ScriptUtils.GetAssetIdFromItemName(m_host, mapname, (int)AssetType.Texture);
if (mapID == UUID.Zero)
{ {
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1)); if (!UUID.TryParse(mapname, out mapID))
return new LSL_List(); {
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_NORMAL: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1));
return new LSL_List();
}
} }
} }
LSL_Vector mnrepeat; LSL_Vector mnrepeat;
try try
{ {
@ -10489,17 +10499,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
string smapname = rules.Data[idx++].ToString(); string smapname = rules.Data[idx++].ToString();
UUID smapID = UUID.Zero;
UUID smapID = ScriptUtils.GetAssetIdFromItemName(m_host, smapname, (int)AssetType.Texture); if(!string.IsNullOrEmpty(smapname))
if (smapID == UUID.Zero)
{ {
if (!UUID.TryParse(smapname, out smapID)) smapID = ScriptUtils.GetAssetIdFromItemName(m_host, smapname, (int)AssetType.Texture);
if (smapID == UUID.Zero)
{ {
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1)); if (!UUID.TryParse(smapname, out smapID))
return new LSL_List(); {
Error(originFunc, string.Format("Error running rule #{0} -> PRIM_SPECULAR: arg #{1} - must be a UUID or a texture name on object inventory", rulesParsed, idx - idxStart - 1));
return new LSL_List();
}
} }
} }
LSL_Vector msrepeat; LSL_Vector msrepeat;
try try
{ {
@ -10715,24 +10727,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
FaceMaterial mat = null; FaceMaterial mat = null;
UUID oldid = texface.MaterialID; UUID oldid = texface.MaterialID;
if(oldid != UUID.Zero) if(mapID != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid); {
if(oldid != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid);
if(mat == null) if(mat == null)
mat = new FaceMaterial(); mat = new FaceMaterial();
mat.NormalMapID = mapID; mat.NormalMapID = mapID;
mat.NormalOffsetX = offsetX; mat.NormalOffsetX = offsetX;
mat.NormalOffsetY = offsetY; mat.NormalOffsetY = offsetY;
mat.NormalRepeatX = repeatX; mat.NormalRepeatX = repeatX;
mat.NormalRepeatY = repeatY; mat.NormalRepeatY = repeatY;
mat.NormalRotation = rot; mat.NormalRotation = rot;
UUID id = m_materialsModule.AddNewMaterial(mat); mapID = m_materialsModule.AddNewMaterial(mat);
if(oldid == id) }
if(oldid == mapID)
return false; return false;
texface.MaterialID = id; texface.MaterialID = mapID;
part.Shape.TextureEntry = tex.GetBytes(9); part.Shape.TextureEntry = tex.GetBytes(9);
m_materialsModule.RemoveMaterial(oldid); m_materialsModule.RemoveMaterial(oldid);
return true; return true;
@ -10777,29 +10792,33 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
FaceMaterial mat = null; FaceMaterial mat = null;
UUID oldid = texface.MaterialID; UUID oldid = texface.MaterialID;
if(oldid != UUID.Zero) if (mapID != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid); {
if (oldid != UUID.Zero)
mat = m_materialsModule.GetMaterialCopy(oldid);
if(mat == null) if (mat == null)
mat = new FaceMaterial(); mat = new FaceMaterial();
mat.SpecularMapID = mapID; mat.SpecularMapID = mapID;
mat.SpecularOffsetX = offsetX; mat.SpecularOffsetX = offsetX;
mat.SpecularOffsetY = offsetY; mat.SpecularOffsetY = offsetY;
mat.SpecularRepeatX = repeatX; mat.SpecularRepeatX = repeatX;
mat.SpecularRepeatY = repeatY; mat.SpecularRepeatY = repeatY;
mat.SpecularRotation = rot; mat.SpecularRotation = rot;
mat.SpecularLightColorR = colorR; mat.SpecularLightColorR = colorR;
mat.SpecularLightColorG = colorG; mat.SpecularLightColorG = colorG;
mat.SpecularLightColorB = colorB; mat.SpecularLightColorB = colorB;
mat.SpecularLightExponent = gloss; mat.SpecularLightExponent = gloss;
mat.EnvironmentIntensity = env; mat.EnvironmentIntensity = env;
UUID id = m_materialsModule.AddNewMaterial(mat); mapID = m_materialsModule.AddNewMaterial(mat);
if(oldid == id) }
if(oldid == mapID)
return false; return false;
texface.MaterialID = id; texface.MaterialID = mapID;
part.Shape.TextureEntry = tex.GetBytes(9); part.Shape.TextureEntry = tex.GetBytes(9);
m_materialsModule.RemoveMaterial(oldid); m_materialsModule.RemoveMaterial(oldid);
return true; return true;