making use of implicit operators and Util.Clip handling of Vector3

integration
SignpostMarv 2012-08-20 09:26:26 +01:00 committed by Justin Clark-Casey (justincc)
parent b863a15a82
commit ede3b9ab07
2 changed files with 27 additions and 22 deletions

View File

@ -2857,6 +2857,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="face"></param>
public void SetFaceColor(Vector3 color, int face)
{
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
// The only way to get a deep copy/ If we don't do this, we can
// never detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
@ -2865,9 +2867,9 @@ namespace OpenSim.Region.Framework.Scenes
if (face >= 0 && face < GetNumberOfSides())
{
texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
@ -2879,15 +2881,15 @@ namespace OpenSim.Region.Framework.Scenes
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());
@ -2903,6 +2905,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="alpha"></param>
public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
{
Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f);
float clippedAlpha = Util.Clip((float)alpha, 0.0f, 1.0f);
// The only way to get a deep copy/ If we don't do this, we can
// never detect color changes further down.
Byte[] buf = Shape.Textures.GetBytes();
@ -2911,10 +2916,10 @@ namespace OpenSim.Region.Framework.Scenes
if (face >= 0 && face < GetNumberOfSides())
{
texcolor = tex.CreateFace((uint)face).RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
texcolor.A = clippedAlpha;
tex.FaceTextures[face].RGBA = texcolor;
UpdateTextureEntry(tex.GetBytes());
return;
@ -2926,17 +2931,17 @@ namespace OpenSim.Region.Framework.Scenes
if (tex.FaceTextures[i] != null)
{
texcolor = tex.FaceTextures[i].RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
texcolor.A = clippedAlpha;
tex.FaceTextures[i].RGBA = texcolor;
}
texcolor = tex.DefaultTexture.RGBA;
texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f);
texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f);
texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f);
texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f);
texcolor.R = clippedColor.X;
texcolor.G = clippedColor.Y;
texcolor.B = clippedColor.Z;
texcolor.A = clippedAlpha;
tex.DefaultTexture.RGBA = texcolor;
}
UpdateTextureEntry(tex.GetBytes());

View File

@ -7484,7 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha);
part.SetFaceColorAlpha(face, color, alpha);
break;