From 31de7b845f18182d47ee43125c3fe6488da841e6 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 3 Mar 2014 20:58:54 +0000 Subject: When positioning agent with PRIM_ROTATION in llSetLinkPrimitiveParams(), set the global rotation rather than the local rotation Functionally the same as the patch in http://opensimulator.org/mantis/view.php?id=7044, thanks Aleric. This commit also extends the regression test --- .../Shared/Api/Implementation/LSL_Api.cs | 14 ++++++++- .../Shared/Tests/LSL_ApiAvatarTests.cs | 36 +++++++++++++++------- 2 files changed, 38 insertions(+), 12 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 2e8b053..b333b55 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -8047,7 +8047,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api sp.OffsetPosition = rules.GetVector3Item(idx++); break; - case (int)ScriptBaseClass.PRIM_ROTATION: + case (int)ScriptBaseClass.PRIM_ROTATION: + if (remain < 1) + return null; + + Quaternion inRot = rules.GetQuaternionItem(idx++); + + SceneObjectPart parentPart = sp.ParentPart; + + if (parentPart != null) + sp.Rotation = m_host.GetWorldRotation() * inRot; + + break; + case (int)ScriptBaseClass.PRIM_ROT_LOCAL: if (remain < 1) return null; diff --git a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs index 167fe78..86381c4 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Tests/LSL_ApiAvatarTests.cs @@ -86,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests new SceneHelpers().SetupScene(); SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; + part.RotationOffset = new Quaternion(0.7071068f, 0, 0, 0.7071068f); LSL_Api apiGrp1 = new LSL_Api(); apiGrp1.Initialize(m_engine, part, null, null); @@ -99,17 +100,30 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero); // Test position - Vector3 newPos = new Vector3(1, 2, 3); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); - - Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); - - // Test rotation - Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); - apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); - - Assert.That( - sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); + { + Vector3 newPos = new Vector3(1, 2, 3); + apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); + + Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); + } + + // Test world rotation + { + Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); + apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); + + Assert.That( + sp.Rotation, new QuaternionToleranceConstraint(part.GetWorldRotation() * newRot, 0.000001)); + } + + // Test local rotation + { + Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); + apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROT_LOCAL, newRot)); + + Assert.That( + sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); + } } } } \ No newline at end of file -- cgit v1.1