aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs21
-rw-r--r--OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs2
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs155
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs38
4 files changed, 24 insertions, 192 deletions
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
index 80b8306..f90c7e7 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureHandler.cs
@@ -26,24 +26,12 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
30using System.Collections.Generic;
31using System.Collections.Specialized;
32using System.Drawing;
33using System.Drawing.Imaging;
34using System.Reflection; 29using System.Reflection;
35using System.IO;
36using System.Web;
37using log4net; 30using log4net;
38using Nini.Config;
39using OpenMetaverse; 31using OpenMetaverse;
40using OpenMetaverse.StructuredData;
41using OpenMetaverse.Imaging;
42using OpenSim.Framework; 32using OpenSim.Framework;
43using OpenSim.Framework.Capabilities; 33using OpenSim.Framework.Capabilities;
44using OpenSim.Framework.Servers;
45using OpenSim.Framework.Servers.HttpServer; 34using OpenSim.Framework.Servers.HttpServer;
46using OpenSim.Region.Framework.Interfaces;
47using OpenSim.Services.Interfaces; 35using OpenSim.Services.Interfaces;
48using Caps = OpenSim.Framework.Capabilities.Caps; 36using Caps = OpenSim.Framework.Capabilities.Caps;
49 37
@@ -56,13 +44,11 @@ namespace OpenSim.Capabilities.Handlers
56 44
57 private Caps m_HostCapsObj; 45 private Caps m_HostCapsObj;
58 private IAssetService m_assetService; 46 private IAssetService m_assetService;
59 private bool m_persistBakedTextures;
60 47
61 public UploadBakedTextureHandler(Caps caps, IAssetService assetService, bool persistBakedTextures) 48 public UploadBakedTextureHandler(Caps caps, IAssetService assetService)
62 { 49 {
63 m_HostCapsObj = caps; 50 m_HostCapsObj = caps;
64 m_assetService = assetService; 51 m_assetService = assetService;
65 m_persistBakedTextures = persistBakedTextures;
66 } 52 }
67 53
68 /// <summary> 54 /// <summary>
@@ -125,9 +111,8 @@ namespace OpenSim.Capabilities.Handlers
125 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString()); 111 asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
126 asset.Data = data; 112 asset.Data = data;
127 asset.Temporary = true; 113 asset.Temporary = true;
128 asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are 114 asset.Local = false;
129 m_assetService.Store(asset); 115 m_assetService.Store(asset);
130
131 } 116 }
132 } 117 }
133 118
@@ -151,8 +136,6 @@ namespace OpenSim.Capabilities.Handlers
151 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID); 136 // m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
152 } 137 }
153 138
154
155
156 /// <summary> 139 /// <summary>
157 /// Handle raw uploaded baked texture data. 140 /// Handle raw uploaded baked texture data.
158 /// </summary> 141 /// </summary>
diff --git a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs
index 10ea8ee..fd484ba 100644
--- a/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs
+++ b/OpenSim/Capabilities/Handlers/UploadBakedTexture/UploadBakedTextureServerConnector.cs
@@ -67,7 +67,7 @@ namespace OpenSim.Capabilities.Handlers
67 server.AddStreamHandler(new RestStreamHandler( 67 server.AddStreamHandler(new RestStreamHandler(
68 "POST", 68 "POST",
69 "/CAPS/UploadBakedTexture/", 69 "/CAPS/UploadBakedTexture/",
70 new UploadBakedTextureHandler(caps, m_AssetService, true).UploadBakedTexture, 70 new UploadBakedTextureHandler(caps, m_AssetService).UploadBakedTexture,
71 "UploadBakedTexture", 71 "UploadBakedTexture",
72 "Upload Baked Texture Capability")); 72 "Upload Baked Texture Capability"));
73 73
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
index dfe097e..b406b37 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/UploadBakedTextureModule.cs
@@ -63,9 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden
63 private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule. 63 private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
64 64
65 private Scene m_scene; 65 private Scene m_scene;
66 private bool m_persistBakedTextures;
67 66
68 private IBakedTextureModule m_BakedTextureModule;
69 private string m_URL; 67 private string m_URL;
70 68
71 public void Initialise(IConfigSource source) 69 public void Initialise(IConfigSource source)
@@ -76,15 +74,12 @@ namespace OpenSim.Region.ClientStack.Linden
76 74
77 m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty); 75 m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
78 76
79 IConfig appearanceConfig = source.Configs["Appearance"]; 77// IConfig appearanceConfig = source.Configs["Appearance"];
80 if (appearanceConfig != null)
81 m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
82 } 78 }
83 79
84 public void AddRegion(Scene s) 80 public void AddRegion(Scene s)
85 { 81 {
86 m_scene = s; 82 m_scene = s;
87
88 } 83 }
89 84
90 public void RemoveRegion(Scene s) 85 public void RemoveRegion(Scene s)
@@ -92,7 +87,6 @@ namespace OpenSim.Region.ClientStack.Linden
92 s.EventManager.OnRegisterCaps -= RegisterCaps; 87 s.EventManager.OnRegisterCaps -= RegisterCaps;
93 s.EventManager.OnNewPresence -= RegisterNewPresence; 88 s.EventManager.OnNewPresence -= RegisterNewPresence;
94 s.EventManager.OnRemovePresence -= DeRegisterPresence; 89 s.EventManager.OnRemovePresence -= DeRegisterPresence;
95 m_BakedTextureModule = null;
96 m_scene = null; 90 m_scene = null;
97 } 91 }
98 92
@@ -101,7 +95,6 @@ namespace OpenSim.Region.ClientStack.Linden
101 m_scene.EventManager.OnRegisterCaps += RegisterCaps; 95 m_scene.EventManager.OnRegisterCaps += RegisterCaps;
102 m_scene.EventManager.OnNewPresence += RegisterNewPresence; 96 m_scene.EventManager.OnNewPresence += RegisterNewPresence;
103 m_scene.EventManager.OnRemovePresence += DeRegisterPresence; 97 m_scene.EventManager.OnRemovePresence += DeRegisterPresence;
104
105 } 98 }
106 99
107 private void DeRegisterPresence(UUID agentId) 100 private void DeRegisterPresence(UUID agentId)
@@ -110,156 +103,12 @@ namespace OpenSim.Region.ClientStack.Linden
110 103
111 private void RegisterNewPresence(ScenePresence presence) 104 private void RegisterNewPresence(ScenePresence presence)
112 { 105 {
113// presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
114 } 106 }
115 107
116/* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache()
117 private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
118 {
119 // if cacheItems.Length > 0 viewer is giving us current textures information.
120 // baked ones should had been uploaded and in assets cache as local itens
121
122
123 if (cacheItems.Length == 0)
124 return; // no textures information, nothing to do
125
126 ScenePresence p = null;
127 if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
128 return; // what are we doing if there is no presence to cache for?
129
130 if (p.IsDeleted)
131 return; // does this really work?
132
133 int maxCacheitemsLoop = cacheItems.Length;
134 if (maxCacheitemsLoop > 20)
135 {
136 maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
137 m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
138 }
139
140 m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
141
142
143 // some nice debug
144 m_log.Debug("[Cacheitems]: " + cacheItems.Length);
145 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
146 {
147 m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
148 cacheItems[iter].TextureID);
149 }
150
151 // p.Appearance.WearableCacheItems is in memory primary cashID to textures mapper
152
153 WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
154
155 if (existingitems == null)
156 {
157 if (m_BakedTextureModule != null)
158 {
159 WearableCacheItem[] savedcache = null;
160 try
161 {
162 if (p.Appearance.WearableCacheItemsDirty)
163 {
164 savedcache = m_BakedTextureModule.Get(p.UUID);
165 p.Appearance.WearableCacheItems = savedcache;
166 p.Appearance.WearableCacheItemsDirty = false;
167 }
168 }
169
170 catch (Exception)
171 {
172 // The service logs a sufficient error message.
173 }
174
175
176 if (savedcache != null)
177 existingitems = savedcache;
178 }
179 }
180
181 // Existing items null means it's a fully new appearance
182 if (existingitems == null)
183 {
184 for (int i = 0; i < maxCacheitemsLoop; i++)
185 {
186 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
187 {
188 Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
189 if (face == null)
190 {
191 textureEntry.CreateFace(cacheItems[i].TextureIndex);
192 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
193 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
194 continue;
195 }
196 cacheItems[i].TextureID = face.TextureID;
197 if (m_scene.AssetService != null)
198 cacheItems[i].TextureAsset =
199 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
200 }
201 else
202 {
203 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);
204 }
205 }
206 }
207 else
208 {
209 for (int i = 0; i < maxCacheitemsLoop; i++)
210 {
211 if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
212 {
213 Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
214 if (face == null)
215 {
216 textureEntry.CreateFace(cacheItems[i].TextureIndex);
217 textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
218 AppearanceManager.DEFAULT_AVATAR_TEXTURE;
219 continue;
220 }
221 cacheItems[i].TextureID =
222 face.TextureID;
223 }
224 else
225 {
226 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);
227 }
228 }
229
230 for (int i = 0; i < maxCacheitemsLoop; i++)
231 {
232 if (cacheItems[i].TextureAsset == null)
233 {
234 cacheItems[i].TextureAsset =
235 m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
236 }
237 }
238 }
239 p.Appearance.WearableCacheItems = cacheItems;
240
241 if (m_BakedTextureModule != null)
242 {
243 m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
244 p.Appearance.WearableCacheItemsDirty = true;
245
246 }
247 else
248 p.Appearance.WearableCacheItemsDirty = false;
249
250 for (int iter = 0; iter < maxCacheitemsLoop; iter++)
251 {
252 m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
253 cacheItems[iter].TextureID);
254 }
255 }
256 */
257 public void PostInitialise() 108 public void PostInitialise()
258 { 109 {
259 } 110 }
260 111
261
262
263 public void Close() { } 112 public void Close() { }
264 113
265 public string Name { get { return "UploadBakedTextureModule"; } } 114 public string Name { get { return "UploadBakedTextureModule"; } }
@@ -275,7 +124,7 @@ namespace OpenSim.Region.ClientStack.Linden
275 if (m_URL == "localhost") 124 if (m_URL == "localhost")
276 { 125 {
277 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler( 126 UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
278 caps, m_scene.AssetService, m_persistBakedTextures); 127 caps, m_scene.AssetService);
279 128
280 caps.RegisterHandler( 129 caps.RegisterHandler(
281 "UploadBakedTexture", 130 "UploadBakedTexture",
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 535d946..14607e9 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
369 return true; 369 return true;
370 370
371 // uploaded baked textures will be in assets local cache 371 // uploaded baked textures will be in assets local cache
372 IAssetService cache = m_scene.AssetService; 372 IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
373 IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 373 IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
374 374
375 int validDirtyBakes = 0; 375 int validDirtyBakes = 0;
@@ -436,7 +436,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
436*/ 436*/
437 wearableCache[idx].TextureAsset = null; 437 wearableCache[idx].TextureAsset = null;
438 if (cache != null) 438 if (cache != null)
439 wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString()); 439 {
440 AssetBase asb = null;
441 cache.Get(face.TextureID.ToString(), out asb);
442 wearableCache[idx].TextureAsset = asb;
443 }
440 444
441 if (wearableCache[idx].TextureAsset != null) 445 if (wearableCache[idx].TextureAsset != null)
442 { 446 {
@@ -481,15 +485,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
481 // if we got a full set of baked textures save all in BakedTextureModule 485 // if we got a full set of baked textures save all in BakedTextureModule
482 if (m_BakedTextureModule != null) 486 if (m_BakedTextureModule != null)
483 { 487 {
484 m_log.Debug("[UpdateBakedCache] start async uploading to bakedModule cache"); 488 m_log.DebugFormat("[UpdateBakedCache] Uploading to Bakes Server: cache hits: {0} changed entries: {1} rebakes {2}",
489 hits.ToString(), validDirtyBakes.ToString(), missing.Count);
485 490
486 m_BakedTextureModule.Store(sp.UUID, wearableCache); 491 m_BakedTextureModule.Store(sp.UUID, wearableCache);
487 } 492 }
488 } 493 }
489 494 else
490 495 m_log.DebugFormat("[UpdateBakedCache] cache hits: {0} changed entries: {1} rebakes {2}",
491 // debug 496 hits.ToString(), validDirtyBakes.ToString(), missing.Count);
492 m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString() + " rebakes " + missing.Count);
493/* 497/*
494 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++) 498 for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
495 { 499 {
@@ -513,7 +517,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
513 517
514 lock (m_setAppearanceLock) 518 lock (m_setAppearanceLock)
515 { 519 {
516 IAssetService cache = m_scene.AssetService; 520 IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
517 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>(); 521 IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
518 WearableCacheItem[] bakedModuleCache = null; 522 WearableCacheItem[] bakedModuleCache = null;
519 523
@@ -553,6 +557,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
553 } 557 }
554 } 558 }
555*/ 559*/
560
556 bool wearableCacheValid = false; 561 bool wearableCacheValid = false;
557 if (wearableCache == null) 562 if (wearableCache == null)
558 { 563 {
@@ -577,10 +582,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
577 hits++; 582 hits++;
578 wearableCache[idx].TextureAsset.Temporary = true; 583 wearableCache[idx].TextureAsset.Temporary = true;
579 wearableCache[idx].TextureAsset.Local = true; 584 wearableCache[idx].TextureAsset.Local = true;
580 cache.Store(wearableCache[idx].TextureAsset); 585 cache.Cache(wearableCache[idx].TextureAsset);
581 continue; 586 continue;
582 } 587 }
583 if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null) 588
589 if (cache.Check((wearableCache[idx].TextureID).ToString()))
584 { 590 {
585 hits++; 591 hits++;
586 continue; 592 continue;
@@ -645,7 +651,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
645 wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset; 651 wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
646 bakedModuleCache[i].TextureAsset.Temporary = true; 652 bakedModuleCache[i].TextureAsset.Temporary = true;
647 bakedModuleCache[i].TextureAsset.Local = true; 653 bakedModuleCache[i].TextureAsset.Local = true;
648 cache.Store(bakedModuleCache[i].TextureAsset); 654 cache.Cache(bakedModuleCache[i].TextureAsset);
649 } 655 }
650 } 656 }
651 gotbacked = true; 657 gotbacked = true;
@@ -706,7 +712,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
706 return 0; 712 return 0;
707 713
708 int texturesRebaked = 0; 714 int texturesRebaked = 0;
709// IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>(); 715 IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
710 716
711 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 717 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
712 { 718 {
@@ -722,18 +728,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
722 728
723 if (missingTexturesOnly) 729 if (missingTexturesOnly)
724 { 730 {
725 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) 731 if (cache != null && cache.Check(face.TextureID.ToString()))
726 { 732 {
727 continue; 733 continue;
728 } 734 }
729 else 735 else
730 { 736 {
731 // On inter-simulator teleports, this occurs if baked textures are not being stored by the
732 // grid asset service (which means that they are not available to the new region and so have
733 // to be re-requested from the client).
734 //
735 // The only available core OpenSimulator behaviour right now
736 // is not to store these textures, temporarily or otherwise.
737 m_log.DebugFormat( 737 m_log.DebugFormat(
738 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", 738 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
739 face.TextureID, idx, sp.Name); 739 face.TextureID, idx, sp.Name);