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
0.8.0.3
Justin Clark-Casey (justincc) 2014-03-03 20:58:54 +00:00
parent 5038a59ef3
commit 31de7b845f
2 changed files with 35 additions and 9 deletions

View File

@ -8048,6 +8048,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; 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: case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
if (remain < 1) if (remain < 1)
return null; return null;

View File

@ -86,6 +86,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Tests
new SceneHelpers().SetupScene(); new SceneHelpers().SetupScene();
SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
part.RotationOffset = new Quaternion(0.7071068f, 0, 0, 0.7071068f);
LSL_Api apiGrp1 = new LSL_Api(); LSL_Api apiGrp1 = new LSL_Api();
apiGrp1.Initialize(m_engine, part, null, null); 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); sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, part.UUID, Vector3.Zero);
// Test position // Test position
{
Vector3 newPos = new Vector3(1, 2, 3); Vector3 newPos = new Vector3(1, 2, 3);
apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos)); apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos));
Assert.That(sp.OffsetPosition, Is.EqualTo(newPos)); Assert.That(sp.OffsetPosition, Is.EqualTo(newPos));
}
// Test rotation // Test world rotation
{
Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f); Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot)); 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( Assert.That(
sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001)); sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001));
} }
} }
}
} }