diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | 196 |
1 files changed, 188 insertions, 8 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs index 50e9275..c27d101 100644 --- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs +++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs | |||
@@ -64,18 +64,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
64 | 64 | ||
65 | private Scene m_scene; | 65 | private Scene m_scene; |
66 | private bool m_persistBakedTextures; | 66 | private bool m_persistBakedTextures; |
67 | private string m_URL; | 67 | |
68 | private IBakedTextureModule m_BakedTextureModule; | ||
68 | 69 | ||
69 | private IBakedTextureModule m_BakedTextureModule; | 70 | private IBakedTextureModule m_BakedTextureModule; |
70 | 71 | ||
71 | public void Initialise(IConfigSource source) | 72 | public void Initialise(IConfigSource source) |
72 | { | 73 | { |
73 | IConfig config = source.Configs["ClientStack.LindenCaps"]; | ||
74 | if (config == null) | ||
75 | return; | ||
76 | |||
77 | m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty); | ||
78 | |||
79 | IConfig appearanceConfig = source.Configs["Appearance"]; | 74 | IConfig appearanceConfig = source.Configs["Appearance"]; |
80 | if (appearanceConfig != null) | 75 | if (appearanceConfig != null) |
81 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); | 76 | m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures); |
@@ -96,7 +91,13 @@ namespace OpenSim.Region.ClientStack.Linden | |||
96 | s.EventManager.OnRemovePresence -= DeRegisterPresence; | 91 | s.EventManager.OnRemovePresence -= DeRegisterPresence; |
97 | m_BakedTextureModule = null; | 92 | m_BakedTextureModule = null; |
98 | m_scene = null; | 93 | m_scene = null; |
94 | <<<<<<< HEAD | ||
95 | } | ||
96 | ======= | ||
99 | } | 97 | } |
98 | >>>>>>> avn/ubitvar | ||
99 | |||
100 | |||
100 | 101 | ||
101 | public void RegionLoaded(Scene s) | 102 | public void RegionLoaded(Scene s) |
102 | { | 103 | { |
@@ -108,12 +109,173 @@ namespace OpenSim.Region.ClientStack.Linden | |||
108 | 109 | ||
109 | private void DeRegisterPresence(UUID agentId) | 110 | private void DeRegisterPresence(UUID agentId) |
110 | { | 111 | { |
112 | <<<<<<< HEAD | ||
113 | ScenePresence presence = null; | ||
114 | if (m_scene.TryGetScenePresence(agentId, out presence)) | ||
115 | { | ||
116 | presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; | ||
117 | } | ||
118 | |||
119 | } | ||
120 | |||
121 | private void RegisterNewPresence(ScenePresence presence) | ||
122 | { | ||
123 | presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; | ||
124 | |||
125 | } | ||
126 | |||
127 | private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) | ||
128 | { | ||
129 | int maxCacheitemsLoop = cacheItems.Length; | ||
130 | if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) | ||
131 | { | ||
132 | maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES; | ||
133 | m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES); | ||
134 | } | ||
135 | |||
136 | m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); | ||
137 | if (cacheItems.Length > 0) | ||
138 | { | ||
139 | // m_log.Debug("[Cacheitems]: " + cacheItems.Length); | ||
140 | // for (int iter = 0; iter < maxCacheitemsLoop; iter++) | ||
141 | // { | ||
142 | // m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + | ||
143 | // cacheItems[iter].TextureID); | ||
144 | // } | ||
145 | |||
146 | ScenePresence p = null; | ||
147 | if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) | ||
148 | { | ||
149 | |||
150 | WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems; | ||
151 | if (existingitems == null) | ||
152 | { | ||
153 | if (m_BakedTextureModule != null) | ||
154 | { | ||
155 | WearableCacheItem[] savedcache = null; | ||
156 | try | ||
157 | { | ||
158 | if (p.Appearance.WearableCacheItemsDirty) | ||
159 | { | ||
160 | savedcache = m_BakedTextureModule.Get(p.UUID); | ||
161 | p.Appearance.WearableCacheItems = savedcache; | ||
162 | p.Appearance.WearableCacheItemsDirty = false; | ||
163 | } | ||
164 | |||
165 | } | ||
166 | /* | ||
167 | * The following Catch types DO NOT WORK with m_BakedTextureModule.Get | ||
168 | * it jumps to the General Packet Exception Handler if you don't catch Exception! | ||
169 | * | ||
170 | catch (System.Net.Sockets.SocketException) | ||
171 | { | ||
172 | cacheItems = null; | ||
173 | } | ||
174 | catch (WebException) | ||
175 | { | ||
176 | cacheItems = null; | ||
177 | } | ||
178 | catch (InvalidOperationException) | ||
179 | { | ||
180 | cacheItems = null; | ||
181 | } */ | ||
182 | catch (Exception) | ||
183 | { | ||
184 | // The service logs a sufficient error message. | ||
185 | } | ||
186 | |||
187 | |||
188 | if (savedcache != null) | ||
189 | existingitems = savedcache; | ||
190 | } | ||
191 | } | ||
192 | // Existing items null means it's a fully new appearance | ||
193 | if (existingitems == null) | ||
194 | { | ||
195 | |||
196 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
197 | { | ||
198 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
199 | { | ||
200 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; | ||
201 | if (face == null) | ||
202 | { | ||
203 | textureEntry.CreateFace(cacheItems[i].TextureIndex); | ||
204 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = | ||
205 | AppearanceManager.DEFAULT_AVATAR_TEXTURE; | ||
206 | continue; | ||
207 | } | ||
208 | cacheItems[i].TextureID =face.TextureID; | ||
209 | if (m_scene.AssetService != null) | ||
210 | cacheItems[i].TextureAsset = | ||
211 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
212 | } | ||
213 | else | ||
214 | { | ||
215 | 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); | ||
216 | } | ||
217 | |||
218 | |||
219 | } | ||
220 | } | ||
221 | else | ||
222 | |||
223 | |||
224 | { | ||
225 | // for each uploaded baked texture | ||
226 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
227 | { | ||
228 | if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) | ||
229 | { | ||
230 | Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex]; | ||
231 | if (face == null) | ||
232 | { | ||
233 | textureEntry.CreateFace(cacheItems[i].TextureIndex); | ||
234 | textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID = | ||
235 | AppearanceManager.DEFAULT_AVATAR_TEXTURE; | ||
236 | continue; | ||
237 | } | ||
238 | cacheItems[i].TextureID = | ||
239 | face.TextureID; | ||
240 | } | ||
241 | else | ||
242 | { | ||
243 | 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); | ||
244 | } | ||
245 | } | ||
246 | |||
247 | for (int i = 0; i < maxCacheitemsLoop; i++) | ||
248 | { | ||
249 | if (cacheItems[i].TextureAsset == null) | ||
250 | { | ||
251 | cacheItems[i].TextureAsset = | ||
252 | m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); | ||
253 | } | ||
254 | } | ||
255 | } | ||
256 | |||
257 | |||
258 | |||
259 | p.Appearance.WearableCacheItems = cacheItems; | ||
260 | |||
261 | |||
262 | |||
263 | if (m_BakedTextureModule != null) | ||
264 | { | ||
265 | m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); | ||
266 | p.Appearance.WearableCacheItemsDirty = true; | ||
267 | |||
268 | } | ||
269 | } | ||
270 | } | ||
271 | ======= | ||
111 | // ScenePresence presence = null; | 272 | // ScenePresence presence = null; |
112 | // if (m_scene.TryGetScenePresence(agentId, out presence)) | 273 | // if (m_scene.TryGetScenePresence(agentId, out presence)) |
113 | { | 274 | { |
114 | // presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; | 275 | // presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; |
115 | } | 276 | } |
116 | 277 | ||
278 | >>>>>>> avn/ubitvar | ||
117 | } | 279 | } |
118 | 280 | ||
119 | private void RegisterNewPresence(ScenePresence presence) | 281 | private void RegisterNewPresence(ScenePresence presence) |
@@ -279,8 +441,25 @@ namespace OpenSim.Region.ClientStack.Linden | |||
279 | 441 | ||
280 | public void RegisterCaps(UUID agentID, Caps caps) | 442 | public void RegisterCaps(UUID agentID, Caps caps) |
281 | { | 443 | { |
282 | // UUID capID = UUID.Random(); | 444 | UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( |
445 | caps, m_scene.AssetService, m_persistBakedTextures); | ||
446 | |||
447 | <<<<<<< HEAD | ||
448 | |||
449 | |||
450 | caps.RegisterHandler( | ||
451 | "UploadBakedTexture", | ||
452 | new RestStreamHandler( | ||
453 | "POST", | ||
454 | "/CAPS/" + caps.CapsObjectPath + m_uploadBakedTexturePath, | ||
455 | avatarhandler.UploadBakedTexture, | ||
456 | "UploadBakedTexture", | ||
457 | agentID.ToString())); | ||
458 | |||
459 | |||
460 | |||
283 | 461 | ||
462 | ======= | ||
284 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); | 463 | //caps.RegisterHandler("GetTexture", new StreamHandler("GET", "/CAPS/" + capID, ProcessGetTexture)); |
285 | if (m_URL == "localhost") | 464 | if (m_URL == "localhost") |
286 | { | 465 | { |
@@ -301,6 +480,7 @@ namespace OpenSim.Region.ClientStack.Linden | |||
301 | { | 480 | { |
302 | caps.RegisterHandler("UploadBakedTexture", m_URL); | 481 | caps.RegisterHandler("UploadBakedTexture", m_URL); |
303 | } | 482 | } |
483 | >>>>>>> avn/ubitvar | ||
304 | } | 484 | } |
305 | } | 485 | } |
306 | } | 486 | } |