From 33aaa40bee37ca4d8a3afa10fbbea7c1be3a1d58 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Wed, 8 May 2013 13:13:51 -0700 Subject: Adds an event and a method so that handling of the CachedTexture packet can be pulled out of LLClientView and moved to AvatarFactory. The first pass at reusing textures (turned off by default) is included. When reusing textures, if the baked textures from a previous login are still in the asset service (which generally means that they are in the simulator's cache) then the avatar will not need to rebake. This is both a performance improvement (specifically that an avatars baked textures do not need to be sent to other users who have the old textures cached) and a resource improvement (don't have to deal with duplicate bakes in the asset service cache). --- .../Region/ClientStack/Linden/UDP/LLClientView.cs | 58 ++++++++++++++++------ 1 file changed, 43 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/ClientStack/Linden') diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index bede379..47dd842 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs @@ -84,6 +84,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event ModifyTerrain OnModifyTerrain; public event Action OnRegionHandShakeReply; public event GenericCall1 OnRequestWearables; + public event CachedTextureRequest OnCachedTextureRequest; public event SetAppearance OnSetAppearance; public event AvatarNowWearing OnAvatarNowWearing; public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; @@ -321,7 +322,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP private readonly byte[] m_channelVersion = Utils.EmptyBytes; private readonly IGroupsModule m_GroupsModule; - private int m_cachedTextureSerial; private PriorityQueue m_entityUpdates; private PriorityQueue m_entityProps; private Prioritizer m_prioritizer; @@ -11462,8 +11462,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP } /// - /// Send a response back to a client when it asks the asset server (via the region server) if it has - /// its appearance texture cached. /// /// /// At the moment, we always reply that there is no cached texture. @@ -11473,33 +11471,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP /// protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet) { - //m_log.Debug("texture cached: " + packet.ToString()); AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; - AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); if (cachedtex.AgentData.SessionID != SessionId) return false; + List requestArgs = new List(); + + for (int i = 0; i < cachedtex.WearableData.Length; i++) + { + CachedTextureRequestArg arg = new CachedTextureRequestArg(); + arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex; + arg.WearableHashID = cachedtex.WearableData[i].ID; + + requestArgs.Add(arg); + } + + CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest; + if (handlerCachedTextureRequest != null) + { + handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs); + } + + return true; + } + + /// + /// Send a response back to a client when it asks the asset server (via the region server) if it has + /// its appearance texture cached. + /// + /// + /// + /// + /// + public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List cachedTextures) + { + ScenePresence presence = avatar as ScenePresence; + if (presence == null) + return; + + AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); + // TODO: don't create new blocks if recycling an old packet - cachedresp.AgentData.AgentID = AgentId; + cachedresp.AgentData.AgentID = m_agentId; cachedresp.AgentData.SessionID = m_sessionId; - cachedresp.AgentData.SerialNum = m_cachedTextureSerial; - m_cachedTextureSerial++; - cachedresp.WearableData = - new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; + cachedresp.AgentData.SerialNum = serial; + cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count]; - for (int i = 0; i < cachedtex.WearableData.Length; i++) + for (int i = 0; i < cachedTextures.Count; i++) { cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); - cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; - cachedresp.WearableData[i].TextureID = UUID.Zero; + cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex; + cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID; cachedresp.WearableData[i].HostName = new byte[0]; } cachedresp.Header.Zerocoded = true; OutPacket(cachedresp, ThrottleOutPacketType.Task); - - return true; } protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) -- cgit v1.1