Make llGetObjectDetails() return the correct world rotation for a sitting avatar

This addresses http://opensimulator.org/mantis/view.php?id=6567
This creates a ScenePresence.GetWorldRotation() with the same semantics as SOP.GetWorldRotation()
SP.Rotation can't be used since it's relative to the sat upon prim if the avatar is sitting.
user_profiles
Justin Clark-Casey (justincc) 2013-03-14 21:23:48 +00:00
parent 9fad90a914
commit e9c394fb4e
2 changed files with 36 additions and 6 deletions

View File

@ -559,16 +559,28 @@ namespace OpenSim.Region.Framework.Scenes
private Quaternion m_bodyRot = Quaternion.Identity; private Quaternion m_bodyRot = Quaternion.Identity;
/// <summary>
/// The rotation of the avatar.
/// </summary>
/// <remarks>
/// If the avatar is not sitting, this is with respect to the world
/// If the avatar is sitting, this is a with respect to the part that it's sitting upon (a local rotation).
/// If you always want the world rotation, use GetWorldRotation()
/// </remarks>
public Quaternion Rotation public Quaternion Rotation
{ {
get { return m_bodyRot; } get
{
return m_bodyRot;
}
set set
{ {
m_bodyRot = value; m_bodyRot = value;
if (PhysicsActor != null) if (PhysicsActor != null)
{
PhysicsActor.Orientation = m_bodyRot; PhysicsActor.Orientation = m_bodyRot;
}
// m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot); // m_log.DebugFormat("[SCENE PRESENCE]: Body rot for {0} set to {1}", Name, m_bodyRot);
} }
} }
@ -608,6 +620,26 @@ namespace OpenSim.Region.Framework.Scenes
set { m_health = value; } set { m_health = value; }
} }
/// <summary>
/// Gets the world rotation of this presence.
/// </summary>
/// <remarks>
/// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not.
/// </remarks>
/// <returns></returns>
public Quaternion GetWorldRotation()
{
if (IsSatOnObject)
{
SceneObjectPart sitPart = ParentPart;
if (sitPart != null)
return sitPart.GetWorldRotation() * Rotation;
}
return Rotation;
}
public void AdjustKnownSeeds() public void AdjustKnownSeeds()
{ {
Dictionary<ulong, string> seeds; Dictionary<ulong, string> seeds;
@ -709,8 +741,6 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region Constructor(s) #region Constructor(s)
public ScenePresence( public ScenePresence(

View File

@ -10518,7 +10518,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z)); ret.Add(new LSL_Vector((double)av.AbsolutePosition.X, (double)av.AbsolutePosition.Y, (double)av.AbsolutePosition.Z));
break; break;
case ScriptBaseClass.OBJECT_ROT: case ScriptBaseClass.OBJECT_ROT:
ret.Add(new LSL_Rotation((double)av.Rotation.X, (double)av.Rotation.Y, (double)av.Rotation.Z, (double)av.Rotation.W)); ret.Add(new LSL_Rotation(av.GetWorldRotation()));
break; break;
case ScriptBaseClass.OBJECT_VELOCITY: case ScriptBaseClass.OBJECT_VELOCITY:
ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z)); ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z));