aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/CachedTextureEventArg.cs46
-rw-r--r--OpenSim/Framework/IClientAPI.cs5
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs58
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs59
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs6
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs6
-rw-r--r--OpenSim/Tests/Common/Mock/TestClient.cs6
7 files changed, 171 insertions, 15 deletions
diff --git a/OpenSim/Framework/CachedTextureEventArg.cs b/OpenSim/Framework/CachedTextureEventArg.cs
new file mode 100644
index 0000000..239fc56
--- /dev/null
+++ b/OpenSim/Framework/CachedTextureEventArg.cs
@@ -0,0 +1,46 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSimulator Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;
29using System.Text;
30using OpenMetaverse;
31
32namespace OpenSim.Framework
33{
34 public class CachedTextureRequestArg
35 {
36 public int BakedTextureIndex;
37 public UUID WearableHashID;
38 }
39
40 public class CachedTextureResponseArg
41 {
42 public int BakedTextureIndex;
43 public UUID BakedTextureID;
44 public String HostName;
45 }
46}
diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs
index 4d5ec3a..cfb36fe 100644
--- a/OpenSim/Framework/IClientAPI.cs
+++ b/OpenSim/Framework/IClientAPI.cs
@@ -64,6 +64,8 @@ namespace OpenSim.Framework
64 64
65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes); 65 public delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes);
66 66
67 public delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List<CachedTextureRequestArg> cachedTextureRequest);
68
67 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams); 69 public delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams);
68 70
69 public delegate void StartAnim(IClientAPI remoteClient, UUID animID); 71 public delegate void StartAnim(IClientAPI remoteClient, UUID animID);
@@ -780,6 +782,7 @@ namespace OpenSim.Framework
780 event EstateChangeInfo OnEstateChangeInfo; 782 event EstateChangeInfo OnEstateChangeInfo;
781 event EstateManageTelehub OnEstateManageTelehub; 783 event EstateManageTelehub OnEstateManageTelehub;
782 // [Obsolete("LLClientView Specific.")] 784 // [Obsolete("LLClientView Specific.")]
785 event CachedTextureRequest OnCachedTextureRequest;
783 event SetAppearance OnSetAppearance; 786 event SetAppearance OnSetAppearance;
784 // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")] 787 // [Obsolete("LLClientView Specific - Replace and rename OnAvatarUpdate. Difference from SetAppearance?")]
785 event AvatarNowWearing OnAvatarNowWearing; 788 event AvatarNowWearing OnAvatarNowWearing;
@@ -1087,6 +1090,8 @@ namespace OpenSim.Framework
1087 /// <param name="textureEntry"></param> 1090 /// <param name="textureEntry"></param>
1088 void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry); 1091 void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry);
1089 1092
1093 void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures);
1094
1090 void SendStartPingCheck(byte seq); 1095 void SendStartPingCheck(byte seq);
1091 1096
1092 /// <summary> 1097 /// <summary>
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
84 public event ModifyTerrain OnModifyTerrain; 84 public event ModifyTerrain OnModifyTerrain;
85 public event Action<IClientAPI> OnRegionHandShakeReply; 85 public event Action<IClientAPI> OnRegionHandShakeReply;
86 public event GenericCall1 OnRequestWearables; 86 public event GenericCall1 OnRequestWearables;
87 public event CachedTextureRequest OnCachedTextureRequest;
87 public event SetAppearance OnSetAppearance; 88 public event SetAppearance OnSetAppearance;
88 public event AvatarNowWearing OnAvatarNowWearing; 89 public event AvatarNowWearing OnAvatarNowWearing;
89 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 90 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -321,7 +322,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
321 private readonly byte[] m_channelVersion = Utils.EmptyBytes; 322 private readonly byte[] m_channelVersion = Utils.EmptyBytes;
322 private readonly IGroupsModule m_GroupsModule; 323 private readonly IGroupsModule m_GroupsModule;
323 324
324 private int m_cachedTextureSerial;
325 private PriorityQueue m_entityUpdates; 325 private PriorityQueue m_entityUpdates;
326 private PriorityQueue m_entityProps; 326 private PriorityQueue m_entityProps;
327 private Prioritizer m_prioritizer; 327 private Prioritizer m_prioritizer;
@@ -11462,8 +11462,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11462 } 11462 }
11463 11463
11464 /// <summary> 11464 /// <summary>
11465 /// Send a response back to a client when it asks the asset server (via the region server) if it has
11466 /// its appearance texture cached.
11467 /// </summary> 11465 /// </summary>
11468 /// <remarks> 11466 /// <remarks>
11469 /// At the moment, we always reply that there is no cached texture. 11467 /// At the moment, we always reply that there is no cached texture.
@@ -11473,33 +11471,63 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11473 /// <returns></returns> 11471 /// <returns></returns>
11474 protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet) 11472 protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
11475 { 11473 {
11476 //m_log.Debug("texture cached: " + packet.ToString());
11477 AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; 11474 AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
11478 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
11479 11475
11480 if (cachedtex.AgentData.SessionID != SessionId) 11476 if (cachedtex.AgentData.SessionID != SessionId)
11481 return false; 11477 return false;
11482 11478
11479 List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
11480
11481 for (int i = 0; i < cachedtex.WearableData.Length; i++)
11482 {
11483 CachedTextureRequestArg arg = new CachedTextureRequestArg();
11484 arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
11485 arg.WearableHashID = cachedtex.WearableData[i].ID;
11486
11487 requestArgs.Add(arg);
11488 }
11489
11490 CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
11491 if (handlerCachedTextureRequest != null)
11492 {
11493 handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
11494 }
11495
11496 return true;
11497 }
11498
11499 /// <summary>
11500 /// Send a response back to a client when it asks the asset server (via the region server) if it has
11501 /// its appearance texture cached.
11502 /// </summary>
11503 /// <param name="avatar"></param>
11504 /// <param name="serial"></param>
11505 /// <param name="cachedTextures"></param>
11506 /// <returns></returns>
11507 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
11508 {
11509 ScenePresence presence = avatar as ScenePresence;
11510 if (presence == null)
11511 return;
11512
11513 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
11514
11483 // TODO: don't create new blocks if recycling an old packet 11515 // TODO: don't create new blocks if recycling an old packet
11484 cachedresp.AgentData.AgentID = AgentId; 11516 cachedresp.AgentData.AgentID = m_agentId;
11485 cachedresp.AgentData.SessionID = m_sessionId; 11517 cachedresp.AgentData.SessionID = m_sessionId;
11486 cachedresp.AgentData.SerialNum = m_cachedTextureSerial; 11518 cachedresp.AgentData.SerialNum = serial;
11487 m_cachedTextureSerial++; 11519 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
11488 cachedresp.WearableData =
11489 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
11490 11520
11491 for (int i = 0; i < cachedtex.WearableData.Length; i++) 11521 for (int i = 0; i < cachedTextures.Count; i++)
11492 { 11522 {
11493 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 11523 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11494 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 11524 cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
11495 cachedresp.WearableData[i].TextureID = UUID.Zero; 11525 cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
11496 cachedresp.WearableData[i].HostName = new byte[0]; 11526 cachedresp.WearableData[i].HostName = new byte[0];
11497 } 11527 }
11498 11528
11499 cachedresp.Header.Zerocoded = true; 11529 cachedresp.Header.Zerocoded = true;
11500 OutPacket(cachedresp, ThrottleOutPacketType.Task); 11530 OutPacket(cachedresp, ThrottleOutPacketType.Task);
11501
11502 return true;
11503 } 11531 }
11504 11532
11505 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) 11533 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index c7ac7c4..b640b48 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -55,6 +55,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
55 55
56 private int m_savetime = 5; // seconds to wait before saving changed appearance 56 private int m_savetime = 5; // seconds to wait before saving changed appearance
57 private int m_sendtime = 2; // seconds to wait before sending changed appearance 57 private int m_sendtime = 2; // seconds to wait before sending changed appearance
58 private bool m_reusetextures = false;
58 59
59 private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates 60 private int m_checkTime = 500; // milliseconds to wait between checks for appearance updates
60 private System.Timers.Timer m_updateTimer = new System.Timers.Timer(); 61 private System.Timers.Timer m_updateTimer = new System.Timers.Timer();
@@ -73,6 +74,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
73 { 74 {
74 m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime))); 75 m_savetime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSave",Convert.ToString(m_savetime)));
75 m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime))); 76 m_sendtime = Convert.ToInt32(appearanceConfig.GetString("DelayBeforeAppearanceSend",Convert.ToString(m_sendtime)));
77 m_reusetextures = appearanceConfig.GetBoolean("ReuseTextures",m_reusetextures);
78
76 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime); 79 // m_log.InfoFormat("[AVFACTORY] configured for {0} save and {1} send",m_savetime,m_sendtime);
77 } 80 }
78 81
@@ -131,6 +134,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
131 client.OnRequestWearables += Client_OnRequestWearables; 134 client.OnRequestWearables += Client_OnRequestWearables;
132 client.OnSetAppearance += Client_OnSetAppearance; 135 client.OnSetAppearance += Client_OnSetAppearance;
133 client.OnAvatarNowWearing += Client_OnAvatarNowWearing; 136 client.OnAvatarNowWearing += Client_OnAvatarNowWearing;
137 client.OnCachedTextureRequest += Client_OnCachedTextureRequest;
134 } 138 }
135 139
136 #endregion 140 #endregion
@@ -671,6 +675,61 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
671 QueueAppearanceSave(client.AgentId); 675 QueueAppearanceSave(client.AgentId);
672 } 676 }
673 } 677 }
678
679 /// <summary>
680 /// Respond to the cached textures request from the client
681 /// </summary>
682 /// <param name="client"></param>
683 /// <param name="serial"></param>
684 /// <param name="cachedTextureRequest"></param>
685 private void Client_OnCachedTextureRequest(IClientAPI client, int serial, List<CachedTextureRequestArg> cachedTextureRequest)
686 {
687 // m_log.WarnFormat("[AVFACTORY]: Client_OnCachedTextureRequest called for {0} ({1})", client.Name, client.AgentId);
688 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
689
690 List<CachedTextureResponseArg> cachedTextureResponse = new List<CachedTextureResponseArg>();
691 foreach (CachedTextureRequestArg request in cachedTextureRequest)
692 {
693 UUID texture = UUID.Zero;
694 int index = request.BakedTextureIndex;
695
696 if (m_reusetextures)
697 {
698 // this is the most insanely dumb way to do this... however it seems to
699 // actually work. if the appearance has been reset because wearables have
700 // changed then the texture entries are zero'd out until the bakes are
701 // uploaded. on login, if the textures exist in the cache (eg if you logged
702 // into the simulator recently, then the appearance will pull those and send
703 // them back in the packet and you won't have to rebake. if the textures aren't
704 // in the cache then the intial makeroot() call in scenepresence will zero
705 // them out.
706 //
707 // a better solution (though how much better is an open question) is to
708 // store the hashes in the appearance and compare them. Thats's coming.
709
710 Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[index];
711 if (face != null)
712 texture = face.TextureID;
713
714 // m_log.WarnFormat("[AVFACTORY]: reuse texture {0} for index {1}",texture,index);
715 }
716
717 CachedTextureResponseArg response = new CachedTextureResponseArg();
718 response.BakedTextureIndex = index;
719 response.BakedTextureID = texture;
720 response.HostName = null;
721
722 cachedTextureResponse.Add(response);
723 }
724
725 // m_log.WarnFormat("[AVFACTORY]: serial is {0}",serial);
726 // The serial number appears to be used to match requests and responses
727 // in the texture transaction. We just send back the serial number
728 // that was provided in the request. The viewer bumps this for us.
729 client.SendCachedTextureResponse(sp, serial, cachedTextureResponse);
730 }
731
732
674 #endregion 733 #endregion
675 734
676 public void WriteBakedTexturesReport(IScenePresence sp, ReportOutputAction outputAction) 735 public void WriteBakedTexturesReport(IScenePresence sp, ReportOutputAction outputAction)
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 915ebd8..3644856 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -660,6 +660,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
660 public event BakeTerrain OnBakeTerrain; 660 public event BakeTerrain OnBakeTerrain;
661 public event EstateChangeInfo OnEstateChangeInfo; 661 public event EstateChangeInfo OnEstateChangeInfo;
662 public event EstateManageTelehub OnEstateManageTelehub; 662 public event EstateManageTelehub OnEstateManageTelehub;
663 public event CachedTextureRequest OnCachedTextureRequest;
663 public event SetAppearance OnSetAppearance; 664 public event SetAppearance OnSetAppearance;
664 public event AvatarNowWearing OnAvatarNowWearing; 665 public event AvatarNowWearing OnAvatarNowWearing;
665 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 666 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -938,7 +939,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
938 { 939 {
939 940
940 } 941 }
942
943 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
944 {
941 945
946 }
947
942 public void SendStartPingCheck(byte seq) 948 public void SendStartPingCheck(byte seq)
943 { 949 {
944 950
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 0ee00e9..8aae300 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -391,6 +391,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
391 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; 391 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
392 public event EstateChangeInfo OnEstateChangeInfo; 392 public event EstateChangeInfo OnEstateChangeInfo;
393 public event EstateManageTelehub OnEstateManageTelehub; 393 public event EstateManageTelehub OnEstateManageTelehub;
394 public event CachedTextureRequest OnCachedTextureRequest;
394 public event ScriptReset OnScriptReset; 395 public event ScriptReset OnScriptReset;
395 public event GetScriptRunning OnGetScriptRunning; 396 public event GetScriptRunning OnGetScriptRunning;
396 public event SetScriptRunning OnSetScriptRunning; 397 public event SetScriptRunning OnSetScriptRunning;
@@ -569,6 +570,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
569 { 570 {
570 } 571 }
571 572
573 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
574 {
575
576 }
577
572 public virtual void Kick(string message) 578 public virtual void Kick(string message)
573 { 579 {
574 } 580 }
diff --git a/OpenSim/Tests/Common/Mock/TestClient.cs b/OpenSim/Tests/Common/Mock/TestClient.cs
index 41402a4..664ecb6 100644
--- a/OpenSim/Tests/Common/Mock/TestClient.cs
+++ b/OpenSim/Tests/Common/Mock/TestClient.cs
@@ -196,6 +196,7 @@ namespace OpenSim.Tests.Common.Mock
196 public event EstateCovenantRequest OnEstateCovenantRequest; 196 public event EstateCovenantRequest OnEstateCovenantRequest;
197 public event EstateChangeInfo OnEstateChangeInfo; 197 public event EstateChangeInfo OnEstateChangeInfo;
198 public event EstateManageTelehub OnEstateManageTelehub; 198 public event EstateManageTelehub OnEstateManageTelehub;
199 public event CachedTextureRequest OnCachedTextureRequest;
199 200
200 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 201 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
201 202
@@ -509,6 +510,11 @@ namespace OpenSim.Tests.Common.Mock
509 { 510 {
510 } 511 }
511 512
513 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
514 {
515
516 }
517
512 public virtual void Kick(string message) 518 public virtual void Kick(string message)
513 { 519 {
514 } 520 }