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 +++++++++++++++++++---
.../Shared/Api/Implementation/LSL_Api.cs | 2 +-
2 files changed, 36 insertions(+), 6 deletions(-)
(limited to 'OpenSim/Region')
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(
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index dd7ee24..47f8758 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -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));
break;
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;
case ScriptBaseClass.OBJECT_VELOCITY:
ret.Add(new LSL_Vector(av.Velocity.X, av.Velocity.Y, av.Velocity.Z));
--
cgit v1.1