fix parsing of a vector4 and storing on a lsl quaternion needed for lightShare scripts

melanie
UbitUmarov 2016-11-16 03:47:48 +00:00
parent 8dd9601fdc
commit 05ba77fd3b
2 changed files with 30 additions and 5 deletions

View File

@ -295,7 +295,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
idx++;
try
{
iQ = rules.GetQuaternionItem(idx);
iQ = rules.GetVector4Item(idx);
}
catch (InvalidCastException)
{
@ -319,7 +319,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
idx++;
try
{
iQ = rules.GetQuaternionItem(idx);
iQ = rules.GetVector4Item(idx);
}
catch (InvalidCastException)
{
@ -342,7 +342,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
idx++;
try
{
iQ = rules.GetQuaternionItem(idx);
iQ = rules.GetVector4Item(idx);
}
catch (InvalidCastException)
{
@ -532,7 +532,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
idx++;
try
{
iQ = rules.GetQuaternionItem(idx);
iQ = rules.GetVector4Item(idx);
}
catch (InvalidCastException)
{
@ -654,7 +654,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
case (int)ScriptBaseClass.WL_SUN_MOON_COLOR:
idx++;
iQ = rules.GetQuaternionItem(idx);
iQ = rules.GetVector4Item(idx);
try
{
wl.sunMoonColor = new Vector4((float)iQ.x, (float)iQ.y, (float)iQ.z, (float)iQ.s);

View File

@ -700,6 +700,31 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
// use LSL_Types.Quaternion to parse and store a vector4 for lightShare
public LSL_Types.Quaternion GetVector4Item(int itemIndex)
{
if (Data[itemIndex] is LSL_Types.Quaternion)
{
LSL_Types.Quaternion q = (LSL_Types.Quaternion)Data[itemIndex];
return q;
}
else if(Data[itemIndex] is OpenMetaverse.Quaternion)
{
LSL_Types.Quaternion q = new LSL_Types.Quaternion(
(OpenMetaverse.Quaternion)Data[itemIndex]);
q.Normalize();
return q;
}
else
{
throw new InvalidCastException(string.Format(
"{0} expected but {1} given",
typeof(LSL_Types.Quaternion).Name,
Data[itemIndex] != null ?
Data[itemIndex].GetType().Name : "null"));
}
}
public LSL_Types.Quaternion GetQuaternionItem(int itemIndex)
{
if (Data[itemIndex] is LSL_Types.Quaternion)