* Partial Commit for Avatar Appearance to include the functionality of Cached Bakes.

avinationmerge
teravus 2012-12-21 19:12:30 -05:00
parent f9051c22d8
commit 77cc7ce399
12 changed files with 120 additions and 34 deletions

View File

@ -117,7 +117,7 @@ namespace OpenSim.Capabilities.Handlers
/// <param name="data"></param>
private void BakedTextureUploaded(UUID assetID, byte[] data)
{
// m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString());
m_log.DebugFormat("[UPLOAD BAKED TEXTURE HANDLER]: Received baked texture {0}", assetID.ToString());
AssetBase asset;
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());

View File

@ -66,7 +66,7 @@ namespace OpenSim.Framework
protected Vector3 m_avatarBoxSize = new Vector3(0.45f, 0.6f, 1.9f);
protected float m_avatarFeetOffset = 0;
protected float m_avatarAnimOffset = 0;
protected WearableCacheItem[] cacheitems;
public virtual int Serial
{
get { return m_serial; }
@ -116,6 +116,12 @@ namespace OpenSim.Framework
set { m_avatarHeight = value; }
}
public virtual WearableCacheItem[] WearableCacheItems
{
get { return cacheitems; }
set { cacheitems = value; }
}
public AvatarAppearance()
{
// m_log.WarnFormat("[AVATAR APPEARANCE]: create empty appearance");

View File

@ -64,7 +64,7 @@ namespace OpenSim.Framework
public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize);
public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems);
public delegate void StartAnim(IClientAPI remoteClient, UUID animID);

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using OpenMetaverse;
namespace OpenSim.Framework
{
public class WearableCacheItem
{
public uint TextureIndex { get; set; }
public UUID CacheId { get; set; }
public UUID TextureID { get; set; }
}
}

View File

@ -6298,12 +6298,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
byte[] visualparams = new byte[appear.VisualParam.Length];
for (int i = 0; i < appear.VisualParam.Length; i++)
visualparams[i] = appear.VisualParam[i].ParamValue;
//var b = appear.WearableData[0];
Primitive.TextureEntry te = null;
if (appear.ObjectData.TextureEntry.Length > 1)
te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
handlerSetAppearance(sender, te, visualparams,avSize);
WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
for (int i=0; i<appear.WearableData.Length;i++)
cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)};
handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
}
catch (Exception e)
{
@ -11705,6 +11712,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (cachedtex.AgentData.SessionID != SessionId)
return false;
// TODO: don't create new blocks if recycling an old packet
cachedresp.AgentData.AgentID = AgentId;
cachedresp.AgentData.SessionID = m_sessionId;
@ -11713,6 +11721,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
cachedresp.WearableData =
new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
//IAvatarFactoryModule fac = m_scene.RequestModuleInterface<IAvatarFactoryModule>();
// var item = fac.GetBakedTextureFaces(AgentId);
//WearableCacheItem[] items = fac.GetCachedItems(AgentId);
IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
if (cache == null)
{
@ -11720,7 +11732,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i].TextureID = UUID.Zero;
cachedresp.WearableData[i].TextureID = UUID.Zero; //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].HostName = new byte[0];
}
}
@ -11730,10 +11742,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
{
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
if(cache.Check(cachedtex.WearableData[i].ID.ToString()))
if (cache.Check(cachedtex.WearableData[i].ID.ToString()))
cachedresp.WearableData[i].TextureID = UUID.Zero;
//UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
else
cachedresp.WearableData[i].TextureID = UUID.Zero;
cachedresp.WearableData[i].TextureID = UUID.Zero; // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].HostName = new byte[0];
}
}

View File

@ -140,18 +140,18 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="sp"></param>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
public void SetAppearance(IScenePresence sp, AvatarAppearance appearance)
public void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems)
{
SetAppearance(sp, appearance.Texture, appearance.VisualParams);
SetAppearance(sp, appearance.Texture, appearance.VisualParams, cacheItems);
}
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize)
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
{
float oldoff = sp.Appearance.AvatarFeetOffset;
Vector3 oldbox = sp.Appearance.AvatarBoxSize;
SetAppearance(sp, textureEntry, visualParams);
SetAppearance(sp, textureEntry, visualParams, cacheItems);
sp.Appearance.SetSize(avSize);
float off = sp.Appearance.AvatarFeetOffset;
@ -166,7 +166,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="sp"></param>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams)
public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems)
{
// m_log.DebugFormat(
// "[AVFACTORY]: start SetAppearance for {0}, te {1}, visualParams {2}",
@ -205,11 +205,14 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// ((ScenePresence)sp).SetSize(box,off);
}
//if (cacheItems.Length > 0)
//{
sp.Appearance.WearableCacheItems = cacheItems;
//}
// Process the baked texture array
if (textureEntry != null)
{
// m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID);
m_log.DebugFormat("[AVFACTORY]: Received texture update for {0} {1}", sp.Name, sp.UUID);
// WriteBakedTexturesReport(sp, m_log.DebugFormat);
@ -278,6 +281,19 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return GetBakedTextureFaces(sp);
}
public WearableCacheItem[] GetCachedItems(UUID agentId)
{
ScenePresence sp = m_scene.GetScenePresence(agentId);
Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = GetBakedTextureFaces(sp);
WearableCacheItem[] items = sp.Appearance.WearableCacheItems;
//foreach (WearableCacheItem item in items)
//{
//}
return items;
}
public bool SaveBakedTextures(UUID agentId)
{
ScenePresence sp = m_scene.GetScenePresence(agentId);
@ -660,12 +676,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
/// <param name="client"></param>
/// <param name="texture"></param>
/// <param name="visualParam"></param>
private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize)
private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
{
// m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId);
ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
if (sp != null)
SetAppearance(sp, textureEntry, visualParams,avSize);
SetAppearance(sp, textureEntry, visualParams,avSize, cacheItems);
else
m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId);
}

View File

@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
for (byte i = 0; i < visualParams.Length; i++)
visualParams[i] = i;
afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams);
afm.SetAppearance(sp, new Primitive.TextureEntry(TestHelpers.ParseTail(0x10)), visualParams, new WearableCacheItem[0]);
// TODO: Check baked texture
Assert.AreEqual(visualParams, sp.Appearance.VisualParams);
@ -102,7 +102,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
Primitive.TextureEntryFace eyesFace = bakedTextureEntry.CreateFace(eyesFaceIndex);
eyesFace.TextureID = eyesTextureId;
afm.SetAppearance(sp, bakedTextureEntry, visualParams);
afm.SetAppearance(sp, bakedTextureEntry, visualParams, new WearableCacheItem[0]);
afm.SaveBakedTextures(userId);
// Dictionary<BakeType, Primitive.TextureEntryFace> bakedTextures = afm.GetBakedTextureFaces(userId);

View File

@ -35,8 +35,8 @@ namespace OpenSim.Region.Framework.Interfaces
public interface IAvatarFactoryModule
{
void SetAppearance(IScenePresence sp, AvatarAppearance appearance);
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams);
void SetAppearance(IScenePresence sp, AvatarAppearance appearance, WearableCacheItem[] cacheItems);
void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, WearableCacheItem[] cacheItems);
/// <summary>
/// Send the appearance of an avatar to others in the scene.
@ -52,6 +52,8 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>An empty list if this agent has no baked textures (e.g. because it's a child agent)</returns>
Dictionary<BakeType, Primitive.TextureEntryFace> GetBakedTextureFaces(UUID agentId);
WearableCacheItem[] GetCachedItems(UUID agentId);
/// <summary>
/// Save the baked textures for the given agent permanently in the asset database.
/// </summary>

View File

@ -931,18 +931,25 @@ namespace OpenSim.Region.Framework.Scenes
// ----------------------------------
// Previous Agent Difference - AGNI sends an unsolicited AgentDataUpdate upon root agent status
if (gm != null)
try
{
groupUUID = ControllingClient.ActiveGroupId;
GroupRecord record = gm.GetGroupRecord(groupUUID);
if (record != null)
GroupName = record.GroupName;
GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid);
if (groupMembershipData != null)
groupPowers = groupMembershipData.GroupPowers;
if (gm != null)
{
groupUUID = ControllingClient.ActiveGroupId;
GroupRecord record = gm.GetGroupRecord(groupUUID);
if (record != null)
GroupName = record.GroupName;
GroupMembershipData groupMembershipData = gm.GetMembershipData(groupUUID, m_uuid);
if (groupMembershipData != null)
groupPowers = groupMembershipData.GroupPowers;
}
ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName,
Grouptitle);
}
catch (Exception e)
{
m_log.Debug("[AGENTUPDATE]: " + e.ToString());
}
ControllingClient.SendAgentDataUpdate(m_uuid, groupUUID, Firstname, Lastname, groupPowers, GroupName,
Grouptitle);
// ------------------------------------
if (ParentID == 0)

View File

@ -911,7 +911,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
// Mimicking LLClientView which gets always set appearance from client.
AvatarAppearance appearance;
m_scene.GetAvatarAppearance(this, out appearance);
OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize);
OnSetAppearance(this, appearance.Texture, (byte[])appearance.VisualParams.Clone(),appearance.AvatarSize, new WearableCacheItem[0]);
}
public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)

View File

@ -108,7 +108,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
// ScenePresence.SendInitialData() to reset our entire appearance.
m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
m_afMod.SetAppearance(sp, originalTe, null);
m_afMod.SetAppearance(sp, originalTe, null, new WearableCacheItem[0] );
UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);

View File

@ -144,7 +144,7 @@ namespace OpenSim.Tests.Performance
// ScenePresence.SendInitialData() to reset our entire appearance.
scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
afm.SetAppearance(sp, originalTe, null);
afm.SetAppearance(sp, originalTe, null, new WearableCacheItem[0]);
INPCModule npcModule = scene.RequestModuleInterface<INPCModule>();