Prevent illegal color values from being set.
0.6.0-stable
Melanie Thielker 2008-09-14 15:18:58 +00:00
parent d7d1bee4a7
commit de44f765e3
1 changed files with 12 additions and 12 deletions

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)color.x; texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0);
texcolor.G = (float)color.y; texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0);
texcolor.B = (float)color.z; texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0);
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)color.x; texcolor.R = (float)Math.Min(Math.Max(color.x, 0.0), 1.0);
texcolor.G = (float)color.y; texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0);
texcolor.B = (float)color.z; texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0);
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 = (float)Math.Min(Math.Max(color.x, 0.0), 1.0);
texcolor.G = (float)color.y; texcolor.G = (float)Math.Min(Math.Max(color.y, 0.0), 1.0);
texcolor.B = (float)color.z; texcolor.B = (float)Math.Min(Math.Max(color.z, 0.0), 1.0);
tex.DefaultTexture.RGBA = texcolor; tex.DefaultTexture.RGBA = texcolor;
} }
part.UpdateTexture(tex); part.UpdateTexture(tex);
@ -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)color.x; part.Shape.LightColorR = (float)Math.Min(Math.Max(color.x, 0.0), 1.0);
part.Shape.LightColorG = (float)color.y; part.Shape.LightColorG = (float)Math.Min(Math.Max(color.y, 0.0), 1.0);
part.Shape.LightColorB = (float)color.z; part.Shape.LightColorB = (float)Math.Min(Math.Max(color.z, 0.0), 1.0);
part.Shape.LightIntensity = intensity; part.Shape.LightIntensity = intensity;
part.Shape.LightRadius = radius; part.Shape.LightRadius = radius;
part.Shape.LightFalloff = falloff; part.Shape.LightFalloff = falloff;