adding a clip method to handle Vector3 objects to enable a minor amount of refactoring

0.7.4-extended
SignpostMarv 2012-08-17 16:53:36 +01:00 committed by Justin Clark-Casey (justincc)
parent 849053681e
commit 174addc426
2 changed files with 11 additions and 6 deletions

View File

@ -850,6 +850,12 @@ namespace OpenSim.Framework
return Math.Min(Math.Max(x, min), max); return Math.Min(Math.Max(x, min), max);
} }
public static Vector3 Clip(Vector3 vec, float min, float max)
{
return new Vector3(Clip(vec.X, min, max), Clip(vec.Y, min, max),
Clip(vec.Z, min, max));
}
/// <summary> /// <summary>
/// Convert an UUID to a raw uuid string. Right now this is a string without hyphens. /// Convert an UUID to a raw uuid string. Right now this is a string without hyphens.
/// </summary> /// </summary>

View File

@ -4023,9 +4023,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llSetText(string text, LSL_Vector color, double alpha) public void llSetText(string text, LSL_Vector color, double alpha)
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 av3 = new Vector3(Util.Clip((float)color.x, 0.0f, 1.0f), Vector3 av3 = Util.Clip(new Vector3((float)color.x, (float)color.y,
Util.Clip((float)color.y, 0.0f, 1.0f), (float)color.z), 0.0f, 1.0f);
Util.Clip((float)color.z, 0.0f, 1.0f));
m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f)); m_host.SetText(text.Length > 254 ? text.Remove(254) : text, av3, Util.Clip((float)alpha, 0.0f, 1.0f));
//m_host.ParentGroup.HasGroupChanged = true; //m_host.ParentGroup.HasGroupChanged = true;
//m_host.ParentGroup.ScheduleGroupForFullUpdate(); //m_host.ParentGroup.ScheduleGroupForFullUpdate();
@ -7577,9 +7576,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
string primText = rules.GetLSLStringItem(idx++); string primText = rules.GetLSLStringItem(idx++);
LSL_Vector primTextColor = rules.GetVector3Item(idx++); LSL_Vector primTextColor = rules.GetVector3Item(idx++);
LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++); LSL_Float primTextAlpha = rules.GetLSLFloatItem(idx++);
Vector3 av3 = new Vector3(Util.Clip((float)primTextColor.x, 0.0f, 1.0f), Vector3 av3 = Util.Clip(new Vector3((float)primTextColor.x,
Util.Clip((float)primTextColor.y, 0.0f, 1.0f), (float)primTextColor.y,
Util.Clip((float)primTextColor.z, 0.0f, 1.0f)); (float)primTextColor.z), 0.0f, 1.0f);
part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f)); part.SetText(primText, av3, Util.Clip((float)primTextAlpha, 0.0f, 1.0f));
break; break;