aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC/Tests
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2011-11-05 01:38:42 +0000
committerJustin Clark-Casey (justincc)2011-11-05 01:38:42 +0000
commit28c4dc9be490a3beedccb17bc1b411e45cced846 (patch)
treea399c6faf3f08e53f20ae4aba546aff9cfdd083e /OpenSim/Region/OptionalModules/World/NPC/Tests
parentAdd comment for experimental effect of removing the Thread.Sleep(20) in ODEPr... (diff)
downloadopensim-SC-28c4dc9be490a3beedccb17bc1b411e45cced846.zip
opensim-SC-28c4dc9be490a3beedccb17bc1b411e45cced846.tar.gz
opensim-SC-28c4dc9be490a3beedccb17bc1b411e45cced846.tar.bz2
opensim-SC-28c4dc9be490a3beedccb17bc1b411e45cced846.tar.xz
Fix NPC sitting for prims without a sit target.
This is to partially address http://opensimulator.org/mantis/view.php?id=5769 We don't need to call SP.HandleAgentSit() again if we are within 10m since the autopilot won't trigger. By calling it twice, the position of the sitting NPC was wrongly adjusted, ending up near <0,0,0>. However, this change does mean that NPCs further than 10m away will not attempt to autopilot to the prim, though this code was broken anyway (is actually a different mechanism to normal NPC movmeent). Hopefully this can be addressed soon.
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC/Tests')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs41
1 files changed, 39 insertions, 2 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 174d74c..d2b79f7 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
231 } 231 }
232 232
233 [Test] 233 [Test]
234 public void TestSitAndStand() 234 public void TestSitAndStandWithSitTarget()
235 { 235 {
236 TestHelpers.InMethod(); 236 TestHelpers.InMethod();
237// log4net.Config.XmlConfigurator.Configure(); 237// log4net.Config.XmlConfigurator.Configure();
@@ -245,12 +245,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
245 ScenePresence npc = scene.GetScenePresence(npcId); 245 ScenePresence npc = scene.GetScenePresence(npcId);
246 SceneObjectPart part = SceneHelpers.AddSceneObject(scene); 246 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
247 247
248 // We must have a non Vector3.Zero sit target position otherwise part.SitTargetAvatar doesn't get set!
249 part.SitTargetPosition = new Vector3(0, 0, 1); 248 part.SitTargetPosition = new Vector3(0, 0, 1);
250 npcModule.Sit(npc.UUID, part.UUID, scene); 249 npcModule.Sit(npc.UUID, part.UUID, scene);
251 250
252 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); 251 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
253 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); 252 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
253 Assert.That(
254 npc.AbsolutePosition,
255 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
256
257 npcModule.Stand(npc.UUID, scene);
258
259 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
260 Assert.That(npc.ParentID, Is.EqualTo(0));
261 }
262
263 [Test]
264 public void TestSitAndStandWithNoSitTarget()
265 {
266 TestHelpers.InMethod();
267// log4net.Config.XmlConfigurator.Configure();
268
269 ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1));
270
271 // FIXME: To get this to work for now, we are going to place the npc right next to the target so that
272 // the autopilot doesn't trigger
273 Vector3 startPos = new Vector3(1, 1, 1);
274
275 INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();
276 UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance);
277
278 ScenePresence npc = scene.GetScenePresence(npcId);
279 SceneObjectPart part = SceneHelpers.AddSceneObject(scene);
280
281 npcModule.Sit(npc.UUID, part.UUID, scene);
282
283 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
284 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
285
286 // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the
287 // default avatar.
288 Assert.That(
289 npc.AbsolutePosition,
290 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.8857438f)));
254 291
255 npcModule.Stand(npc.UUID, scene); 292 npcModule.Stand(npc.UUID, scene);
256 293