From e9c394fb4ed56ffb931a0161b8c6fdc929b38058 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 14 Mar 2013 21:23:48 +0000 Subject: 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. --- OpenSim/Region/Framework/Scenes/ScenePresence.cs | 40 +++++++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/Framework') diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index a7c7539..82bb759 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -559,16 +559,28 @@ namespace OpenSim.Region.Framework.Scenes private Quaternion m_bodyRot = Quaternion.Identity; + /// + /// The rotation of the avatar. + /// + /// + /// 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() + /// public Quaternion Rotation { - get { return m_bodyRot; } + get + { + return m_bodyRot; + } + set { m_bodyRot = value; + if (PhysicsActor != null) - { PhysicsActor.Orientation = 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; } } + /// + /// Gets the world rotation of this presence. + /// + /// + /// Unlike Rotation, this returns the world rotation no matter whether the avatar is sitting on a prim or not. + /// + /// + public Quaternion GetWorldRotation() + { + if (IsSatOnObject) + { + SceneObjectPart sitPart = ParentPart; + + if (sitPart != null) + return sitPart.GetWorldRotation() * Rotation; + } + + return Rotation; + } + public void AdjustKnownSeeds() { Dictionary seeds; @@ -709,8 +741,6 @@ namespace OpenSim.Region.Framework.Scenes #endregion - - #region Constructor(s) public ScenePresence( -- cgit v1.1