aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs140
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs110
2 files changed, 230 insertions, 20 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 3b0ccd7..6778ba5 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections; 29using System.Collections;
30using System.Collections.Generic;
30using System.Collections.Specialized; 31using System.Collections.Specialized;
31using System.Drawing; 32using System.Drawing;
32using System.Drawing.Imaging; 33using System.Drawing.Imaging;
@@ -53,8 +54,8 @@ namespace OpenSim.Region.ClientStack.Linden
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")] 54 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "UploadBakedTextureModule")]
54 public class UploadBakedTextureModule : INonSharedRegionModule 55 public class UploadBakedTextureModule : INonSharedRegionModule
55 { 56 {
56// private static readonly ILog m_log = 57 private static readonly ILog m_log =
57// LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 58 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 59
59 /// <summary> 60 /// <summary>
60 /// For historical reasons this is fixed, but there 61 /// For historical reasons this is fixed, but there
@@ -64,31 +65,154 @@ namespace OpenSim.Region.ClientStack.Linden
64 private Scene m_scene; 65 private Scene m_scene;
65 private bool m_persistBakedTextures; 66 private bool m_persistBakedTextures;
66 67
68 private IBakedTextureModule m_BakedTextureModule;
69
67 public void Initialise(IConfigSource source) 70 public void Initialise(IConfigSource source)
68 { 71 {
69 IConfig appearanceConfig = source.Configs["Appearance"]; 72 IConfig appearanceConfig = source.Configs["Appearance"];
70 if (appearanceConfig != null) 73 if (appearanceConfig != null)
71 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); 74 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
75
76
72 } 77 }
73 78
74 public void AddRegion(Scene s) 79 public void AddRegion(Scene s)
75 { 80 {
76 m_scene = s; 81 m_scene = s;
82
77 } 83 }
78 84
79 public void RemoveRegion(Scene s) 85 public void RemoveRegion(Scene s)
80 { 86 {
87 s.EventManager.OnRegisterCaps -= RegisterCaps;
88 s.EventManager.OnNewPresence -= RegisterNewPresence;
89 s.EventManager.OnRemovePresence -= DeRegisterPresence;
90 m_BakedTextureModule = null;
91 m_scene = null;
81 } 92 }
82 93
94
95
83 public void RegionLoaded(Scene s) 96 public void RegionLoaded(Scene s)
84 { 97 {
85 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 98 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
99 m_scene.EventManager.OnNewPresence += RegisterNewPresence;
100 m_scene.EventManager.OnRemovePresence += DeRegisterPresence;
101
102 }
103
104 private void DeRegisterPresence(UUID agentId)
105 {
106 ScenePresence presence = null;
107 if (m_scene.TryGetScenePresence(agentId, out presence))
108 {
109 presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
110 }
111
112 }
113
114 private void RegisterNewPresence(ScenePresence presence)
115 {
116 presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
117
118 }
119
120 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
121 {
122 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
123 if (cacheItems.Length > 0)
124 {
125 m_log.Info("[Cacheitems]: " + cacheItems.Length);
126 for (int iter = 0; iter < cacheItems.Length; iter++)
127 {
128 m_log.Info("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
129 cacheItems[iter].TextureID);
130 }
131
132 ScenePresence p = null;
133 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
134 {
135
136 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
137 if (existingitems == null)
138 {
139 if (m_BakedTextureModule != null)
140 {
141 WearableCacheItem[] savedcache = null;
142 try
143 {
144 if (p.Appearance.WearableCacheItemsDirty)
145 {
146 savedcache = m_BakedTextureModule.Get(p.UUID);
147 p.Appearance.WearableCacheItems = savedcache;
148 p.Appearance.WearableCacheItemsDirty = false;
149 }
150
151 }
152 catch (InvalidOperationException)
153 {
154 }
155
156 if (savedcache != null)
157 existingitems = savedcache;
158 }
159 }
160 // Existing items null means it's a fully new appearance
161 if (existingitems == null)
162 {
163
164 for (int iter = 0; iter < cacheItems.Length; iter++)
165 {
166
167 cacheItems[iter].TextureID = textureEntry.FaceTextures[cacheItems[iter].TextureIndex].TextureID;
168 if (m_scene.AssetService != null)
169 cacheItems[iter].TextureAsset = m_scene.AssetService.GetCached(cacheItems[iter].TextureID.ToString());
170
171
172 }
173 }
174 else
175
176
177 {
178 // for each uploaded baked texture
179 for (int i = 0; i < cacheItems.Length; i++)
180 {
181 cacheItems[i].TextureID =
182 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID;
183 }
184
185 for (int i = 0; i < cacheItems.Length; i++)
186 {
187 if (cacheItems[i].TextureAsset == null)
188 {
189 cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
190 }
191 }
192 }
193
194
195
196 p.Appearance.WearableCacheItems = cacheItems;
197
198
199
200 if (m_BakedTextureModule != null)
201 {
202 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
203 p.Appearance.WearableCacheItemsDirty = true;
204
205 }
206 }
207 }
86 } 208 }
87 209
88 public void PostInitialise() 210 public void PostInitialise()
89 { 211 {
90 } 212 }
91 213
214
215
92 public void Close() { } 216 public void Close() { }
93 217
94 public string Name { get { return "UploadBakedTextureModule"; } } 218 public string Name { get { return "UploadBakedTextureModule"; } }
@@ -100,15 +224,23 @@ namespace OpenSim.Region.ClientStack.Linden
100 224
101 public void RegisterCaps(UUID agentID, Caps caps) 225 public void RegisterCaps(UUID agentID, Caps caps)
102 { 226 {
227 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
228 caps, m_scene.AssetService, m_persistBakedTextures);
229
230
231
103 caps.RegisterHandler( 232 caps.RegisterHandler(
104 "UploadBakedTexture", 233 "UploadBakedTexture",
105 new RestStreamHandler( 234 new RestStreamHandler(
106 "POST", 235 "POST",
107 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, 236 "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath,
108 new UploadBakedTextureHandler( 237 avatarhandler.UploadBakedTexture,
109 caps, m_scene.AssetService, m_persistBakedTextures).UploadBakedTexture,
110 "UploadBakedTexture", 238 "UploadBakedTexture",
111 agentID.ToString())); 239 agentID.ToString()));
240
241
242
243
112 } 244 }
113 } 245 }
114} \ No newline at end of file 246} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index d18b026..9e39699 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -3629,7 +3629,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3629 3629
3630 avp.Sender.IsTrial = false; 3630 avp.Sender.IsTrial = false;
3631 avp.Sender.ID = agentID; 3631 avp.Sender.ID = agentID;
3632 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); 3632 m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3633 OutPacket(avp, ThrottleOutPacketType.State); 3633 OutPacket(avp, ThrottleOutPacketType.State);
3634 } 3634 }
3635 3635
@@ -11725,32 +11725,110 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11725 // var item = fac.GetBakedTextureFaces(AgentId); 11725 // var item = fac.GetBakedTextureFaces(AgentId);
11726 //WearableCacheItem[] items = fac.GetCachedItems(AgentId); 11726 //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
11727 11727
11728 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>(); 11728 IAssetService cache = m_scene.AssetService;
11729 if (cache == null) 11729 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
11730 if (bakedTextureModule != null && cache != null)
11730 { 11731 {
11731 for (int i = 0; i < cachedtex.WearableData.Length; i++) 11732 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
11733
11734 WearableCacheItem[] cacheItems = null;
11735 ScenePresence p = m_scene.GetScenePresence(AgentId);
11736 if (p.Appearance != null)
11737 if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
11738 {
11739 try
11740 {
11741 cacheItems = bakedTextureModule.Get(AgentId);
11742 p.Appearance.WearableCacheItems = cacheItems;
11743 p.Appearance.WearableCacheItemsDirty = false;
11744 }
11745 catch (InvalidOperationException)
11746 {
11747 cacheItems = null;
11748 }
11749 }
11750 else if (p.Appearance.WearableCacheItems != null)
11751 {
11752 cacheItems = p.Appearance.WearableCacheItems;
11753 }
11754
11755 if (cache != null && cacheItems != null)
11756 {
11757 foreach (WearableCacheItem item in cacheItems)
11758 {
11759
11760 if (cache.GetCached(item.TextureID.ToString()) == null)
11761 {
11762 item.TextureAsset.Temporary = true;
11763 cache.Store(item.TextureAsset);
11764 }
11765
11766
11767 }
11768 }
11769 if (cacheItems != null)
11770 {
11771
11772 for (int i = 0; i < cachedtex.WearableData.Length; i++)
11773 {
11774 WearableCacheItem item =
11775 WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
11776
11777 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11778 cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex;
11779 cachedresp.WearableData[i].HostName = new byte[0];
11780 if (item != null)
11781 {
11782 cachedresp.WearableData[i].TextureID = item.TextureID;
11783 }
11784 else
11785 {
11786 cachedresp.WearableData[i].TextureID = UUID.Zero;
11787 }
11788 }
11789 }
11790 else
11732 { 11791 {
11733 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 11792 for (int i = 0; i < cachedtex.WearableData.Length; i++)
11734 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 11793 {
11735 cachedresp.WearableData[i].TextureID = UUID.Zero; //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11794 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11736 cachedresp.WearableData[i].HostName = new byte[0]; 11795 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11796 cachedresp.WearableData[i].TextureID = UUID.Zero;
11797 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11798 cachedresp.WearableData[i].HostName = new byte[0];
11799 }
11737 } 11800 }
11738 } 11801 }
11739 else 11802 else
11740 { 11803 {
11741 for (int i = 0; i < cachedtex.WearableData.Length; i++) 11804 if (cache == null)
11805 {
11806 for (int i = 0; i < cachedtex.WearableData.Length; i++)
11807 {
11808 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11809 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11810 cachedresp.WearableData[i].TextureID = UUID.Zero;
11811 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11812 cachedresp.WearableData[i].HostName = new byte[0];
11813 }
11814 }
11815 else
11742 { 11816 {
11743 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 11817 for (int i = 0; i < cachedtex.WearableData.Length; i++)
11744 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 11818 {
11819 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11820 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11745 11821
11746 11822
11747 11823
11748 if (cache.Check(cachedtex.WearableData[i].ID.ToString())) 11824 if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
11749 cachedresp.WearableData[i].TextureID = UUID.Zero; 11825 cachedresp.WearableData[i].TextureID = UUID.Zero;
11750 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11826 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11751 else 11827 else
11752 cachedresp.WearableData[i].TextureID = UUID.Zero; // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46"); 11828 cachedresp.WearableData[i].TextureID = UUID.Zero;
11753 cachedresp.WearableData[i].HostName = new byte[0]; 11829 // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11830 cachedresp.WearableData[i].HostName = new byte[0];
11831 }
11754 } 11832 }
11755 } 11833 }
11756 cachedresp.Header.Zerocoded = true; 11834 cachedresp.Header.Zerocoded = true;