aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-08-04 01:00:33 +0100
committerJustin Clark-Casey (justincc)2011-08-04 01:00:33 +0100
commit7f6f100c5a93791e8af29bafcfb93cfd289d5e8b (patch)
treef36b5dfbc1414fa2564429dd3f4eec6dc1479201
parentextend npc move test to check a second movement (diff)
downloadopensim-SC-7f6f100c5a93791e8af29bafcfb93cfd289d5e8b.zip
opensim-SC-7f6f100c5a93791e8af29bafcfb93cfd289d5e8b.tar.gz
opensim-SC-7f6f100c5a93791e8af29bafcfb93cfd289d5e8b.tar.bz2
opensim-SC-7f6f100c5a93791e8af29bafcfb93cfd289d5e8b.tar.xz
When the NPC reaches within the SIGNIFICANT_CLIENT_MOVEMENT distance of the target, move it directly to the target.
This makes the movement exact. Regression test changed to check avatar reaches exact target. Also has the nice side effect of making NPC animations continue to work after the first movement (which wasn't working). However, avatar still pauses in mid-stride
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs3
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs2
3 files changed, 7 insertions, 3 deletions
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 54ef039..ba10423 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -1575,6 +1575,7 @@ namespace OpenSim.Region.Framework.Scenes
1575 if (distanceToTarget <= 1) 1575 if (distanceToTarget <= 1)
1576 { 1576 {
1577 // We are close enough to the target 1577 // We are close enough to the target
1578 AbsolutePosition = MoveToPositionTarget;
1578 ResetMoveToTarget(); 1579 ResetMoveToTarget();
1579 updated = true; 1580 updated = true;
1580 } 1581 }
@@ -1713,7 +1714,7 @@ namespace OpenSim.Region.Framework.Scenes
1713 /// </summary> 1714 /// </summary>
1714 public void ResetMoveToTarget() 1715 public void ResetMoveToTarget()
1715 { 1716 {
1716// m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name); 1717 m_log.DebugFormat("[SCENE PRESENCE]: Resetting move to target for {0}", Name);
1717 1718
1718 m_moveToPositionInProgress = false; 1719 m_moveToPositionInProgress = false;
1719 MoveToPositionTarget = Vector3.Zero; 1720 MoveToPositionTarget = Vector3.Zero;
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index dd94240..fdc3485 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -70,12 +70,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
70// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); 70// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget);
71 71
72 // Check the error term of the current position in relation to the target position 72 // Check the error term of the current position in relation to the target position
73 if (distanceToTarget <= 1) 73 if (distanceToTarget <= 2)
74 { 74 {
75// m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); 75// m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID);
76 // We are close enough to the target for now 76 // We are close enough to the target for now
77 presence.ResetMoveToTarget();
78 presence.Velocity = Vector3.Zero; 77 presence.Velocity = Vector3.Zero;
78 presence.AbsolutePosition = presence.MoveToPositionTarget;
79 presence.ResetMoveToTarget();
79 80
80 // FIXME: This doesn't work 81 // FIXME: This doesn't work
81 if (presence.PhysicsActor.Flying) 82 if (presence.PhysicsActor.Flying)
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 545819f..c9dddba 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -130,6 +130,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
130 130
131 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); 131 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
132 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); 132 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
133 Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
133 134
134 // Try a second movement 135 // Try a second movement
135 startPos = npc.AbsolutePosition; 136 startPos = npc.AbsolutePosition;
@@ -149,6 +150,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
149 150
150 distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); 151 distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
151 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move"); 152 Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
153 Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
152 } 154 }
153 } 155 }
154} \ No newline at end of file 156} \ No newline at end of file