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.
bulletsim
Justin Clark-Casey (justincc) 2011-08-01 23:41:29 +01:00
parent 05e94ff27e
commit 59f548cda8
7 changed files with 95 additions and 15 deletions

View File

@ -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

View File

@ -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

View File

@ -2647,7 +2647,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="avatar"></param>
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

View File

@ -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);

View File

@ -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<INPCModule>();
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));
}
}
}

View File

@ -42,7 +42,7 @@ namespace OpenSim.Tests.Common
/// <returns></returns>
public static AssetBase CreateAsset()
{
return CreateAsset(UUID.Random(), AssetType.Notecard, "hello", UUID.Random());
return CreateAsset(UUID.Random());
}
/// <summary>
@ -50,9 +50,9 @@ namespace OpenSim.Tests.Common
/// </summary>
/// <param name="creatorId">/param>
/// <returns></returns>
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());
}
/// <summary>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
</configSections>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" />
<bindingRedirect oldVersion="2.0.6.0" newVersion="2.4.6.0" />
<bindingRedirect oldVersion="2.1.4.0" newVersion="2.4.6.0" />
<bindingRedirect oldVersion="2.2.8.0" newVersion="2.4.6.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<log4net>
<!-- A1 is set to be a ConsoleAppender -->
<appender name="A1" type="log4net.Appender.ConsoleAppender">
<!-- A1 uses PatternLayout -->
<layout type="log4net.Layout.PatternLayout">
<!-- Print the date in ISO 8601 format -->
<conversionPattern value="%date [%thread] %-5level %logger %ndc - %message%newline" />
</layout>
</appender>
<!-- Set root logger level to DEBUG and its only appender to A1 -->
<root>
<level value="DEBUG" />
<appender-ref ref="A1" />
</root>
</log4net>
</configuration>