diff options
author | SignpostMarv | 2012-08-20 09:26:26 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-20 23:10:25 +0100 |
commit | ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd (patch) | |
tree | faeed5b19ad958ed64a9dee79ad0f2aaf009b880 /OpenSim | |
parent | single operation for PRIM_COLOR (diff) | |
download | opensim-SC-ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd.zip opensim-SC-ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd.tar.gz opensim-SC-ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd.tar.bz2 opensim-SC-ede3b9ab07dc1ed4a51684b7257cbb4d76e9bdfd.tar.xz |
making use of implicit operators and Util.Clip handling of Vector3
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 47 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 2 |
2 files changed, 27 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 6741e5e..098b2d9 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -2857,6 +2857,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2857 | /// <param name="face"></param> | 2857 | /// <param name="face"></param> |
2858 | public void SetFaceColor(Vector3 color, int face) | 2858 | public void SetFaceColor(Vector3 color, int face) |
2859 | { | 2859 | { |
2860 | Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f); | ||
2861 | |||
2860 | // The only way to get a deep copy/ If we don't do this, we can | 2862 | // The only way to get a deep copy/ If we don't do this, we can |
2861 | // never detect color changes further down. | 2863 | // never detect color changes further down. |
2862 | Byte[] buf = Shape.Textures.GetBytes(); | 2864 | Byte[] buf = Shape.Textures.GetBytes(); |
@@ -2865,9 +2867,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2865 | if (face >= 0 && face < GetNumberOfSides()) | 2867 | if (face >= 0 && face < GetNumberOfSides()) |
2866 | { | 2868 | { |
2867 | texcolor = tex.CreateFace((uint)face).RGBA; | 2869 | texcolor = tex.CreateFace((uint)face).RGBA; |
2868 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2870 | texcolor.R = clippedColor.X; |
2869 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2871 | texcolor.G = clippedColor.Y; |
2870 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2872 | texcolor.B = clippedColor.Z; |
2871 | tex.FaceTextures[face].RGBA = texcolor; | 2873 | tex.FaceTextures[face].RGBA = texcolor; |
2872 | UpdateTextureEntry(tex.GetBytes()); | 2874 | UpdateTextureEntry(tex.GetBytes()); |
2873 | return; | 2875 | return; |
@@ -2879,15 +2881,15 @@ namespace OpenSim.Region.Framework.Scenes | |||
2879 | if (tex.FaceTextures[i] != null) | 2881 | if (tex.FaceTextures[i] != null) |
2880 | { | 2882 | { |
2881 | texcolor = tex.FaceTextures[i].RGBA; | 2883 | texcolor = tex.FaceTextures[i].RGBA; |
2882 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2884 | texcolor.R = clippedColor.X; |
2883 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2885 | texcolor.G = clippedColor.Y; |
2884 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2886 | texcolor.B = clippedColor.Z; |
2885 | tex.FaceTextures[i].RGBA = texcolor; | 2887 | tex.FaceTextures[i].RGBA = texcolor; |
2886 | } | 2888 | } |
2887 | texcolor = tex.DefaultTexture.RGBA; | 2889 | texcolor = tex.DefaultTexture.RGBA; |
2888 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2890 | texcolor.R = clippedColor.X; |
2889 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2891 | texcolor.G = clippedColor.Y; |
2890 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2892 | texcolor.B = clippedColor.Z; |
2891 | tex.DefaultTexture.RGBA = texcolor; | 2893 | tex.DefaultTexture.RGBA = texcolor; |
2892 | } | 2894 | } |
2893 | UpdateTextureEntry(tex.GetBytes()); | 2895 | UpdateTextureEntry(tex.GetBytes()); |
@@ -2903,6 +2905,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2903 | /// <param name="alpha"></param> | 2905 | /// <param name="alpha"></param> |
2904 | public void SetFaceColorAlpha(int face, Vector3 color, double alpha) | 2906 | public void SetFaceColorAlpha(int face, Vector3 color, double alpha) |
2905 | { | 2907 | { |
2908 | Vector3 clippedColor = Util.Clip(color, 0.0f, 1.0f); | ||
2909 | float clippedAlpha = Util.Clip((float)alpha, 0.0f, 1.0f); | ||
2910 | |||
2906 | // The only way to get a deep copy/ If we don't do this, we can | 2911 | // The only way to get a deep copy/ If we don't do this, we can |
2907 | // never detect color changes further down. | 2912 | // never detect color changes further down. |
2908 | Byte[] buf = Shape.Textures.GetBytes(); | 2913 | Byte[] buf = Shape.Textures.GetBytes(); |
@@ -2911,10 +2916,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2911 | if (face >= 0 && face < GetNumberOfSides()) | 2916 | if (face >= 0 && face < GetNumberOfSides()) |
2912 | { | 2917 | { |
2913 | texcolor = tex.CreateFace((uint)face).RGBA; | 2918 | texcolor = tex.CreateFace((uint)face).RGBA; |
2914 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2919 | texcolor.R = clippedColor.X; |
2915 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2920 | texcolor.G = clippedColor.Y; |
2916 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2921 | texcolor.B = clippedColor.Z; |
2917 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 2922 | texcolor.A = clippedAlpha; |
2918 | tex.FaceTextures[face].RGBA = texcolor; | 2923 | tex.FaceTextures[face].RGBA = texcolor; |
2919 | UpdateTextureEntry(tex.GetBytes()); | 2924 | UpdateTextureEntry(tex.GetBytes()); |
2920 | return; | 2925 | return; |
@@ -2926,17 +2931,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
2926 | if (tex.FaceTextures[i] != null) | 2931 | if (tex.FaceTextures[i] != null) |
2927 | { | 2932 | { |
2928 | texcolor = tex.FaceTextures[i].RGBA; | 2933 | texcolor = tex.FaceTextures[i].RGBA; |
2929 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2934 | texcolor.R = clippedColor.X; |
2930 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2935 | texcolor.G = clippedColor.Y; |
2931 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2936 | texcolor.B = clippedColor.Z; |
2932 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 2937 | texcolor.A = clippedAlpha; |
2933 | tex.FaceTextures[i].RGBA = texcolor; | 2938 | tex.FaceTextures[i].RGBA = texcolor; |
2934 | } | 2939 | } |
2935 | texcolor = tex.DefaultTexture.RGBA; | 2940 | texcolor = tex.DefaultTexture.RGBA; |
2936 | texcolor.R = Util.Clip((float)color.X, 0.0f, 1.0f); | 2941 | texcolor.R = clippedColor.X; |
2937 | texcolor.G = Util.Clip((float)color.Y, 0.0f, 1.0f); | 2942 | texcolor.G = clippedColor.Y; |
2938 | texcolor.B = Util.Clip((float)color.Z, 0.0f, 1.0f); | 2943 | texcolor.B = clippedColor.Z; |
2939 | texcolor.A = Util.Clip((float)alpha, 0.0f, 1.0f); | 2944 | texcolor.A = clippedAlpha; |
2940 | tex.DefaultTexture.RGBA = texcolor; | 2945 | tex.DefaultTexture.RGBA = texcolor; |
2941 | } | 2946 | } |
2942 | UpdateTextureEntry(tex.GetBytes()); | 2947 | UpdateTextureEntry(tex.GetBytes()); |
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index dbbfbd3..0cbb317 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | |||
@@ -7484,7 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api | |||
7484 | LSL_Vector color=rules.GetVector3Item(idx++); | 7484 | LSL_Vector color=rules.GetVector3Item(idx++); |
7485 | double alpha=(double)rules.GetLSLFloatItem(idx++); | 7485 | double alpha=(double)rules.GetLSLFloatItem(idx++); |
7486 | 7486 | ||
7487 | part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha); | 7487 | part.SetFaceColorAlpha(face, color, alpha); |
7488 | 7488 | ||
7489 | break; | 7489 | break; |
7490 | 7490 | ||