Add TestGetChildPartPositionAfterObjectRotation()

0.7.4.1
Justin Clark-Casey (justincc) 2012-04-17 02:14:10 +01:00
parent 2f2181683c
commit cca6b6bd0d
1 changed files with 37 additions and 1 deletions

View File

@ -111,8 +111,44 @@ namespace OpenSim.Region.Framework.Scenes.Tests
Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition)); Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition));
Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition)); Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition));
Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition)); Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition));
}
// TODO: Write test for child part position after rotation. [Test]
public void TestGetChildPartPositionAfterObjectRotation()
{
TestHelpers.InMethod();
Vector3 rootPartPosition = new Vector3(10, 20, 30);
Vector3 childOffsetPosition = new Vector3(2, 3, 4);
SceneObjectGroup so
= SceneHelpers.CreateSceneObject(2, m_ownerId, "obj1", 0x10);
so.AbsolutePosition = rootPartPosition;
so.Parts[1].OffsetPosition = childOffsetPosition;
m_scene.AddNewSceneObject(so, false);
so.UpdateGroupRotationR(Quaternion.CreateFromEulers(0, 0, -90 * Utils.DEG_TO_RAD));
// Calculate child absolute position.
Vector3 rotatedChildOffsetPosition
= new Vector3(childOffsetPosition.Y, -childOffsetPosition.X, childOffsetPosition.Z);
Vector3 childPosition = new Vector3(rootPartPosition + rotatedChildOffsetPosition);
SceneObjectPart childPart = so.Parts[1];
// FIXME: Should be childPosition after rotation?
Assert.That(childPart.AbsolutePosition, Is.EqualTo(rootPartPosition + childOffsetPosition));
Assert.That(childPart.GroupPosition, Is.EqualTo(rootPartPosition));
Assert.That(childPart.GetWorldPosition(), Is.EqualTo(childPosition));
// Relative to root part as (0, 0, 0)
Assert.That(childPart.RelativePosition, Is.EqualTo(childOffsetPosition));
// Relative to root part as (0, 0, 0)
Assert.That(childPart.OffsetPosition, Is.EqualTo(childOffsetPosition));
} }
} }
} }