From b863a15a820be7c3b86b27ef24944d6a85fa5360 Mon Sep 17 00:00:00 2001
From: SignpostMarv
Date: Fri, 17 Aug 2012 15:09:52 +0100
Subject: single operation for PRIM_COLOR
---
OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | 49 ++++++++++++++++++++++
.../Shared/Api/Implementation/LSL_Api.cs | 3 +-
2 files changed, 50 insertions(+), 2 deletions(-)
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0535dcb..6741e5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -2896,6 +2896,55 @@ namespace OpenSim.Region.Framework.Scenes
}
///
+ /// Set the color & alpha of prim faces
+ ///
+ ///
+ ///
+ ///
+ public void SetFaceColorAlpha(int face, Vector3 color, double alpha)
+ {
+ // 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();
+ Primitive.TextureEntry tex = new Primitive.TextureEntry(buf, 0, buf.Length);
+ Color4 texcolor;
+ 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);
+ tex.FaceTextures[face].RGBA = texcolor;
+ UpdateTextureEntry(tex.GetBytes());
+ return;
+ }
+ else if (face == ALL_SIDES)
+ {
+ for (uint i = 0; i < GetNumberOfSides(); i++)
+ {
+ 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);
+ 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);
+ tex.DefaultTexture.RGBA = texcolor;
+ }
+ UpdateTextureEntry(tex.GetBytes());
+ return;
+ }
+ }
+
+ ///
/// Get the number of sides that this part has.
///
///
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 4645e7a..dbbfbd3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -7484,8 +7484,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
LSL_Vector color=rules.GetVector3Item(idx++);
double alpha=(double)rules.GetLSLFloatItem(idx++);
- part.SetFaceColor(color, face);
- SetAlpha(part, alpha, face);
+ part.SetFaceColorAlpha(face, new Vector3((float)color.x, (float)color.y, (float)color.z), alpha);
break;
--
cgit v1.1