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 | |
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')
6 files changed, 60 insertions, 13 deletions
diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs index 716baab..6b1f58a 100644 --- a/OpenSim/Framework/AvatarAppearance.cs +++ b/OpenSim/Framework/AvatarAppearance.cs | |||
@@ -77,7 +77,11 @@ namespace OpenSim.Framework | |||
77 | public virtual Primitive.TextureEntry Texture | 77 | public virtual Primitive.TextureEntry Texture |
78 | { | 78 | { |
79 | get { return m_texture; } | 79 | get { return m_texture; } |
80 | set { m_texture = value; } | 80 | set |
81 | { | ||
82 | // m_log.DebugFormat("[AVATAR APPEARANCE]: Set TextureEntry to {0}", value); | ||
83 | m_texture = value; | ||
84 | } | ||
81 | } | 85 | } |
82 | 86 | ||
83 | public virtual AvatarWearable[] Wearables | 87 | public virtual AvatarWearable[] Wearables |
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs index 20dff0c..e3e3452 100644 --- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs | |||
@@ -151,6 +151,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory | |||
151 | if (face == null) | 151 | if (face == null) |
152 | continue; | 152 | continue; |
153 | 153 | ||
154 | // m_log.DebugFormat( | ||
155 | // "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}", | ||
156 | // face.TextureID, idx, client.Name, client.AgentId); | ||
157 | |||
154 | // if the texture is one of the "defaults" then skip it | 158 | // if the texture is one of the "defaults" then skip it |
155 | // this should probably be more intelligent (skirt texture doesnt matter | 159 | // this should probably be more intelligent (skirt texture doesnt matter |
156 | // if the avatar isnt wearing a skirt) but if any of the main baked | 160 | // if the avatar isnt wearing a skirt) but if any of the main baked |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 83b761c..1e121d9 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -2647,7 +2647,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2647 | /// <param name="avatar"></param> | 2647 | /// <param name="avatar"></param> |
2648 | public void SendAppearanceToAgent(ScenePresence avatar) | 2648 | public void SendAppearanceToAgent(ScenePresence avatar) |
2649 | { | 2649 | { |
2650 | // m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId); | 2650 | // m_log.DebugFormat( |
2651 | // "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID); | ||
2651 | 2652 | ||
2652 | avatar.ControllingClient.SendAppearance( | 2653 | avatar.ControllingClient.SendAppearance( |
2653 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); | 2654 | m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes()); |
@@ -2659,7 +2660,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2659 | public AvatarAppearance Appearance | 2660 | public AvatarAppearance Appearance |
2660 | { | 2661 | { |
2661 | get { return m_appearance; } | 2662 | get { return m_appearance; } |
2662 | set { m_appearance = value; } | 2663 | set |
2664 | { | ||
2665 | m_appearance = value; | ||
2666 | // m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value); | ||
2667 | } | ||
2663 | } | 2668 | } |
2664 | 2669 | ||
2665 | #endregion | 2670 | #endregion |
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 |
diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs index 9b68331..99eb124 100644 --- a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs +++ b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs | |||
@@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common | |||
42 | /// <returns></returns> | 42 | /// <returns></returns> |
43 | public static AssetBase CreateAsset() | 43 | public static AssetBase CreateAsset() |
44 | { | 44 | { |
45 | return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", UUID.Random()); | 45 | return CreateAsset(UUID.Random()); |
46 | } | 46 | } |
47 | 47 | ||
48 | /// <summary> | 48 | /// <summary> |
@@ -50,9 +50,9 @@ namespace OpenSim.Tests.Common | |||
50 | /// </summary> | 50 | /// </summary> |
51 | /// <param name="creatorId">/param> | 51 | /// <param name="creatorId">/param> |
52 | /// <returns></returns> | 52 | /// <returns></returns> |
53 | public static AssetBase CreateAsset(UUID creatorId) | 53 | public static AssetBase CreateAsset(UUID id) |
54 | { | 54 | { |
55 | return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId); | 55 | return CreateAsset(id, AssetType.Notecard, "hello", UUID.Random()); |
56 | } | 56 | } |
57 | 57 | ||
58 | /// <summary> | 58 | /// <summary> |