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 test0.8.0.3
parent
5038a59ef3
commit
31de7b845f
|
@ -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;
|
||||||
|
|
|
@ -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);
|
{
|
||||||
apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_POSITION, newPos));
|
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));
|
Assert.That(sp.OffsetPosition, Is.EqualTo(newPos));
|
||||||
|
}
|
||||||
|
|
||||||
// Test rotation
|
// Test world rotation
|
||||||
Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
|
{
|
||||||
apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot));
|
Quaternion newRot = new Quaternion(0, 0.7071068f, 0, 0.7071068f);
|
||||||
|
apiGrp1.llSetLinkPrimitiveParams(2, new LSL_Types.list(ScriptBaseClass.PRIM_ROTATION, newRot));
|
||||||
|
|
||||||
Assert.That(
|
Assert.That(
|
||||||
sp.Rotation, new QuaternionToleranceConstraint(newRot, 0.000001));
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue