Added some further clipping to color- and alpha-values.

0.6.0-stable
Homer Horwitz 2008-09-14 15:46:54 +00:00
parent de44f765e3
commit 4ba7ce5981
2 changed files with 102 additions and 98 deletions

View File

@ -1181,9 +1181,9 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)color.x; texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)color.y; texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)color.z; texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1195,15 +1195,15 @@ namespace OpenSim.Region.ScriptEngine.Common
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)color.x; texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)color.y; texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)color.z; texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)color.x; texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)color.y; texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)color.z; texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
part.UpdateTexture(tex); part.UpdateTexture(tex);
@ -1340,7 +1340,7 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1352,12 +1352,12 @@ namespace OpenSim.Region.ScriptEngine.Common
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1444,9 +1444,9 @@ namespace OpenSim.Region.ScriptEngine.Common
if (light) if (light)
{ {
part.Shape.LightEntry = true; part.Shape.LightEntry = true;
part.Shape.LightColorR = (float)color.x; part.Shape.LightColorR = Util.Clip((float)color.x, 0.0f, 1.0f);
part.Shape.LightColorG = (float)color.y; part.Shape.LightColorG = Util.Clip((float)color.y, 0.0f, 1.0f);
part.Shape.LightColorB = (float)color.z; part.Shape.LightColorB = Util.Clip((float)color.z, 0.0f, 1.0f);
part.Shape.LightIntensity = intensity; part.Shape.LightIntensity = intensity;
part.Shape.LightRadius = radius; part.Shape.LightRadius = radius;
part.Shape.LightFalloff = falloff; part.Shape.LightFalloff = falloff;
@ -2866,9 +2866,9 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -2876,25 +2876,25 @@ namespace OpenSim.Region.ScriptEngine.Common
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -2913,34 +2913,34 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
@ -3161,8 +3161,10 @@ namespace OpenSim.Region.ScriptEngine.Common
public void llSetText(string text, LSL_Types.Vector3 color, double alpha) public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z); Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f),
m_host.SetText(text, av3, alpha); Util.Clip((float)color.y, 0.0f, 1.0f),
Util.Clip((float)color.z, 0.0f, 1.0f));
m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
} }
public double llWater(LSL_Types.Vector3 offset) public double llWater(LSL_Types.Vector3 offset)
@ -6154,7 +6156,7 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -6162,19 +6164,19 @@ namespace OpenSim.Region.ScriptEngine.Common
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -6193,26 +6195,26 @@ namespace OpenSim.Region.ScriptEngine.Common
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }

View File

@ -990,9 +990,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1004,15 +1004,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
part.UpdateTexture(tex); part.UpdateTexture(tex);
@ -1149,7 +1149,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1161,12 +1161,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -1253,9 +1253,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (light) if (light)
{ {
part.Shape.LightEntry = true; part.Shape.LightEntry = true;
part.Shape.LightColorR = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); part.Shape.LightColorR = Util.Clip((float)color.x, 0.0f, 1.0f);
part.Shape.LightColorG = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); part.Shape.LightColorG = Util.Clip((float)color.y, 0.0f, 1.0f);
part.Shape.LightColorB = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); part.Shape.LightColorB = Util.Clip((float)color.z, 0.0f, 1.0f);
part.Shape.LightIntensity = intensity; part.Shape.LightIntensity = intensity;
part.Shape.LightRadius = radius; part.Shape.LightRadius = radius;
part.Shape.LightFalloff = falloff; part.Shape.LightFalloff = falloff;
@ -2710,9 +2710,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -2720,25 +2720,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -2757,34 +2757,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0); texcolor.R = Util.Clip((float)color.x, 0.0f, 1.0f);
texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0); texcolor.G = Util.Clip((float)color.y, 0.0f, 1.0f);
texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0); texcolor.B = Util.Clip((float)color.z, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
@ -2990,8 +2990,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Types.Vector3 color, double alpha) public void llSetText(string text, LSL_Types.Vector3 color, double alpha)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 av3 = new Vector3((float)color.x, (float)color.y, (float)color.z); Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f),
m_host.SetText(text, av3, alpha); Util.Clip((float)color.y, 0.0f, 1.0f),
Util.Clip((float)color.z, 0.0f, 1.0f));
m_host.SetText(text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
m_host.ParentGroup.HasGroupChanged = true; m_host.ParentGroup.HasGroupChanged = true;
} }
@ -5959,7 +5961,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -5967,19 +5969,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
return; return;
@ -5998,26 +6000,26 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (face > -1) if (face > -1)
{ {
texcolor = tex.CreateFace((uint)face).RGBA; texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[face].RGBA = texcolor; tex.FaceTextures[face].RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }
else if (face == -1) else if (face == -1)
{ {
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
for (uint i = 0; i < 32; i++) for (uint i = 0; i < 32; i++)
{ {
if (tex.FaceTextures[i] != null) if (tex.FaceTextures[i] != null)
{ {
texcolor = tex.FaceTextures[i].RGBA; texcolor = tex.FaceTextures[i].RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.FaceTextures[i].RGBA = texcolor; tex.FaceTextures[i].RGBA = texcolor;
} }
} }
texcolor = tex.DefaultTexture.RGBA; texcolor = tex.DefaultTexture.RGBA;
texcolor.A = (float)Math.Min(Math.Max(alpha, 0.0), 1.0); texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
part.UpdateTexture(tex); part.UpdateTexture(tex);
} }