diff --git a/OpenSim/Framework/AvatarAppearance.cs b/OpenSim/Framework/AvatarAppearance.cs
index 716baab300..6b1f58a033 100644
--- a/OpenSim/Framework/AvatarAppearance.cs
+++ b/OpenSim/Framework/AvatarAppearance.cs
@@ -77,7 +77,11 @@ namespace OpenSim.Framework
public virtual Primitive.TextureEntry Texture
{
get { return m_texture; }
- set { m_texture = value; }
+ set
+ {
+// m_log.DebugFormat("[AVATAR APPEARANCE]: Set TextureEntry to {0}", value);
+ m_texture = value;
+ }
}
public virtual AvatarWearable[] Wearables
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 20dff0c6f5..e3e34523a8 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
if (face == null)
continue;
+// m_log.DebugFormat(
+// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
+// face.TextureID, idx, client.Name, client.AgentId);
+
// if the texture is one of the "defaults" then skip it
// this should probably be more intelligent (skirt texture doesnt matter
// 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 83b761c7a2..1e121d92f5 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -2647,7 +2647,8 @@ namespace OpenSim.Region.Framework.Scenes
///
public void SendAppearanceToAgent(ScenePresence avatar)
{
-// m_log.WarnFormat("[SP] Send appearance from {0} to {1}",m_uuid,avatar.ControllingClient.AgentId);
+// m_log.DebugFormat(
+// "[SCENE PRESENCE] Send appearance from {0} {1} to {2} {3}", Name, m_uuid, avatar.Name, avatar.UUID);
avatar.ControllingClient.SendAppearance(
m_appearance.Owner, m_appearance.VisualParams, m_appearance.Texture.GetBytes());
@@ -2659,7 +2660,11 @@ namespace OpenSim.Region.Framework.Scenes
public AvatarAppearance Appearance
{
get { return m_appearance; }
- set { m_appearance = value; }
+ set
+ {
+ m_appearance = value;
+// m_log.DebugFormat("[SCENE PRESENCE]: Set appearance for {0} to {1}", Name, value);
+ }
}
#endregion
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3cdd06d52c..64f82c9431 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)
- {
- m_appearanceCache.Add(target, appearance);
- return appearance;
- }
+ ScenePresence originalPresence = scene.GetScenePresence(target);
- return new AvatarAppearance();
+ 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 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 899e721767..bc151ed43d 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
diff --git a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
index 9b68331038..99eb12410b 100644
--- a/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
+++ b/OpenSim/Tests/Common/Helpers/AssetHelpers.cs
@@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common
///
public static AssetBase CreateAsset()
{
- return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", UUID.Random());
+ return CreateAsset(UUID.Random());
}
///
@@ -50,9 +50,9 @@ namespace OpenSim.Tests.Common
///
/// /param>
///
- public static AssetBase CreateAsset(UUID creatorId)
+ public static AssetBase CreateAsset(UUID id)
{
- return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", creatorId);
+ return CreateAsset(id, AssetType.Notecard, "hello", UUID.Random());
}
///
diff --git a/bin/OpenSim.Region.OptionalModules.Tests.dll.config b/bin/OpenSim.Region.OptionalModules.Tests.dll.config
new file mode 100644
index 0000000000..a3f681d89e
--- /dev/null
+++ b/bin/OpenSim.Region.OptionalModules.Tests.dll.config
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+