Fix baked textures for regions without external Xbakes adding rebake

requests. Those may also be trigger if for same reason one is missing even
with Xbakes. Later we can let this regions send the assets on teleports,
changing how those are serialized
avinationmerge
UbitUmarov 2014-10-29 06:35:23 +00:00
parent e4d84d8ff6
commit afa2466951
1 changed files with 35 additions and 32 deletions

View File

@ -202,14 +202,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// WriteBakedTexturesReport(sp, m_log.DebugFormat); // WriteBakedTexturesReport(sp, m_log.DebugFormat);
// If bake textures are missing and this is not an NPC, request a rebake from client
// rebake may messup caching, and should not be needed
// if (!UpdateBakedTextureCache(sp,cacheItems) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
// RequestRebake(sp, true);
UpdateBakedTextureCache(sp, cacheItems); UpdateBakedTextureCache(sp, cacheItems);
// This appears to be set only in the final stage of the appearance // This appears to be set only in the final stage of the appearance
@ -372,6 +364,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// uploaded baked textures will be in assets local cache // uploaded baked textures will be in assets local cache
IAssetService cache = m_scene.AssetService; IAssetService cache = m_scene.AssetService;
IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
int validDirtyBakes = 0; int validDirtyBakes = 0;
int hits = 0; int hits = 0;
@ -384,6 +377,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
wearableCache = WearableCacheItem.GetDefaultCacheItem(); wearableCache = WearableCacheItem.GetDefaultCacheItem();
} }
List<UUID> missing = new List<UUID>();
// Process received baked textures // Process received baked textures
for (int i = 0; i < cacheItems.Length; i++) for (int i = 0; i < cacheItems.Length; i++)
{ {
@ -411,7 +406,8 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
continue; continue;
} }
if(sp.Appearance.Texture.FaceTextures[idx].TextureID == wearableCache[idx].TextureID) /*
if (face.TextureID == wearableCache[idx].TextureID && m_BakedTextureModule != null)
{ {
if (wearableCache[idx].CacheId != cacheItems[i].CacheId) if (wearableCache[idx].CacheId != cacheItems[i].CacheId)
{ {
@ -423,6 +419,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
hits++; hits++;
continue; continue;
} }
*/
wearableCache[idx].TextureAsset = null; wearableCache[idx].TextureAsset = null;
if (cache != null) if (cache != null)
@ -431,7 +428,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (wearableCache[idx].TextureAsset != null) if (wearableCache[idx].TextureAsset != null)
{ {
wearableCache[idx].CacheId = cacheItems[i].CacheId; wearableCache[idx].CacheId = cacheItems[i].CacheId;
wearableCache[idx].TextureID = sp.Appearance.Texture.FaceTextures[idx].TextureID; wearableCache[idx].TextureID = face.TextureID;
validDirtyBakes++; validDirtyBakes++;
hits++; hits++;
} }
@ -440,6 +437,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
wearableCache[idx].CacheId = UUID.Zero; wearableCache[idx].CacheId = UUID.Zero;
wearableCache[idx].TextureID = UUID.Zero; wearableCache[idx].TextureID = UUID.Zero;
wearableCache[idx].TextureAsset = null; wearableCache[idx].TextureAsset = null;
missing.Add(face.TextureID);
continue; continue;
} }
} }
@ -451,7 +449,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (validDirtyBakes > 0 && hits == cacheItems.Length) if (validDirtyBakes > 0 && hits == cacheItems.Length)
{ {
IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
if (m_BakedTextureModule != null) if (m_BakedTextureModule != null)
{ {
m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache"); m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache");
@ -469,8 +466,14 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
} }
if(missing.Count > 0)
{
foreach(UUID id in missing)
sp.ControllingClient.SendRebakeAvatarTextures(id);
}
// debug // debug
m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString()); m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString() + " rebakes " + missing.Count);
/* /*
for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++) for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
{ {
@ -548,7 +551,10 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
{ {
int idx = AvatarAppearance.BAKE_INDICES[i]; int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
if (face != null && face.TextureID == wearableCache[idx].TextureID) if (face != null)
{
if (face.TextureID == wearableCache[idx].TextureID &&
face.TextureID != UUID.Zero)
{ {
if (wearableCache[idx].TextureAsset != null) if (wearableCache[idx].TextureAsset != null)
{ {
@ -556,17 +562,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
wearableCache[idx].TextureAsset.Temporary = true; wearableCache[idx].TextureAsset.Temporary = true;
wearableCache[idx].TextureAsset.Local = true; wearableCache[idx].TextureAsset.Local = true;
cache.Store(wearableCache[idx].TextureAsset); cache.Store(wearableCache[idx].TextureAsset);
continue;
} }
else if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null) if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null)
{ {
hits++; hits++;
continue;
}
} }
else
{
wearableCacheValid = false; wearableCacheValid = false;
break;
}
} }
} }
@ -623,7 +627,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
bakedModuleCache[i].TextureAsset.Temporary = true; bakedModuleCache[i].TextureAsset.Temporary = true;
bakedModuleCache[i].TextureAsset.Local = true; bakedModuleCache[i].TextureAsset.Local = true;
cache.Store(bakedModuleCache[i].TextureAsset); cache.Store(bakedModuleCache[i].TextureAsset);
} }
} }
gotbacked = true; gotbacked = true;