remove the option to store baked textures on assets service, thats suicide use xbakes

0.9.0-post-fixes
UbitUmarov 2017-05-31 04:47:59 +01:00
parent b1c585718c
commit 720a69a49b
4 changed files with 24 additions and 192 deletions

View File

@ -26,24 +26,12 @@
*/
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Drawing;
using System.Drawing.Imaging;
using System.Reflection;
using System.IO;
using System.Web;
using log4net;
using Nini.Config;
using OpenMetaverse;
using OpenMetaverse.StructuredData;
using OpenMetaverse.Imaging;
using OpenSim.Framework;
using OpenSim.Framework.Capabilities;
using OpenSim.Framework.Servers;
using OpenSim.Framework.Servers.HttpServer;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using Caps = OpenSim.Framework.Capabilities.Caps;
@ -56,13 +44,11 @@ namespace OpenSim.Capabilities.Handlers
private Caps m_HostCapsObj;
private IAssetService m_assetService;
private bool m_persistBakedTextures;
public UploadBakedTextureHandler(Caps caps, IAssetService assetService, bool persistBakedTextures)
public UploadBakedTextureHandler(Caps caps, IAssetService assetService)
{
m_HostCapsObj = caps;
m_assetService = assetService;
m_persistBakedTextures = persistBakedTextures;
}
/// <summary>
@ -125,9 +111,8 @@ namespace OpenSim.Capabilities.Handlers
asset = new AssetBase(assetID, "Baked Texture", (sbyte)AssetType.Texture, m_HostCapsObj.AgentID.ToString());
asset.Data = data;
asset.Temporary = true;
asset.Local = !m_persistBakedTextures; // Local assets aren't persisted, non-local are
asset.Local = false;
m_assetService.Store(asset);
}
}
@ -151,8 +136,6 @@ namespace OpenSim.Capabilities.Handlers
// m_log.InfoFormat("[CAPS] baked texture upload starting for {0}",newAssetID);
}
/// <summary>
/// Handle raw uploaded baked texture data.
/// </summary>

View File

@ -67,7 +67,7 @@ namespace OpenSim.Capabilities.Handlers
server.AddStreamHandler(new RestStreamHandler(
"POST",
"/CAPS/UploadBakedTexture/",
new UploadBakedTextureHandler(caps, m_AssetService, true).UploadBakedTexture,
new UploadBakedTextureHandler(caps, m_AssetService).UploadBakedTexture,
"UploadBakedTexture",
"Upload Baked Texture Capability"));

View File

@ -63,9 +63,7 @@ namespace OpenSim.Region.ClientStack.Linden
private static readonly string m_uploadBakedTexturePath = "0010/";// This is in the LandManagementModule.
private Scene m_scene;
private bool m_persistBakedTextures;
private IBakedTextureModule m_BakedTextureModule;
private string m_URL;
public void Initialise(IConfigSource source)
@ -76,15 +74,12 @@ namespace OpenSim.Region.ClientStack.Linden
m_URL = config.GetString("Cap_UploadBakedTexture", string.Empty);
IConfig appearanceConfig = source.Configs["Appearance"];
if (appearanceConfig != null)
m_persistBakedTextures = appearanceConfig.GetBoolean("PersistBakedTextures", m_persistBakedTextures);
// IConfig appearanceConfig = source.Configs["Appearance"];
}
public void AddRegion(Scene s)
{
m_scene = s;
}
public void RemoveRegion(Scene s)
@ -92,7 +87,6 @@ namespace OpenSim.Region.ClientStack.Linden
s.EventManager.OnRegisterCaps -= RegisterCaps;
s.EventManager.OnNewPresence -= RegisterNewPresence;
s.EventManager.OnRemovePresence -= DeRegisterPresence;
m_BakedTextureModule = null;
m_scene = null;
}
@ -101,7 +95,6 @@ namespace OpenSim.Region.ClientStack.Linden
m_scene.EventManager.OnRegisterCaps += RegisterCaps;
m_scene.EventManager.OnNewPresence += RegisterNewPresence;
m_scene.EventManager.OnRemovePresence += DeRegisterPresence;
}
private void DeRegisterPresence(UUID agentId)
@ -110,156 +103,12 @@ namespace OpenSim.Region.ClientStack.Linden
private void RegisterNewPresence(ScenePresence presence)
{
// presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
}
/* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache()
private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
{
// if cacheItems.Length > 0 viewer is giving us current textures information.
// baked ones should had been uploaded and in assets cache as local itens
if (cacheItems.Length == 0)
return; // no textures information, nothing to do
ScenePresence p = null;
if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
return; // what are we doing if there is no presence to cache for?
if (p.IsDeleted)
return; // does this really work?
int maxCacheitemsLoop = cacheItems.Length;
if (maxCacheitemsLoop > 20)
{
maxCacheitemsLoop = AvatarWearable.MAX_WEARABLES;
m_log.WarnFormat("[CACHEDBAKES]: Too Many Cache items Provided {0}, the max is {1}. Truncating!", cacheItems.Length, AvatarWearable.MAX_WEARABLES);
}
m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
// some nice debug
m_log.Debug("[Cacheitems]: " + cacheItems.Length);
for (int iter = 0; iter < maxCacheitemsLoop; iter++)
{
m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
cacheItems[iter].TextureID);
}
// p.Appearance.WearableCacheItems is in memory primary cashID to textures mapper
WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
if (existingitems == null)
{
if (m_BakedTextureModule != null)
{
WearableCacheItem[] savedcache = null;
try
{
if (p.Appearance.WearableCacheItemsDirty)
{
savedcache = m_BakedTextureModule.Get(p.UUID);
p.Appearance.WearableCacheItems = savedcache;
p.Appearance.WearableCacheItemsDirty = false;
}
}
catch (Exception)
{
// The service logs a sufficient error message.
}
if (savedcache != null)
existingitems = savedcache;
}
}
// Existing items null means it's a fully new appearance
if (existingitems == null)
{
for (int i = 0; i < maxCacheitemsLoop; i++)
{
if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
{
Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
if (face == null)
{
textureEntry.CreateFace(cacheItems[i].TextureIndex);
textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
AppearanceManager.DEFAULT_AVATAR_TEXTURE;
continue;
}
cacheItems[i].TextureID = face.TextureID;
if (m_scene.AssetService != null)
cacheItems[i].TextureAsset =
m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
}
else
{
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);
}
}
}
else
{
for (int i = 0; i < maxCacheitemsLoop; i++)
{
if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
{
Primitive.TextureEntryFace face = textureEntry.FaceTextures[cacheItems[i].TextureIndex];
if (face == null)
{
textureEntry.CreateFace(cacheItems[i].TextureIndex);
textureEntry.FaceTextures[cacheItems[i].TextureIndex].TextureID =
AppearanceManager.DEFAULT_AVATAR_TEXTURE;
continue;
}
cacheItems[i].TextureID =
face.TextureID;
}
else
{
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);
}
}
for (int i = 0; i < maxCacheitemsLoop; i++)
{
if (cacheItems[i].TextureAsset == null)
{
cacheItems[i].TextureAsset =
m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
}
}
}
p.Appearance.WearableCacheItems = cacheItems;
if (m_BakedTextureModule != null)
{
m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
p.Appearance.WearableCacheItemsDirty = true;
}
else
p.Appearance.WearableCacheItemsDirty = false;
for (int iter = 0; iter < maxCacheitemsLoop; iter++)
{
m_log.Debug("[CacheitemsLeaving] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" +
cacheItems[iter].TextureID);
}
}
*/
public void PostInitialise()
{
}
public void Close() { }
public string Name { get { return "UploadBakedTextureModule"; } }
@ -275,7 +124,7 @@ namespace OpenSim.Region.ClientStack.Linden
if (m_URL == "localhost")
{
UploadBakedTextureHandler avatarhandler = new UploadBakedTextureHandler(
caps, m_scene.AssetService, m_persistBakedTextures);
caps, m_scene.AssetService);
caps.RegisterHandler(
"UploadBakedTexture",

View File

@ -369,7 +369,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return true;
// uploaded baked textures will be in assets local cache
IAssetService cache = m_scene.AssetService;
IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
int validDirtyBakes = 0;
@ -436,7 +436,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
*/
wearableCache[idx].TextureAsset = null;
if (cache != null)
wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString());
{
AssetBase asb = null;
cache.Get(face.TextureID.ToString(), out asb);
wearableCache[idx].TextureAsset = asb;
}
if (wearableCache[idx].TextureAsset != null)
{
@ -481,15 +485,15 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// if we got a full set of baked textures save all in BakedTextureModule
if (m_BakedTextureModule != null)
{
m_log.Debug("[UpdateBakedCache] start async uploading to bakedModule cache");
m_log.DebugFormat("[UpdateBakedCache] Uploading to Bakes Server: cache hits: {0} changed entries: {1} rebakes {2}",
hits.ToString(), validDirtyBakes.ToString(), missing.Count);
m_BakedTextureModule.Store(sp.UUID, wearableCache);
}
}
// debug
m_log.Debug("[UpdateBakedCache] cache hits: " + hits.ToString() + " changed entries: " + validDirtyBakes.ToString() + " rebakes " + missing.Count);
else
m_log.DebugFormat("[UpdateBakedCache] cache hits: {0} changed entries: {1} rebakes {2}",
hits.ToString(), validDirtyBakes.ToString(), missing.Count);
/*
for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
{
@ -513,7 +517,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
lock (m_setAppearanceLock)
{
IAssetService cache = m_scene.AssetService;
IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
WearableCacheItem[] bakedModuleCache = null;
@ -553,6 +557,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
}
}
*/
bool wearableCacheValid = false;
if (wearableCache == null)
{
@ -577,10 +582,11 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
hits++;
wearableCache[idx].TextureAsset.Temporary = true;
wearableCache[idx].TextureAsset.Local = true;
cache.Store(wearableCache[idx].TextureAsset);
cache.Cache(wearableCache[idx].TextureAsset);
continue;
}
if (cache.GetCached((wearableCache[idx].TextureID).ToString()) != null)
if (cache.Check((wearableCache[idx].TextureID).ToString()))
{
hits++;
continue;
@ -645,7 +651,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
bakedModuleCache[i].TextureAsset.Temporary = true;
bakedModuleCache[i].TextureAsset.Local = true;
cache.Store(bakedModuleCache[i].TextureAsset);
cache.Cache(bakedModuleCache[i].TextureAsset);
}
}
gotbacked = true;
@ -706,7 +712,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
return 0;
int texturesRebaked = 0;
// IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
IAssetCache cache = m_scene.RequestModuleInterface<IAssetCache>();
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
@ -722,18 +728,12 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (missingTexturesOnly)
{
if (m_scene.AssetService.Get(face.TextureID.ToString()) != null)
if (cache != null && cache.Check(face.TextureID.ToString()))
{
continue;
}
else
{
// On inter-simulator teleports, this occurs if baked textures are not being stored by the
// grid asset service (which means that they are not available to the new region and so have
// to be re-requested from the client).
//
// The only available core OpenSimulator behaviour right now
// is not to store these textures, temporarily or otherwise.
m_log.DebugFormat(
"[AVFACTORY]: Missing baked texture {0} ({1}) for {2}, requesting rebake.",
face.TextureID, idx, sp.Name);