From 4cdc8806fbc0d0d9b0ff878b30a4491b347cf2dc Mon Sep 17 00:00:00 2001 From: Melanie Date: Sat, 23 Jul 2011 11:39:32 +0100 Subject: Fix LLTextBox to work with the updated libOMV --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 15bc1b7..3afcc8d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -1157,7 +1157,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } - public void SendTextBoxRequest(string message, int chatChannel, string objectname, string ownerFirstName, string ownerLastName, UUID objectId) + public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId) { } -- cgit v1.1 From 59f548cda82facef003fb7309180412254a234a1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Mon, 1 Aug 2011 23:41:29 +0100 Subject: Get osNpcCreate appearance working with avatars that are currently in the scene. Had to stop using AvatarService for now since it doesn't store baked texture IDs (which is why this was failing). Also failing because cloning appearance was also cloning the AvatarApperance.Owner field, which we weren't then changing. Extended TestCreate() to check this. --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 25 +++++++++++++++++----- .../World/NPC/Tests/NPCModuleTests.cs | 23 ++++++++++++++++++-- 2 files changed, 41 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3cdd06d..64f82c9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -59,14 +59,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (m_appearanceCache.ContainsKey(target)) return m_appearanceCache[target]; - AvatarAppearance appearance = scene.AvatarService.GetAppearance(target); - if (appearance != null) + ScenePresence originalPresence = scene.GetScenePresence(target); + + if (originalPresence != null) { - m_appearanceCache.Add(target, appearance); - return appearance; + AvatarAppearance originalAppearance = originalPresence.Appearance; + m_appearanceCache.Add(target, originalAppearance); + return originalAppearance; } + else + { + m_log.DebugFormat( + "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); - return new AvatarAppearance(); + return new AvatarAppearance(); + } } public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) @@ -86,8 +93,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); + npcAppearance.Owner = acd.AgentID; acd.Appearance = npcAppearance; +// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) +// { +// m_log.DebugFormat( +// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", +// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); +// } + scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); scene.AddNewClient(npcAvatar); diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 899e721..bc151ed 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -27,11 +27,13 @@ using System; using System.Reflection; +using log4net; using Nini.Config; using NUnit.Framework; using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; +using OpenSim.Region.CoreModules.Avatar.AvatarFactory; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -58,14 +60,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule(), new LocalAvatarServicesConnector()); + SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector()); + TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); +// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); + + // 8 is the index of the first baked texture in AvatarAppearance + UUID originalFace8TextureId = TestHelper.ParseTail(0x10); + Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); + Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); + originalTef.TextureID = originalFace8TextureId; + + // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell + // ScenePresence.SendInitialData() to reset our entire appearance. + scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); + + afm.SetAppearance(originalClient, originalTe, null); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, UUID.Zero); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); ScenePresence npc = scene.GetScenePresence(npcId); + Assert.That(npc, Is.Not.Null); + Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); } } } \ No newline at end of file -- cgit v1.1 From b6ac1c46cd473b129b70344f0001f1e8f97d8860 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 00:13:04 +0100 Subject: Get rid of AvatarAppearance.Owner to simplify the code. This is not used for anything - appearances are always properties of objects with ids (ScenePresence, AgentCircuitData) and just has the potential to get out of sync when the appearance is cloned. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 1 - 1 file changed, 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 64f82c9..6286dc8 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -93,7 +93,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); - npcAppearance.Owner = acd.AgentID; acd.Appearance = npcAppearance; // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) -- cgit v1.1 From c122489e0947300753281e88771b7a74d49869c7 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 2 Aug 2011 23:41:12 +0100 Subject: Partially fix autopilot/go here This now works again except that it requires a click or avatar mvmt to get going This is because the ScenePresence.HandleAgentUpdate() method doesn't trigger until the client does something significant, at which point autopilot takes over. Even clicking is enough to trigger. This will be improved presently. --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 3afcc8d..e87993a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -99,6 +99,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { } + public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 6286dc8..8cb8318 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -140,7 +140,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC { ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); - sp.DoAutoPilot(0, pos, m_avatars[agentID]); + +// m_log.DebugFormat( +// "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); +// +// List targetArgs = new List(); +// targetArgs.Add(pos.X); +// targetArgs.Add(pos.Y); +// targetArgs.Add(pos.Z); +// sp.DoMoveToPosition(null, "NPC", targetArgs); +// sp.DoMoveToPosition(0, pos, m_avatars[agentID]); } } } -- cgit v1.1 From 6e4ec2972266ae250337867fe1ba1944131f212d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 04:19:19 +0100 Subject: Do a partial fix/implementation of OSSL osNpcMoveTo() Avatar moves and stops. However, will stop in mid stride. And if the move to position is in the air, avatar will continue to make vain and quite hilarious attempts to take off (but never doing so). Clearly more work is needed. --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 59 ++++++++++++++++++---- 1 file changed, 48 insertions(+), 11 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 8cb8318..fcfacc6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -46,12 +46,54 @@ namespace OpenSim.Region.OptionalModules.World.NPC // private const bool m_enabled = false; - private Dictionary m_avatars = new Dictionary(); - private Dictionary m_appearanceCache = new Dictionary(); + private Dictionary m_avatars = new Dictionary(); + private Dictionary m_appearanceCache = new Dictionary(); public void Initialise(Scene scene, IConfigSource source) { scene.RegisterModuleInterface(this); + scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; + } + + public void HandleOnSignificantClientMovement(ScenePresence presence) + { + lock (m_avatars) + { + if (m_avatars.ContainsKey(presence.UUID)) + { + double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Abs pos of {0} is {1}, target {2}, distance {3}", +// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); + + // Check the error term of the current position in relation to the target position + if (distanceToTarget <= 1) + { +// m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); + // We are close enough to the target for now + presence.ResetMoveToPosition(); + presence.Velocity = Vector3.Zero; + + // FIXME: This doesn't work + if (presence.PhysicsActor.Flying) + presence.Animator.TrySetMovementAnimation("HOVER"); + else + presence.Animator.TrySetMovementAnimation("STAND"); + } + else + { + Vector3 agent_control_v3 = new Vector3(); + presence.DoMoveToPositionUpdate(ref agent_control_v3, presence.Rotation, false, true); + presence.AddNewMovement(agent_control_v3, presence.Rotation); + } +// +//// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); + +// +// + + } + } } private AvatarAppearance GetAppearance(UUID target, Scene scene) @@ -141,15 +183,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC ScenePresence sp; scene.TryGetScenePresence(agentID, out sp); -// m_log.DebugFormat( -// "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); -// -// List targetArgs = new List(); -// targetArgs.Add(pos.X); -// targetArgs.Add(pos.Y); -// targetArgs.Add(pos.Z); -// sp.DoMoveToPosition(null, "NPC", targetArgs); -// sp.DoMoveToPosition(0, pos, m_avatars[agentID]); + m_log.DebugFormat( + "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); + + sp.DoMoveToPosition(0, pos, m_avatars[agentID]); } } } -- cgit v1.1 From 797def8aa4a009ba3bc44d6b73e063e4bb61ba97 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 04:33:45 +0100 Subject: Put config to enable disable [NPC] module. Default is disabled. You will need to explicitly enable to toy with this. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index fcfacc6..d139b25 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -44,15 +44,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); - // private const bool m_enabled = false; - private Dictionary m_avatars = new Dictionary(); private Dictionary m_appearanceCache = new Dictionary(); public void Initialise(Scene scene, IConfigSource source) { - scene.RegisterModuleInterface(this); - scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; + IConfig config = source.Configs["NPC"]; + + if (config != null && config.GetBoolean("Enabled", false)) + { + scene.RegisterModuleInterface(this); + scene.EventManager.OnSignificantClientMovement += HandleOnSignificantClientMovement; + } } public void HandleOnSignificantClientMovement(ScenePresence presence) -- cgit v1.1 From b7a3f36c65474ffd959ff0053f1602235ce2f2e0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 04:48:47 +0100 Subject: enable the NPC module for its regression test --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index bc151ed..9e77e7d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -59,6 +59,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests config.AddConfig("AvatarService"); config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); + config.AddConfig("NPC"); + config.Configs["NPC"].Set("Enabled", "true"); AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneSetupHelpers.SetupScene(); -- cgit v1.1 From 2964467708871f5932c46ad04e002a5506dd7732 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 22:11:05 +0100 Subject: get rid of vestigal move to parameters --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index e87993a..dfc624d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -328,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event UpdateVector OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d139b25..a78ad0c 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -189,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); - sp.DoMoveToPosition(0, pos, m_avatars[agentID]); + sp.DoMoveToPosition(pos); } } } -- cgit v1.1 From a333c60f28acf1298c929f9129d3537f3f97e638 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 22:34:05 +0100 Subject: refactor: rename the move to position methods to move to target to be consistent with terminology used by scene object part and elsewhere --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index a78ad0c..1d88e43 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -74,7 +74,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { // m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); // We are close enough to the target for now - presence.ResetMoveToPosition(); + presence.ResetMoveToTarget(); presence.Velocity = Vector3.Zero; // FIXME: This doesn't work @@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC else { Vector3 agent_control_v3 = new Vector3(); - presence.DoMoveToPositionUpdate(ref agent_control_v3, presence.Rotation, false, true); + presence.HandleMoveToPositionUpdate(ref agent_control_v3, presence.Rotation, false, true); presence.AddNewMovement(agent_control_v3, presence.Rotation); } // @@ -189,7 +189,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); - sp.DoMoveToPosition(pos); + sp.MoveToTarget(pos); } } } -- cgit v1.1 From e0503d397c8cda2c12944e8a8200e417164a4121 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 22:45:43 +0100 Subject: stop avatar service being set up in NPC TestCreate() - it's no longer used --- .../World/NPC/Tests/NPCModuleTests.cs | 54 +++++++++++++++++++--- 1 file changed, 48 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 9e77e7d..c5770d3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -54,17 +54,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests IConfigSource config = new IniConfigSource(); - config.AddConfig("Modules"); - config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); - config.AddConfig("AvatarService"); - config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); - config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); +// config.AddConfig("Modules"); +// config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); +// config.AddConfig("AvatarService"); +// config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); +// config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector()); + SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -88,5 +88,47 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); } + +// [Test] +// public void TestMove() +// { +// TestHelper.InMethod(); +//// log4net.Config.XmlConfigurator.Configure(); +// +// IConfigSource config = new IniConfigSource(); +// +// config.AddConfig("Modules"); +// config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); +// config.AddConfig("AvatarService"); +// config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); +// config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); +// config.AddConfig("NPC"); +// config.Configs["NPC"].Set("Enabled", "true"); +// +// TestScene scene = SceneSetupHelpers.SetupScene(); +// SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector()); +// TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); +//// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); +// +// // 8 is the index of the first baked texture in AvatarAppearance +// UUID originalFace8TextureId = TestHelper.ParseTail(0x10); +// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); +// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); +// originalTef.TextureID = originalFace8TextureId; +// +// // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell +// // ScenePresence.SendInitialData() to reset our entire appearance. +// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); +// +// afm.SetAppearance(originalClient, originalTe, null); +// +// INPCModule npcModule = scene.RequestModuleInterface(); +// UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); +// +// ScenePresence npc = scene.GetScenePresence(npcId); +// +// Assert.That(npc, Is.Not.Null); +// Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); +// } } } \ No newline at end of file -- cgit v1.1 From d78fe441916b6e66cd5c071bcbbf027bb28feabd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 22:51:46 +0100 Subject: Add passing but incomplete NPC move regression test --- .../World/NPC/Tests/NPCModuleTests.cs | 72 ++++++++-------------- 1 file changed, 25 insertions(+), 47 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c5770d3..46e39ef 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -53,12 +53,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // log4net.Config.XmlConfigurator.Configure(); IConfigSource config = new IniConfigSource(); - -// config.AddConfig("Modules"); -// config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); -// config.AddConfig("AvatarService"); -// config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); -// config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); @@ -89,46 +83,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); } -// [Test] -// public void TestMove() -// { -// TestHelper.InMethod(); -//// log4net.Config.XmlConfigurator.Configure(); -// -// IConfigSource config = new IniConfigSource(); -// -// config.AddConfig("Modules"); -// config.Configs["Modules"].Set("AvatarServices", "LocalAvatarServicesConnector"); -// config.AddConfig("AvatarService"); -// config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); -// config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); -// config.AddConfig("NPC"); -// config.Configs["NPC"].Set("Enabled", "true"); -// -// TestScene scene = SceneSetupHelpers.SetupScene(); -// SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector()); -// TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); -//// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); -// -// // 8 is the index of the first baked texture in AvatarAppearance -// UUID originalFace8TextureId = TestHelper.ParseTail(0x10); -// Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); -// Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); -// originalTef.TextureID = originalFace8TextureId; -// -// // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell -// // ScenePresence.SendInitialData() to reset our entire appearance. -// scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); -// -// afm.SetAppearance(originalClient, originalTe, null); -// -// INPCModule npcModule = scene.RequestModuleInterface(); -// UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); -// -// ScenePresence npc = scene.GetScenePresence(npcId); -// -// Assert.That(npc, Is.Not.Null); -// Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); -// } + [Test] + public void TestMove() + { + TestHelper.InMethod(); + log4net.Config.XmlConfigurator.Configure(); + + IConfigSource config = new IniConfigSource(); + + config.AddConfig("NPC"); + config.Configs["NPC"].Set("Enabled", "true"); + + TestScene scene = SceneSetupHelpers.SetupScene(); + SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule()); + TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); +// ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); + + Vector3 startPos = new Vector3(128, 128, 30); + INPCModule npcModule = scene.RequestModuleInterface(); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId); + + ScenePresence npc = scene.GetScenePresence(npcId); + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + + // Not yet complete + } } } \ No newline at end of file -- cgit v1.1 From 21d8a6b0e8f1480a5ac75ae4e76d01d4ae2fb13f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 23:06:18 +0100 Subject: extend move test to check one beat of the simulator without actually asking the npc to move. --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 46e39ef..4e2b5f1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests public void TestMove() { TestHelper.InMethod(); - log4net.Config.XmlConfigurator.Configure(); +// log4net.Config.XmlConfigurator.Configure(); IConfigSource config = new IniConfigSource(); @@ -106,6 +106,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests ScenePresence npc = scene.GetScenePresence(npcId); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + // For now, we'll make the scene presence fly to simplify this test, but this needs to change. + npc.PhysicsActor.Flying = true; + + scene.Update(); + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + // Not yet complete } } -- cgit v1.1 From 31cea17f8e7995277008370738be1d510dfede7a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 23:13:52 +0100 Subject: extend move test to check avatar is moving in the right direction after setting a move target --- .../OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 4e2b5f1..512405a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -112,6 +112,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + Vector3 targetPos = new Vector3(128, 128, 40); + npcModule.Autopilot(npc.UUID, scene, targetPos); + + Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); + + 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)); + // Not yet complete } } -- cgit v1.1 From 61d49d4f63eafa68d0b63877029da3475d977263 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 23:20:36 +0100 Subject: rename NPC.Autopilot to NPC.MoveToTarget internally. Add method doc to INPCModule --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 1d88e43..f9c41d7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -177,7 +177,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public void Autopilot(UUID agentID, Scene scene, Vector3 pos) + public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) { lock (m_avatars) { diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 512405a..2e3d431 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Vector3 targetPos = new Vector3(128, 128, 40); - npcModule.Autopilot(npc.UUID, scene, targetPos); + npcModule.MoveToTarget(npc.UUID, scene, targetPos); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); -- cgit v1.1 From 31fb6b2d72081a7ab27199f57e6a40fc1e478bc2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 3 Aug 2011 23:40:05 +0100 Subject: remove move to duck walk compensation - no longer required. extends npc move to regression test to check stop after sufficient sim updates --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 2e3d431..57847f7 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -125,7 +125,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.AbsolutePosition.Z, Is.GreaterThan(startPos.Z)); Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.Z)); - // Not yet complete + for (int i = 0; i < 10; i++) + scene.Update(); + + double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position"); } } } \ No newline at end of file -- cgit v1.1 From a2f5b4ac9afeec2b8f44ba09d7236a134f187bfe Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 00:10:53 +0100 Subject: Rename HandleMoveToPositionUpdate() to HandleMoveToTargetUpdate() for consistency. Improve method doc. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index f9c41d7..dd94240 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC else { Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToPositionUpdate(ref agent_control_v3, presence.Rotation, false, true); + presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation, false, true); presence.AddNewMovement(agent_control_v3, presence.Rotation); } // -- cgit v1.1 From ba0c65e028ecd3c19a11e6e5557fb004f9dc6c01 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 00:25:51 +0100 Subject: extend npc move test to check a second movement --- .../World/NPC/Tests/NPCModuleTests.cs | 23 ++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 57847f7..545819f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); - Vector3 targetPos = new Vector3(128, 128, 40); + Vector3 targetPos = startPos + new Vector3(0, 0, 10); npcModule.MoveToTarget(npc.UUID, scene, targetPos); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -129,7 +129,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests scene.Update(); double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); - Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position"); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); + + // Try a second movement + startPos = npc.AbsolutePosition; + targetPos = startPos + new Vector3(10, 0, 0); + npcModule.MoveToTarget(npc.UUID, scene, targetPos); + + scene.Update(); + + // We should really check the exact figure. + Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X)); + Assert.That(npc.AbsolutePosition.X, Is.LessThan(targetPos.X)); + Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y)); + Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z)); + + for (int i = 0; i < 10; i++) + scene.Update(); + + distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); + Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move"); } } } \ No newline at end of file -- cgit v1.1 From 7f6f100c5a93791e8af29bafcfb93cfd289d5e8b Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 01:00:33 +0100 Subject: 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 --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 5 +++-- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') 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 // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); // Check the error term of the current position in relation to the target position - if (distanceToTarget <= 1) + if (distanceToTarget <= 2) { // m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); // We are close enough to the target for now - presence.ResetMoveToTarget(); presence.Velocity = Vector3.Zero; + presence.AbsolutePosition = presence.MoveToPositionTarget; + presence.ResetMoveToTarget(); // FIXME: This doesn't work 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 double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); + Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); // Try a second movement startPos = npc.AbsolutePosition; @@ -149,6 +150,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move"); + Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); } } } \ No newline at end of file -- cgit v1.1 From fc64cc2439278f442839c69a7d98125f47019613 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 01:05:43 +0100 Subject: Make SIGNIFICANT_MOVEMENT SP constant a top-level property so that other classes can use it. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index fdc3485..a0a24f2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -70,7 +70,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC // presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget, distanceToTarget); // Check the error term of the current position in relation to the target position - if (distanceToTarget <= 2) + if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) { // m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); // We are close enough to the target for now -- cgit v1.1 From 7b2b47530e48153b53c00cd33356abbbdb13d0b5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 01:16:24 +0100 Subject: move reset code out of HandleMoveToTargetUpdate() so that we only call it where needed instead of passing in a flag --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index a0a24f2..fa60653 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC else { Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation, false, true); + presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation, true); presence.AddNewMovement(agent_control_v3, presence.Rotation); } // -- cgit v1.1 From 61a931490dae6a10adc915788bc661680be6778c Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 01:30:37 +0100 Subject: move bAllowUpdateMoveToPosition switch outside of HandleMoveToTargetUpdate() --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index fa60653..2215495 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -87,7 +87,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC else { Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation, true); + presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); presence.AddNewMovement(agent_control_v3, presence.Rotation); } // -- cgit v1.1 From 54ce0293423b4286fe62cbadc3b1441cae5f78eb Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 02:31:40 +0100 Subject: if an NPC move to target is above the terrain then make it fly to destination --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 2215495..30e81fc 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -62,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { lock (m_avatars) { - if (m_avatars.ContainsKey(presence.UUID)) + if (m_avatars.ContainsKey(presence.UUID) && presence.MovingToTarget) { double distanceToTarget = Util.GetDistanceTo(presence.AbsolutePosition, presence.MoveToPositionTarget); // m_log.DebugFormat( @@ -72,8 +72,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC // Check the error term of the current position in relation to the target position if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) { -// m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0} {1}", presence.Name, presence.UUID); - // We are close enough to the target for now + m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); + // We are close enough to the target presence.Velocity = Vector3.Zero; presence.AbsolutePosition = presence.MoveToPositionTarget; presence.ResetMoveToTarget(); @@ -86,6 +86,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC } else { + m_log.DebugFormat( + "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", + presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); + Vector3 agent_control_v3 = new Vector3(); presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); presence.AddNewMovement(agent_control_v3, presence.Rotation); -- cgit v1.1 From 1918402cb181a39f8c085a409909dccb5c988aa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 4 Aug 2011 03:08:35 +0100 Subject: if an NPC target is set to a ground location, then automatically land them when they get there. This doesn't help where the target is a prim surface. In these situations, it might be better to provide manual overrides so the script can control whethre an avatar flys there/lands, etc. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 30e81fc..4f21d9d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -72,8 +72,19 @@ namespace OpenSim.Region.OptionalModules.World.NPC // Check the error term of the current position in relation to the target position if (distanceToTarget <= ScenePresence.SIGNIFICANT_MOVEMENT) { - m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); // We are close enough to the target + m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); + + if (presence.PhysicsActor.Flying) + { + Vector3 targetPos = presence.MoveToPositionTarget; + float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; + if (targetPos.Z - terrainHeight < 0.2) + { + presence.PhysicsActor.Flying = false; + } + } + presence.Velocity = Vector3.Zero; presence.AbsolutePosition = presence.MoveToPositionTarget; presence.ResetMoveToTarget(); -- cgit v1.1 From bda1a4be4567181df6c18ce6e059ca8982bc5fa1 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:26:37 +0100 Subject: rename test SceneSetupHelpers -> SceneHelpers for consistency --- .../Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c9dddba..c0053c9 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -57,9 +57,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests config.Configs["NPC"].Set("Enabled", "true"); AvatarFactoryModule afm = new AvatarFactoryModule(); - TestScene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); - TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); + TestClient originalClient = SceneHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); // 8 is the index of the first baked texture in AvatarAppearance @@ -94,9 +94,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests config.AddConfig("NPC"); config.Configs["NPC"].Set("Enabled", "true"); - TestScene scene = SceneSetupHelpers.SetupScene(); - SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule()); - TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); + TestScene scene = SceneHelpers.SetupScene(); + SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); + TestClient originalClient = SceneHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); Vector3 startPos = new Vector3(128, 128, 30); -- cgit v1.1 From dad1d6df181151ae45fb998447b58d5589459627 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 00:31:03 +0100 Subject: rename TestHelper => TestHelpers for consistency --- .../Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index c0053c9..28fa8a2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -49,7 +49,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests [Test] public void TestCreate() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IConfigSource config = new IniConfigSource(); @@ -59,11 +59,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); + TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); // 8 is the index of the first baked texture in AvatarAppearance - UUID originalFace8TextureId = TestHelper.ParseTail(0x10); + UUID originalFace8TextureId = TestHelpers.ParseTail(0x10); Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); originalTef.TextureID = originalFace8TextureId; @@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests [Test] public void TestMove() { - TestHelper.InMethod(); + TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); IConfigSource config = new IniConfigSource(); @@ -96,7 +96,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); + TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); Vector3 startPos = new Vector3(128, 128, 30); -- cgit v1.1 From 85e07c78fbed9e85c142c0f565c27015ad95769d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Sat, 6 Aug 2011 02:17:41 +0100 Subject: refactor: Change SceneHelpers.AddClient() to AddScenePresence(). This seems to make more sense as we can get SP.ControllingClient --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 28fa8a2..a0260a5 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); + IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); // 8 is the index of the first baked texture in AvatarAppearance @@ -96,7 +96,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); - TestClient originalClient = SceneHelpers.AddClient(scene, TestHelpers.ParseTail(0x1)); + IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); Vector3 startPos = new Vector3(128, 128, 30); -- cgit v1.1 From e869eeb0bfc48c769f680970f99e4c67dd5a1a70 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 03:51:34 +0100 Subject: Implement first draft functions for saving and loading NPC appearance from storage. This works by serializing and deserializing NPC AvatarAppearance to a notecard in the prim inventory and making the required baked textures permanent. By using notecards, we avoid lots of awkward, technical and user-unfriendly issues concerning retaining asset references and creating a new asset type. Notecards also allow different appearances to be swapped and manipulated easily. This also allows stored NPC appearances to work transparently with OARs/IARs since the UUID scan will pick up and store the necessary references from the notecard text. This works in my basic test but is not at all ready for user use or bug reporting yet. --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 29 ++++++++++++++++++++++ .../World/NPC/Tests/NPCModuleTests.cs | 2 +- 2 files changed, 30 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 4f21d9d..d966345 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -137,6 +137,35 @@ namespace OpenSim.Region.OptionalModules.World.NPC } } + public bool IsNPC(UUID agentId, Scene scene) + { + ScenePresence sp = scene.GetScenePresence(agentId); + if (sp == null || sp.IsChildAgent) + return false; + + lock (m_avatars) + return m_avatars.ContainsKey(agentId); + } + + public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) + { + ScenePresence sp = scene.GetScenePresence(agentId); + if (sp == null || sp.IsChildAgent) + return false; + + lock (m_avatars) + if (!m_avatars.ContainsKey(agentId)) + return false; + + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); + sp.Appearance = npcAppearance; + + IAvatarFactory module = scene.RequestModuleInterface(); + module.SendAppearance(sp.UUID); + + return true; + } + public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index a0260a5..2ec354f 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -72,7 +72,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); - afm.SetAppearance(originalClient, originalTe, null); + afm.SetAppearanceFromClient(originalClient, originalTe, null); INPCModule npcModule = scene.RequestModuleInterface(); UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); -- cgit v1.1 From 92e96d394a1712ed16b0a7835dd2ccfde01f3fee Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 23:11:07 +0100 Subject: When an NPC is created, stop telling neighbouring regions to expect a child agent --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 8 ++------ OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 8 +------- 2 files changed, 3 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index dfc624d..b3e2495 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event DeRezObject OnDeRezObject; public event Action OnRegionHandShakeReply; public event GenericCall1 OnRequestWearables; - public event GenericCall1 OnCompleteMovementToRegion; + public event Action OnCompleteMovementToRegion; public event UpdateAgent OnPreAgentUpdate; public event UpdateAgent OnAgentUpdate; public event AgentRequestSit OnAgentRequestSit; @@ -745,12 +745,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC { OnRegionHandShakeReply(this); } - - if (OnCompleteMovementToRegion != null) - { - OnCompleteMovementToRegion(this); - } } + public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) { } diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d966345..88867f2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -201,13 +201,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); - // Shouldn't call this - temporary. - sp.CompleteMovement(npcAvatar); - -// sp.SendAppearanceToAllOtherAgents(); -// -// // Send animations back to the avatar as well -// sp.Animator.SendAnimPack(); + sp.CompleteMovement(npcAvatar, false); } else { -- cgit v1.1 From cba54090c759d1b21701179493f8399eb1b7a60f Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 9 Aug 2011 23:25:52 +0100 Subject: When an NPC appearance is loaded, rez the attachments too --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 1 + 1 file changed, 1 insertion(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 88867f2..068eec8 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -159,6 +159,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; + sp.RezAttachments(); IAvatarFactory module = scene.RequestModuleInterface(); module.SendAppearance(sp.UUID); -- cgit v1.1 From 195c1dc9b8b8511980d9a607a242b24a5a91da17 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:26:38 +0100 Subject: implement osNpcStopMoveTo() to cancel any current move target --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 37 ++++++++++++++++++++-- 1 file changed, 34 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 068eec8..87cb322 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public void MoveToTarget(UUID agentID, Scene scene, Vector3 pos) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) { lock (m_avatars) { @@ -230,22 +230,49 @@ namespace OpenSim.Region.OptionalModules.World.NPC "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); sp.MoveToTarget(pos); + + return true; + } + } + + return false; + } + + public bool StopMoveToTarget(UUID agentID, Scene scene) + { + lock (m_avatars) + { + if (m_avatars.ContainsKey(agentID)) + { + ScenePresence sp; + scene.TryGetScenePresence(agentID, out sp); + + sp.Velocity = Vector3.Zero; + sp.ResetMoveToTarget(); + + return true; } } + + return false; } - public void Say(UUID agentID, Scene scene, string text) + public bool Say(UUID agentID, Scene scene, string text) { lock (m_avatars) { if (m_avatars.ContainsKey(agentID)) { m_avatars[agentID].Say(text); + + return true; } } + + return false; } - public void DeleteNPC(UUID agentID, Scene scene) + public bool DeleteNPC(UUID agentID, Scene scene) { lock (m_avatars) { @@ -253,8 +280,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC { scene.RemoveClient(agentID); m_avatars.Remove(agentID); + + return true; } } + + return false; } public void PostInitialise() -- cgit v1.1 From 4cb8d6379ddb39cfb8b30a63475e154a00a78110 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 00:59:31 +0100 Subject: Stop trying to deregister caps or close child agents when an NPC is removed --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 87cb322..7b9457a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -278,7 +278,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { - scene.RemoveClient(agentID); + scene.RemoveClient(agentID, false); m_avatars.Remove(agentID); return true; -- cgit v1.1 From 5d6c9644faf6aeac38410af9cff97adfef88d7aa Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 01:47:37 +0100 Subject: early code to allow scripts to force npcs not to fly when moving to target this is to allow walking on prims. it will be up to the script writer to be sure that there is a continuous path. currently implemented in osNpcMoveToTarget(), but none of this is final. --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 4 ++-- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index b3e2495..cfd692d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -328,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public event ScriptReset OnScriptReset; public event GetScriptRunning OnGetScriptRunning; public event SetScriptRunning OnSetScriptRunning; - public event Action OnAutoPilotGo; + public event Action OnAutoPilotGo; public event TerrainUnacked OnUnackedTerrain; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 7b9457a..d0b5a94 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -217,7 +217,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly) { lock (m_avatars) { @@ -229,7 +229,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC m_log.DebugFormat( "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); - sp.MoveToTarget(pos); + sp.MoveToTarget(pos, noFly); return true; } diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 2ec354f..81497d5 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Vector3 targetPos = startPos + new Vector3(0, 0, 10); - npcModule.MoveToTarget(npc.UUID, scene, targetPos); + npcModule.MoveToTarget(npc.UUID, scene, targetPos, false); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -135,7 +135,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // Try a second movement startPos = npc.AbsolutePosition; targetPos = startPos + new Vector3(10, 0, 0); - npcModule.MoveToTarget(npc.UUID, scene, targetPos); + npcModule.MoveToTarget(npc.UUID, scene, targetPos, false); scene.Update(); -- cgit v1.1 From 7f499ff3f386d57bcd81ebb3f58f110011100604 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 10 Aug 2011 23:56:19 +0100 Subject: Add a OS_NPC_LAND_AT_TARGET option to osMoveToTarget() Default for this function is now not to automatically land. This allows better control by scripts when an avatar is going to be landing on a prim rather than the ground. Stopping the avatar involves faking a collision, to avoid the pid controller making it overshoot. A better approach would be to gradually slow the avatar as we near the target --- .../Region/OptionalModules/World/NPC/NPCAvatar.cs | 5 ++++ .../Region/OptionalModules/World/NPC/NPCModule.cs | 33 ++++++++++++++-------- .../World/NPC/Tests/NPCModuleTests.cs | 4 +-- 3 files changed, 29 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index cfd692d..d63c2a6 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -37,6 +37,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC { public class NPCAvatar : IClientAPI { + /// + /// Signal whether the avatar should land when it reaches a move target + /// + public bool LandAtTarget { get; set; } + private readonly string m_firstname; private readonly string m_lastname; private readonly Vector3 m_startPos; diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index d0b5a94..f38af46 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -75,19 +75,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC // We are close enough to the target m_log.DebugFormat("[NPC MODULE]: Stopping movement of npc {0}", presence.Name); + presence.Velocity = Vector3.Zero; + presence.AbsolutePosition = presence.MoveToPositionTarget; + presence.ResetMoveToTarget(); + if (presence.PhysicsActor.Flying) { - Vector3 targetPos = presence.MoveToPositionTarget; - float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; - if (targetPos.Z - terrainHeight < 0.2) - { + for (int i = 0; i < 5; i++) + presence.PhysicsActor.IsColliding = true; + +// Vector3 targetPos = presence.MoveToPositionTarget; + if (m_avatars[presence.UUID].LandAtTarget) presence.PhysicsActor.Flying = false; - } - } - presence.Velocity = Vector3.Zero; - presence.AbsolutePosition = presence.MoveToPositionTarget; - presence.ResetMoveToTarget(); +// float terrainHeight = (float)presence.Scene.Heightmap[(int)targetPos.X, (int)targetPos.Y]; +// if (targetPos.Z - terrainHeight < 0.2) +// { +// presence.PhysicsActor.Flying = false; +// } + } // FIXME: This doesn't work if (presence.PhysicsActor.Flying) @@ -217,7 +223,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC return npcAvatar.AgentId; } - public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly) + public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) { lock (m_avatars) { @@ -227,8 +233,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC scene.TryGetScenePresence(agentID, out sp); m_log.DebugFormat( - "[NPC MODULE]: Moving {0} to {1} in {2}", sp.Name, pos, scene.RegionInfo.RegionName); + "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", + sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); + m_avatars[agentID].LandAtTarget = landAtTarget; sp.MoveToTarget(pos, noFly); return true; @@ -263,6 +271,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC { if (m_avatars.ContainsKey(agentID)) { + ScenePresence sp; + scene.TryGetScenePresence(agentID, out sp); + m_avatars[agentID].Say(text); return true; diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 81497d5..d220fab 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -113,7 +113,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); Vector3 targetPos = startPos + new Vector3(0, 0, 10); - npcModule.MoveToTarget(npc.UUID, scene, targetPos, false); + npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); @@ -135,7 +135,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // Try a second movement startPos = npc.AbsolutePosition; targetPos = startPos + new Vector3(10, 0, 0); - npcModule.MoveToTarget(npc.UUID, scene, targetPos, false); + npcModule.MoveToTarget(npc.UUID, scene, targetPos, false, false); scene.Update(); -- cgit v1.1 From 4402851b086e7faf0d441d2ae0d5f6a3e1ea04b8 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 01:56:42 +0100 Subject: Get NPCs to revert to the correct 'resting' animation (e.g. stand or hover) after finishing their movement. This also fixes judder after an avatar has finished "go here"/autopilot movement in a viewer. This meant reseting the SP.AgentControlFlags since the Animator uses these to determine the correct default animation. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 8 +++----- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 1 + 2 files changed, 4 insertions(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index f38af46..0e313df 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -95,11 +95,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC // } } - // FIXME: This doesn't work - if (presence.PhysicsActor.Flying) - presence.Animator.TrySetMovementAnimation("HOVER"); - else - presence.Animator.TrySetMovementAnimation("STAND"); +// m_log.DebugFormat( +// "[NPC MODULE]: AgentControlFlags {0}, MovementFlag {1} for {2}", +// presence.AgentControlFlags, presence.MovementFlag, presence.Name); } else { diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index d220fab..2742b67 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -131,6 +131,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos); Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move"); Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos)); + Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE)); // Try a second movement startPos = npc.AbsolutePosition; -- cgit v1.1 From 36f7d36fa1556d2b9356bc9bc5d9b16fc81eb96a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 02:54:15 +0100 Subject: instead of setting avatar rotation twice in SP.HandleAgentUpdate(), eliminate the second setting in AddNewMovement() --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 0e313df..9b86abb 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -107,7 +107,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC Vector3 agent_control_v3 = new Vector3(); presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); - presence.AddNewMovement(agent_control_v3, presence.Rotation); + presence.AddNewMovement(agent_control_v3); } // //// presence.DoMoveToPositionUpdate((0, presence.MoveToPositionTarget, null); -- cgit v1.1 From 1aa171189397f34d7d18fb358f7bd767d241675a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 03:05:51 +0100 Subject: eliminate the rotation parameter from SP.HandleMoveToTargetUpdate(). This can just use the currently set Rotation looks like I spoke to soon about eliminating jerkiness on "go here"/autopilot. It's still there. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 9b86abb..580d7ef 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -81,6 +81,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (presence.PhysicsActor.Flying) { + // A horrible hack to stop the NPC dead in its tracks rather than having them overshoot + // the target if flying. + // We really need to be more subtle (slow the avatar as it approaches the target) or at + // least be able to set collision status once, rather than 5 times to give it enough + // weighting so that that PhysicsActor thinks it really is colliding. for (int i = 0; i < 5; i++) presence.PhysicsActor.IsColliding = true; @@ -106,7 +111,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); Vector3 agent_control_v3 = new Vector3(); - presence.HandleMoveToTargetUpdate(ref agent_control_v3, presence.Rotation); + presence.HandleMoveToTargetUpdate(ref agent_control_v3); presence.AddNewMovement(agent_control_v3); } // -- cgit v1.1 From 50945dd56029a1280c581ea9b29213ab0e162a0a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 11 Aug 2011 21:43:26 +0100 Subject: add regression test for osNpcCreate when cloning an in-region avatar --- .../Region/OptionalModules/World/NPC/NPCModule.cs | 29 +++------------------- .../World/NPC/Tests/NPCModuleTests.cs | 10 ++++---- 2 files changed, 8 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 580d7ef..c764c20 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -45,7 +45,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private Dictionary m_avatars = new Dictionary(); - private Dictionary m_appearanceCache = new Dictionary(); public void Initialise(Scene scene, IConfigSource source) { @@ -124,28 +123,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC } } - private AvatarAppearance GetAppearance(UUID target, Scene scene) - { - if (m_appearanceCache.ContainsKey(target)) - return m_appearanceCache[target]; - - ScenePresence originalPresence = scene.GetScenePresence(target); - - if (originalPresence != null) - { - AvatarAppearance originalAppearance = originalPresence.Appearance; - m_appearanceCache.Add(target, originalAppearance); - return originalAppearance; - } - else - { - m_log.DebugFormat( - "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); - - return new AvatarAppearance(); - } - } - public bool IsNPC(UUID agentId, Scene scene) { ScenePresence sp = scene.GetScenePresence(agentId); @@ -176,7 +153,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC return true; } - public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) + public UUID CreateNPC( + string firstname, string lastname, Vector3 position, Scene scene, AvatarAppearance appearance) { NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, scene); npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); @@ -191,8 +169,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC acd.lastname = lastname; acd.ServiceURLs = new Dictionary(); - AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); - AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); acd.Appearance = npcAppearance; // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index 2742b67..f8afc5a 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests AvatarFactoryModule afm = new AvatarFactoryModule(); TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); - IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); // 8 is the index of the first baked texture in AvatarAppearance @@ -72,10 +72,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests // ScenePresence.SendInitialData() to reset our entire appearance. scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); - afm.SetAppearanceFromClient(originalClient, originalTe, null); + afm.SetAppearanceFromClient(sp.ControllingClient, originalTe, null); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); + UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); @@ -96,12 +96,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests TestScene scene = SceneHelpers.SetupScene(); SceneHelpers.SetupSceneModules(scene, config, new NPCModule()); - IClientAPI originalClient = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)).ControllingClient; + ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); Vector3 startPos = new Vector3(128, 128, 30); INPCModule npcModule = scene.RequestModuleInterface(); - UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, originalClient.AgentId); + UUID npcId = npcModule.CreateNPC("John", "Smith", startPos, scene, sp.Appearance); ScenePresence npc = scene.GetScenePresence(npcId); Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); -- cgit v1.1 From 65c4b8d37b304c4b6c09c0c4b07184c4a7ffda7d Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 00:51:05 +0100 Subject: Fix kicking of NPCs via "kick user" console command. Needed to hook up the Close() function in the NPCAvatar IClientAPI implementation, which [unfortunately] is still needed --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index d63c2a6..4441579 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -842,6 +842,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void Close() { + // Remove ourselves from the scene + m_scene.RemoveClient(AgentId, false); } public void Start() -- cgit v1.1 From 2169cf04f92a6465fe9cd58a2bac0d1380a561bd Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 01:24:15 +0100 Subject: When saving appearance, only save the baked textures, not the other face textures (which are already stored permanently) --- OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 4441579..31e79fa 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs @@ -843,7 +843,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC public void Close() { // Remove ourselves from the scene - m_scene.RemoveClient(AgentId, false); + m_scene.RemoveClient(AgentId, false); } public void Start() -- cgit v1.1 From 4b88f04c0afd36f9e88680bbafb7ccc4680fd504 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 12 Aug 2011 22:46:42 +0100 Subject: minor: On "login disable/enable" always tell the user the final login status, rather than remaining silent if it was already on/off --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c764c20..11fda6d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -105,9 +105,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC } else { - m_log.DebugFormat( - "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", - presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); +// m_log.DebugFormat( +// "[NPC MODULE]: Updating npc {0} at {1} for next movement to {2}", +// presence.Name, presence.AbsolutePosition, presence.MoveToPositionTarget); Vector3 agent_control_v3 = new Vector3(); presence.HandleMoveToTargetUpdate(ref agent_control_v3); -- cgit v1.1 From acfdca34fd9bf6d66d144ae5c0a325dd5e864517 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 17 Aug 2011 01:35:33 +0100 Subject: Fix issue where loading a new appearance onto an NPC would not remove the previous attachments from the scene. Addresses http://opensimulator.org/mantis/view.php?id=5636 --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 11fda6d..3b7ae9d 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -143,6 +143,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (!m_avatars.ContainsKey(agentId)) return false; + // FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it + List attachments = sp.Attachments; + lock (attachments) + { + foreach (SceneObjectGroup att in attachments) + scene.DeleteSceneObject(att, false); + + attachments.Clear(); + } + AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; sp.RezAttachments(); -- cgit v1.1 From c1a34cd8da293e63d3cba70b5271c9a297789db2 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 18 Aug 2011 00:53:05 +0100 Subject: Don't try to save changed attachment states when an NPC with attachments is removed from the scene. This is done by introducing a PresenceType enum into ScenePresence which currently has two values, User and Npc. This seems better than a SaveAttachments flag in terms of code comprehension, though I'm still slightly uneasy about introducing these semantics to core objects --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 3b7ae9d..c1da803 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -190,7 +190,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC // } scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); - scene.AddNewClient(npcAvatar); + scene.AddNewClient(npcAvatar, PresenceType.Npc); ScenePresence sp; if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) -- cgit v1.1 From c9e6b7bd10b2cdaa917e41259ae0d612f2171f7a Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 19 Aug 2011 00:45:22 +0100 Subject: Stop NPC's getting hypergrid like names in some circumstances. This meant punching in another AddUser() method in IUserManagement to do a direct name to UUID associated without the account check (since NPCs don't have accounts). May address http://opensimulator.org/mantis/view.php?id=5645 --- OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index f8afc5a..78296a4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs @@ -34,6 +34,7 @@ using OpenMetaverse; using OpenSim.Framework; using OpenSim.Framework.Communications; using OpenSim.Region.CoreModules.Avatar.AvatarFactory; +using OpenSim.Region.CoreModules.Framework.UserManagement; using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -57,8 +58,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests config.Configs["NPC"].Set("Enabled", "true"); AvatarFactoryModule afm = new AvatarFactoryModule(); + UserManagementModule umm = new UserManagementModule(); + TestScene scene = SceneHelpers.SetupScene(); - SceneHelpers.SetupSceneModules(scene, config, afm, new NPCModule()); + SceneHelpers.SetupSceneModules(scene, config, afm, umm, new NPCModule()); ScenePresence sp = SceneHelpers.AddScenePresence(scene, TestHelpers.ParseTail(0x1)); // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); @@ -81,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); + Assert.That(umm.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); } [Test] -- cgit v1.1 From 04bafd21221a789b83b039efd1c52e141944cde0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 30 Aug 2011 23:05:43 +0100 Subject: refactor: Move ScenePresence.RezAttachments() into AttachmentsModule This adds an incomplete IScenePresence to match ISceneEntity --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index c1da803..79c79e4 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -155,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; - sp.RezAttachments(); + scene.AttachmentsModule.RezAttachments(sp); IAvatarFactory module = scene.RequestModuleInterface(); module.SendAppearance(sp.UUID); -- cgit v1.1 From 32444d98cb13423fdf8c874e4fbb7ea17670d7c5 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 16:29:51 +0100 Subject: Make SP.Attachments available as sp.GetAttachments() instead. The approach here, as in other parts of OpenSim, is to return a copy of the list rather than the attachments list itself This prevents callers from forgetting to lock the list when they read it, as was happening in various parts of the codebase. It also improves liveness. This might improve attachment anomolies when performing region crossings. --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index 79c79e4..e58dca2 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -144,14 +144,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC return false; // FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it - List attachments = sp.Attachments; - lock (attachments) - { - foreach (SceneObjectGroup att in attachments) - scene.DeleteSceneObject(att, false); + foreach (SceneObjectGroup att in sp.GetAttachments()) + scene.DeleteSceneObject(att, false); - attachments.Clear(); - } + sp.ClearAttachments(); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; -- cgit v1.1 From 7d58b5fa157b4c3e842573d9fb02a9822034f4b0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Wed, 31 Aug 2011 17:53:58 +0100 Subject: move common code into AttachmentsModule.DeleteAttachmentsFromScene() --- OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/NPC') diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index e58dca2..2fdeeab 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs @@ -143,11 +143,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC if (!m_avatars.ContainsKey(agentId)) return false; - // FIXME: An extremely bad bit of code that reaches directly into the attachments list and manipulates it - foreach (SceneObjectGroup att in sp.GetAttachments()) - scene.DeleteSceneObject(att, false); - - sp.ClearAttachments(); + scene.AttachmentsModule.DeleteAttachmentsFromScene(sp, false); AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); sp.Appearance = npcAppearance; -- cgit v1.1