From 8159fd7110459246ff61a41800899f5d854eceee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 21 Sep 2011 19:28:41 +0100 Subject: When calling osNpcMoveTo(), rotate the avatar in the direction of travel. This stops the npc walking backwards if the target is directly behind. This means that the npc no longer returns to its original rotation once movement has finished. If you want this behaviour, please store and reset the original rotation after movement. This is somewhat to address http://opensimulator.org/mantis/view.php?id=5678 --- .../OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 246bc34..1a0d0c7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -182,18 +182,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); - Vector3 targetPos = startPos + new Vector3(0, 0, 10); + Vector3 targetPos = startPos + new Vector3(0, 10, 0); npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); + Assert.That( + npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001)); scene.Update(); // We should really check the exact figure. Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X)); - Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y)); - Assert.That(npc.AbsolutePosition.Z, Is.GreaterThan(startPos.Z)); - Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.Z)); + Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y)); + Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); + Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X)); for (int i = 0; i < 10; i++) scene.Update(); @@ -208,6 +211,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests targetPos = startPos + new Vector3(10, 0, 0); npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); +// Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1))); + Assert.That( + npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001)); + scene.Update(); // We should really check the exact figure. -- cgit v1.1