aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs123
1 files changed, 82 insertions, 41 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index 6778ba5..6bed95f 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -119,13 +119,20 @@ namespace OpenSim.Region.ClientStack.Linden
119 119
120 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) 120 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
121 { 121 {
122 int maxCacheitemsLoop = cacheItems.Length;
123 if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES)
124 {
125 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
126 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
127 }
128
122 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 129 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
123 if (cacheItems.Length > 0) 130 if (cacheItems.Length > 0)
124 { 131 {
125 m_log.Info("[Cacheitems]: " + cacheItems.Length); 132 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
126 for (int iter = 0; iter < cacheItems.Length; iter++) 133 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
127 { 134 {
128 m_log.Info("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + 135 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
129 cacheItems[iter].TextureID); 136 cacheItems[iter].TextureID);
130 } 137 }
131 138
@@ -133,65 +140,99 @@ namespace OpenSim.Region.ClientStack.Linden
133 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) 140 if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
134 { 141 {
135 142
136 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; 143 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
137 if (existingitems == null) 144 if (existingitems == null)
145 {
146 if (m_BakedTextureModule != null)
138 { 147 {
139 if (m_BakedTextureModule != null) 148 WearableCacheItem[] savedcache = null;
149 try
140 { 150 {
141 WearableCacheItem[] savedcache = null; 151 if (p.Appearance.WearableCacheItemsDirty)
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 { 152 {
153 savedcache = m_BakedTextureModule.Get(p.UUID);
154 p.Appearance.WearableCacheItems = savedcache;
155 p.Appearance.WearableCacheItemsDirty = false;
154 } 156 }
155 157
156 if (savedcache != null)
157 existingitems = savedcache;
158 } 158 }
159 /*
160 * The following Catch types DO NOT WORK with m_BakedTextureModule.Get
161 * it jumps to the General Packet Exception Handler if you don't catch Exception!
162 *
163 catch (System.Net.Sockets.SocketException)
164 {
165 cacheItems = null;
166 }
167 catch (WebException)
168 {
169 cacheItems = null;
170 }
171 catch (InvalidOperationException)
172 {
173 cacheItems = null;
174 } */
175 catch (Exception)
176 {
177 // The service logs a sufficient error message.
178 }
179
180
181 if (savedcache != null)
182 existingitems = savedcache;
159 } 183 }
160 // Existing items null means it's a fully new appearance 184 }
161 if (existingitems == null) 185 // Existing items null means it's a fully new appearance
162 { 186 if (existingitems == null)
187 {
163 188
164 for (int iter = 0; iter < cacheItems.Length; iter++) 189 for (int i = 0; i < maxCacheitemsLoop; i++)
190 {
191 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
165 { 192 {
166 193 cacheItems[i].TextureID =
167 cacheItems[iter].TextureID = textureEntry.FaceTextures[cacheItems[iter].TextureIndex].TextureID; 194 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID;
168 if (m_scene.AssetService != null) 195 if (m_scene.AssetService != null)
169 cacheItems[iter].TextureAsset = m_scene.AssetService.GetCached(cacheItems[iter].TextureID.ToString()); 196 cacheItems[i].TextureAsset =
170 197 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
171 198 }
199 else
200 {
201 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
172 } 202 }
203
204
173 } 205 }
174 else 206 }
175 207 else
176 208
209
210 {
211 // for each uploaded baked texture
212 for (int i = 0; i < maxCacheitemsLoop; i++)
177 { 213 {
178 // for each uploaded baked texture 214 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
179 for (int i = 0; i < cacheItems.Length; i++)
180 { 215 {
181 cacheItems[i].TextureID = 216 cacheItems[i].TextureID =
182 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID; 217 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID;
183 } 218 }
184 219 else
185 for (int i = 0; i < cacheItems.Length; i++)
186 { 220 {
187 if (cacheItems[i].TextureAsset == null) 221 m_log.WarnFormat("[CACHEDBAKES]: Invalid Texture Index Provided, Texture doesn't exist or hasn't been uploaded yet {0}, the max is {1}. Skipping!", cacheItems[i].TextureIndex, textureEntry.FaceTextures.Length);
188 {
189 cacheItems[i].TextureAsset = m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
190 }
191 } 222 }
192 } 223 }
193 224
194 225 for (int i = 0; i < maxCacheitemsLoop; i++)
226 {
227 if (cacheItems[i].TextureAsset == null)
228 {
229 cacheItems[i].TextureAsset =
230 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
231 }
232 }
233 }
234
235
195 236
196 p.Appearance.WearableCacheItems = cacheItems; 237 p.Appearance.WearableCacheItems = cacheItems;
197 238