aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/CoreModules
diff options
context:
space:
mode:
authorteravus2012-12-19 11:53:26 -0500
committerteravus2012-12-19 11:53:26 -0500
commitc648325d7c761beb2ebe0edff3a70fdfbc81ffdb (patch)
tree831779e20f7c21037d2bfcb4dc1985412c364e6b /OpenSim/Region/CoreModules
parent* This is a better way to do the last commit. (diff)
parentAdd the interfaces for the new Avination baked texture cache service (diff)
downloadopensim-SC_OLD-c648325d7c761beb2ebe0edff3a70fdfbc81ffdb.zip
opensim-SC_OLD-c648325d7c761beb2ebe0edff3a70fdfbc81ffdb.tar.gz
opensim-SC_OLD-c648325d7c761beb2ebe0edff3a70fdfbc81ffdb.tar.bz2
opensim-SC_OLD-c648325d7c761beb2ebe0edff3a70fdfbc81ffdb.tar.xz
Merge branch 'avination' of careminster:/var/git/careminster into teravuswork
Diffstat (limited to 'OpenSim/Region/CoreModules')
-rw-r--r--OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs6
-rw-r--r--OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs4
-rw-r--r--OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs75
-rw-r--r--OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs5
-rw-r--r--OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs81
5 files changed, 155 insertions, 16 deletions
diff --git a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
index e40caec..f43305f 100644
--- a/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CenomeAssetCache.cs
@@ -194,6 +194,12 @@ namespace OpenSim.Region.CoreModules.Asset
194 194
195 #region IImprovedAssetCache Members 195 #region IImprovedAssetCache Members
196 196
197
198 public bool Check(string id)
199 {
200 return false;
201 }
202
197 /// <summary> 203 /// <summary>
198 /// Cache asset. 204 /// Cache asset.
199 /// </summary> 205 /// </summary>
diff --git a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
index 9742a5c..58ce61a 100644
--- a/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/CoreAssetCache.cs
@@ -112,6 +112,10 @@ namespace OpenSim.Region.CoreModules.Asset
112 //////////////////////////////////////////////////////////// 112 ////////////////////////////////////////////////////////////
113 // IImprovedAssetCache 113 // IImprovedAssetCache
114 // 114 //
115 public bool Check(string id)
116 {
117 return false;
118 }
115 119
116 public void Cache(AssetBase asset) 120 public void Cache(AssetBase asset)
117 { 121 {
diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
index b1bb56b..a0f1e8c 100644
--- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs
@@ -348,6 +348,17 @@ namespace OpenSim.Region.CoreModules.Asset
348 return asset; 348 return asset;
349 } 349 }
350 350
351 private bool CheckFromMemoryCache(string id)
352 {
353 AssetBase asset = null;
354
355 if (m_MemoryCache.TryGetValue(id, out asset))
356 return true;
357
358 return false;
359 }
360
361
351 /// <summary> 362 /// <summary>
352 /// Try to get an asset from the file cache. 363 /// Try to get an asset from the file cache.
353 /// </summary> 364 /// </summary>
@@ -420,6 +431,50 @@ namespace OpenSim.Region.CoreModules.Asset
420 return asset; 431 return asset;
421 } 432 }
422 433
434 private bool CheckFromFileCache(string id)
435 {
436 bool found = false;
437
438 string filename = GetFileName(id);
439 if (File.Exists(filename))
440 {
441 // actually check if we can open it, and so update expire
442 FileStream stream = null;
443 try
444 {
445 stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
446 if (stream != null)
447 {
448 found = true;
449 stream.Close();
450 }
451
452 }
453 catch (System.Runtime.Serialization.SerializationException e)
454 {
455 found = false;
456 m_log.ErrorFormat(
457 "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
458 filename, id, e.Message, e.StackTrace);
459
460 // If there was a problem deserializing the asset, the asset may
461 // either be corrupted OR was serialized under an old format
462 // {different version of AssetBase} -- we should attempt to
463 // delete it and re-cache
464 File.Delete(filename);
465 }
466 catch (Exception e)
467 {
468 found = false;
469 m_log.ErrorFormat(
470 "[FLOTSAM ASSET CACHE]: Failed to check file {0} for asset {1}. Exception {2} {3}",
471 filename, id, e.Message, e.StackTrace);
472 }
473 }
474
475 return found;
476 }
477
423 public AssetBase Get(string id) 478 public AssetBase Get(string id)
424 { 479 {
425 m_Requests++; 480 m_Requests++;
@@ -456,11 +511,26 @@ namespace OpenSim.Region.CoreModules.Asset
456 return asset; 511 return asset;
457 } 512 }
458 513
514 public bool Check(string id)
515 {
516 if (m_MemoryCacheEnabled && CheckFromMemoryCache(id))
517 return true;
518
519 if (m_FileCacheEnabled && CheckFromFileCache(id))
520 return true;
521 return false;
522 }
523
459 public AssetBase GetCached(string id) 524 public AssetBase GetCached(string id)
460 { 525 {
461 return Get(id); 526 return Get(id);
462 } 527 }
463 528
529 public AssetBase CheckCached(string id)
530 {
531 return Get(id);
532 }
533
464 public void Expire(string id) 534 public void Expire(string id)
465 { 535 {
466 if (m_LogLevel >= 2) 536 if (m_LogLevel >= 2)
@@ -941,6 +1011,11 @@ namespace OpenSim.Region.CoreModules.Asset
941 return asset.Data; 1011 return asset.Data;
942 } 1012 }
943 1013
1014 public bool CheckData(string id)
1015 {
1016 return Check(id); ;
1017 }
1018
944 public bool Get(string id, object sender, AssetRetrieved handler) 1019 public bool Get(string id, object sender, AssetRetrieved handler)
945 { 1020 {
946 AssetBase asset = Get(id); 1021 AssetBase asset = Get(id);
diff --git a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
index 9592ca0..ce9b546 100644
--- a/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
+++ b/OpenSim/Region/CoreModules/Asset/GlynnTuckerAssetCache.cs
@@ -115,6 +115,11 @@ namespace OpenSim.Region.CoreModules.Asset
115 // IImprovedAssetCache 115 // IImprovedAssetCache
116 // 116 //
117 117
118 public bool Check(string id)
119 {
120 return false;
121 }
122
118 public void Cache(AssetBase asset) 123 public void Cache(AssetBase asset)
119 { 124 {
120 if (asset != null) 125 if (asset != null)
diff --git a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
index 8496005..3532b1d 100644
--- a/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
+++ b/OpenSim/Region/CoreModules/Avatar/AvatarFactory/AvatarFactoryModule.cs
@@ -145,6 +145,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
145 SetAppearance(sp, appearance.Texture, appearance.VisualParams); 145 SetAppearance(sp, appearance.Texture, appearance.VisualParams);
146 } 146 }
147 147
148
149 public void SetAppearance(IScenePresence sp, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize)
150 {
151 float oldoff = sp.Appearance.AvatarFeetOffset;
152 Vector3 oldbox = sp.Appearance.AvatarBoxSize;
153
154 SetAppearance(sp, textureEntry, visualParams);
155 sp.Appearance.SetSize(avSize);
156
157 float off = sp.Appearance.AvatarFeetOffset;
158 Vector3 box = sp.Appearance.AvatarBoxSize;
159 if (oldoff != off || oldbox != box)
160 ((ScenePresence)sp).SetSize(box, off);
161 }
162
148 /// <summary> 163 /// <summary>
149 /// Set appearance data (texture asset IDs and slider settings) 164 /// Set appearance data (texture asset IDs and slider settings)
150 /// </summary> 165 /// </summary>
@@ -174,12 +189,21 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
174 // m_log.DebugFormat( 189 // m_log.DebugFormat(
175 // "[AVFACTORY]: Setting visual params for {0} to {1}", 190 // "[AVFACTORY]: Setting visual params for {0} to {1}",
176 // client.Name, string.Join(", ", visualParamsStrings)); 191 // client.Name, string.Join(", ", visualParamsStrings));
177 192/*
178 float oldHeight = sp.Appearance.AvatarHeight; 193 float oldHeight = sp.Appearance.AvatarHeight;
179 changed = sp.Appearance.SetVisualParams(visualParams); 194 changed = sp.Appearance.SetVisualParams(visualParams);
180 195
181 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0) 196 if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
182 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight); 197 ((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
198 */
199// float oldoff = sp.Appearance.AvatarFeetOffset;
200// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
201 changed = sp.Appearance.SetVisualParams(visualParams);
202// float off = sp.Appearance.AvatarFeetOffset;
203// Vector3 box = sp.Appearance.AvatarBoxSize;
204// if(oldoff != off || oldbox != box)
205// ((ScenePresence)sp).SetSize(box,off);
206
183 } 207 }
184 208
185 // Process the baked texture array 209 // Process the baked texture array
@@ -337,6 +361,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
337 public bool ValidateBakedTextureCache(IScenePresence sp) 361 public bool ValidateBakedTextureCache(IScenePresence sp)
338 { 362 {
339 bool defonly = true; // are we only using default textures 363 bool defonly = true; // are we only using default textures
364 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
340 365
341 // Process the texture entry 366 // Process the texture entry
342 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 367 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
@@ -361,8 +386,16 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
361 386
362 defonly = false; // found a non-default texture reference 387 defonly = false; // found a non-default texture reference
363 388
364 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) 389 if (cache != null)
365 return false; 390 {
391 if (!cache.Check(face.TextureID.ToString()))
392 return false;
393 }
394 else
395 {
396 if (m_scene.AssetService.Get(face.TextureID.ToString()) == null)
397 return false;
398 }
366 } 399 }
367 400
368// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); 401// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID);
@@ -374,6 +407,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
374 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) 407 public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
375 { 408 {
376 int texturesRebaked = 0; 409 int texturesRebaked = 0;
410 IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
377 411
378 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) 412 for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
379 { 413 {
@@ -397,21 +431,36 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
397 431
398 if (missingTexturesOnly) 432 if (missingTexturesOnly)
399 { 433 {
400 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null) 434 if (cache != null)
401 { 435 {
402 continue; 436 if (cache.Check(face.TextureID.ToString()))
437 continue;
438 else
439 {
440 m_log.DebugFormat(
441 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
442 face.TextureID, idx, sp.Name);
443 }
403 } 444 }
404 else 445 else
405 { 446 {
406 // On inter-simulator teleports, this occurs if baked textures are not being stored by the 447 if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
407 // grid asset service (which means that they are not available to the new region and so have 448 {
408 // to be re-requested from the client). 449 continue;
409 // 450 }
410 // The only available core OpenSimulator behaviour right now 451
411 // is not to store these textures, temporarily or otherwise. 452 else
412 m_log.DebugFormat( 453 {
413 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.", 454 // On inter-simulator teleports, this occurs if baked textures are not being stored by the
414 face.TextureID, idx, sp.Name); 455 // grid asset service (which means that they are not available to the new region and so have
456 // to be re-requested from the client).
457 //
458 // The only available core OpenSimulator behaviour right now
459 // is not to store these textures, temporarily or otherwise.
460 m_log.DebugFormat(
461 "[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
462 face.TextureID, idx, sp.Name);
463 }
415 } 464 }
416 } 465 }
417 else 466 else
@@ -611,12 +660,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
611 /// <param name="client"></param> 660 /// <param name="client"></param>
612 /// <param name="texture"></param> 661 /// <param name="texture"></param>
613 /// <param name="visualParam"></param> 662 /// <param name="visualParam"></param>
614 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams) 663 private void Client_OnSetAppearance(IClientAPI client, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize)
615 { 664 {
616 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId); 665 // m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance called for {0} ({1})", client.Name, client.AgentId);
617 ScenePresence sp = m_scene.GetScenePresence(client.AgentId); 666 ScenePresence sp = m_scene.GetScenePresence(client.AgentId);
618 if (sp != null) 667 if (sp != null)
619 SetAppearance(sp, textureEntry, visualParams); 668 SetAppearance(sp, textureEntry, visualParams,avSize);
620 else 669 else
621 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId); 670 m_log.WarnFormat("[AVFACTORY]: Client_OnSetAppearance unable to find presence for {0}", client.AgentId);
622 } 671 }