diff options
author | Justin Clark-Casey (justincc) | 2011-08-01 23:41:29 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-08-01 23:41:29 +0100 |
commit | 59f548cda82facef003fb7309180412254a234a1 (patch) | |
tree | ee736eca64d23b35dbd3aa0e18f1b2311804ff43 /OpenSim/Region/OptionalModules | |
parent | Move common gemo/agent map name code into CreateGeom() (diff) | |
download | opensim-SC_OLD-59f548cda82facef003fb7309180412254a234a1.zip opensim-SC_OLD-59f548cda82facef003fb7309180412254a234a1.tar.gz opensim-SC_OLD-59f548cda82facef003fb7309180412254a234a1.tar.bz2 opensim-SC_OLD-59f548cda82facef003fb7309180412254a234a1.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | 25 | ||||
-rw-r--r-- | OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | 23 |
2 files changed, 41 insertions, 7 deletions
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 | |||
59 | if (m_appearanceCache.ContainsKey(target)) | 59 | if (m_appearanceCache.ContainsKey(target)) |
60 | return m_appearanceCache[target]; | 60 | return m_appearanceCache[target]; |
61 | 61 | ||
62 | AvatarAppearance appearance = scene.AvatarService.GetAppearance(target); | 62 | ScenePresence originalPresence = scene.GetScenePresence(target); |
63 | if (appearance != null) | 63 | |
64 | if (originalPresence != null) | ||
64 | { | 65 | { |
65 | m_appearanceCache.Add(target, appearance); | 66 | AvatarAppearance originalAppearance = originalPresence.Appearance; |
66 | return appearance; | 67 | m_appearanceCache.Add(target, originalAppearance); |
68 | return originalAppearance; | ||
67 | } | 69 | } |
70 | else | ||
71 | { | ||
72 | m_log.DebugFormat( | ||
73 | "[NPC MODULE]: Avatar {0} is not in the scene for us to grab baked textures from them. Using defaults.", target); | ||
68 | 74 | ||
69 | return new AvatarAppearance(); | 75 | return new AvatarAppearance(); |
76 | } | ||
70 | } | 77 | } |
71 | 78 | ||
72 | public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) | 79 | public UUID CreateNPC(string firstname, string lastname, Vector3 position, Scene scene, UUID cloneAppearanceFrom) |
@@ -86,8 +93,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
86 | 93 | ||
87 | AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); | 94 | AvatarAppearance originalAppearance = GetAppearance(cloneAppearanceFrom, scene); |
88 | AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); | 95 | AvatarAppearance npcAppearance = new AvatarAppearance(originalAppearance, true); |
96 | npcAppearance.Owner = acd.AgentID; | ||
89 | acd.Appearance = npcAppearance; | 97 | acd.Appearance = npcAppearance; |
90 | 98 | ||
99 | // for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) | ||
100 | // { | ||
101 | // m_log.DebugFormat( | ||
102 | // "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", | ||
103 | // acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); | ||
104 | // } | ||
105 | |||
91 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); | 106 | scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); |
92 | scene.AddNewClient(npcAvatar); | 107 | scene.AddNewClient(npcAvatar); |
93 | 108 | ||
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 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Reflection; | 29 | using System.Reflection; |
30 | using log4net; | ||
30 | using Nini.Config; | 31 | using Nini.Config; |
31 | using NUnit.Framework; | 32 | using NUnit.Framework; |
32 | using OpenMetaverse; | 33 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.CoreModules.Avatar.AvatarFactory; | ||
35 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar; |
36 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.Framework.Scenes; | 39 | using OpenSim.Region.Framework.Scenes; |
@@ -58,14 +60,31 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
58 | config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); | 60 | config.Configs["AvatarService"].Set("LocalServiceModule", "OpenSim.Services.AvatarService.dll:AvatarService"); |
59 | config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); | 61 | config.Configs["AvatarService"].Set("StorageProvider", "OpenSim.Data.Null.dll"); |
60 | 62 | ||
63 | AvatarFactoryModule afm = new AvatarFactoryModule(); | ||
61 | TestScene scene = SceneSetupHelpers.SetupScene(); | 64 | TestScene scene = SceneSetupHelpers.SetupScene(); |
62 | SceneSetupHelpers.SetupSceneModules(scene, config, new NPCModule(), new LocalAvatarServicesConnector()); | 65 | SceneSetupHelpers.SetupSceneModules(scene, config, afm, new NPCModule(), new LocalAvatarServicesConnector()); |
66 | TestClient originalClient = SceneSetupHelpers.AddClient(scene, TestHelper.ParseTail(0x1)); | ||
67 | // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId); | ||
68 | |||
69 | // 8 is the index of the first baked texture in AvatarAppearance | ||
70 | UUID originalFace8TextureId = TestHelper.ParseTail(0x10); | ||
71 | Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero); | ||
72 | Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8); | ||
73 | originalTef.TextureID = originalFace8TextureId; | ||
74 | |||
75 | // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell | ||
76 | // ScenePresence.SendInitialData() to reset our entire appearance. | ||
77 | scene.AssetService.Store(AssetHelpers.CreateAsset(originalFace8TextureId)); | ||
78 | |||
79 | afm.SetAppearance(originalClient, originalTe, null); | ||
63 | 80 | ||
64 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); | 81 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
65 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, UUID.Zero); | 82 | UUID npcId = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, originalClient.AgentId); |
66 | 83 | ||
67 | ScenePresence npc = scene.GetScenePresence(npcId); | 84 | ScenePresence npc = scene.GetScenePresence(npcId); |
85 | |||
68 | Assert.That(npc, Is.Not.Null); | 86 | Assert.That(npc, Is.Not.Null); |
87 | Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); | ||
69 | } | 88 | } |
70 | } | 89 | } |
71 | } \ No newline at end of file | 90 | } \ No newline at end of file |