integrating redundant code into operator

integration
SignpostMarv 2012-08-18 15:19:15 +01:00 committed by Melanie
parent ca33619e11
commit d72d599056
2 changed files with 7 additions and 14 deletions

View File

@ -330,14 +330,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key; return key;
} }
// convert a LSL_Rotation to a Quaternion
public static Quaternion Rot2Quaternion(LSL_Rotation r)
{
Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
q.Normalize();
return q;
}
//These are the implementations of the various ll-functions used by the LSL scripts. //These are the implementations of the various ll-functions used by the LSL scripts.
public LSL_Float llSin(double f) public LSL_Float llSin(double f)
{ {
@ -6532,12 +6524,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot) protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot)
{ {
// LSL quaternions can normalize to 0, normal Quaternions can't.
if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
rot.z = 1; // ZERO_ROTATION = 0,0,0,1
part.SitTargetPosition = offset; part.SitTargetPosition = offset;
part.SitTargetOrientation = Rot2Quaternion(rot); part.SitTargetOrientation = rot;
part.ParentGroup.HasGroupChanged = true; part.ParentGroup.HasGroupChanged = true;
} }

View File

@ -417,7 +417,12 @@ namespace OpenSim.Region.ScriptEngine.Shared
public static implicit operator OMV_Quaternion(Quaternion rot) public static implicit operator OMV_Quaternion(Quaternion rot)
{ {
return new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s); // LSL quaternions can normalize to 0, normal Quaternions can't.
if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
rot.z = 1; // ZERO_ROTATION = 0,0,0,1
OMV_Quaternion omvrot = new OMV_Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s);
omvrot.Normalize();
return omvrot;
} }
public static implicit operator Quaternion(OMV_Quaternion rot) public static implicit operator Quaternion(OMV_Quaternion rot)