does some verification of the quaternion returned by llAxes2Rot and modifies the sign of the s term if a discrepency is found. This helps llAxes2Rot more closely match the Linden implementation.

0.6.0-stable
Dahlia Trimble 2008-07-21 05:34:31 +00:00
parent bedd28e02e
commit 08f3d212ce
2 changed files with 69 additions and 52 deletions

View File

@ -452,7 +452,16 @@ namespace OpenSim.Region.ScriptEngine.Common
if (f == 4) { x = -x; s = -s; } if (f == 4) { x = -x; s = -s; }
if (f == 5) { z = -z; } if (f == 5) { z = -z; }
if (f == 6) { y = -y; } if (f == 6) { y = -y; }
return new LSL_Types.Quaternion(x, y, z, s);
LSL_Types.Quaternion result = new LSL_Types.Quaternion(x, y, z, s);
// a hack to correct a few questionable angles :(
LSL_Types.Vector3 fwdTest = new LSL_Types.Vector3(1, 0, 0);
LSL_Types.Vector3 leftTest = new LSL_Types.Vector3(0, 1, 0);
if (llVecDist(fwdTest * result, fwd) > 0.001 || llVecDist(leftTest * result, left) > 0.001)
result.s = -s;
return result;
} }
public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)

View File

@ -439,8 +439,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (f == 4) { x = -x; s = -s; } if (f == 4) { x = -x; s = -s; }
if (f == 5) { z = -z; } if (f == 5) { z = -z; }
if (f == 6) { y = -y; } if (f == 6) { y = -y; }
return new LSL_Types.Quaternion(x, y, z, s);
LSL_Types.Quaternion result = new LSL_Types.Quaternion(x, y, z, s);
// a hack to correct a few questionable angles :(
LSL_Types.Vector3 fwdTest = new LSL_Types.Vector3(1, 0, 0);
LSL_Types.Vector3 leftTest = new LSL_Types.Vector3(0, 1, 0);
if (llVecDist(fwdTest * result, fwd) > 0.001 || llVecDist(leftTest * result, left) > 0.001)
result.s = -s;
return result;
} }
public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r) public LSL_Types.Vector3 llRot2Fwd(LSL_Types.Quaternion r)