Merge branch 'ubitworkmaster'

avinationmerge
Melanie Thielker 2014-08-07 16:55:00 +02:00
commit a06d66b70b
12 changed files with 982 additions and 924 deletions

View File

@ -2942,7 +2942,7 @@ namespace OpenSim.ApplicationPlugins.RemoteController
/// </summary> /// </summary>
private void ApplyNextOwnerPermissions(InventoryItemBase item) private void ApplyNextOwnerPermissions(InventoryItemBase item)
{ {
if (item.InvType == (int)InventoryType.Object) if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0)
{ {
uint perms = item.CurrentPermissions; uint perms = item.CurrentPermissions;
PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms);

View File

@ -72,8 +72,8 @@ namespace OpenSim.Framework
/// <param name="mainPerms">The permissions variable to modify.</param> /// <param name="mainPerms">The permissions variable to modify.</param>
public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms)
{ {
if ((foldedPerms & 7) == 0) // if ((foldedPerms & 7) == 0)
return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded // return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded
if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0)
mainPerms &= ~(uint)PermissionMask.Copy; mainPerms &= ~(uint)PermissionMask.Copy;

View File

@ -46,7 +46,7 @@ namespace OpenSim.Framework
int itemmax = 21; int itemmax = 21;
WearableCacheItem[] retitems = new WearableCacheItem[itemmax]; WearableCacheItem[] retitems = new WearableCacheItem[itemmax];
for (uint i=0;i<itemmax;i++) for (uint i=0;i<itemmax;i++)
retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i + 1}; retitems[i] = new WearableCacheItem() {CacheId = UUID.Zero, TextureID = UUID.Zero, TextureIndex = i};
return retitems; return retitems;
} }
public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache) public static WearableCacheItem[] FromOSD(OSD pInput, IImprovedAssetCache dataCache)

View File

@ -96,9 +96,7 @@ namespace OpenSim.Region.ClientStack.Linden
s.EventManager.OnRemovePresence -= DeRegisterPresence; s.EventManager.OnRemovePresence -= DeRegisterPresence;
m_BakedTextureModule = null; m_BakedTextureModule = null;
m_scene = null; m_scene = null;
} }
public void RegionLoaded(Scene s) public void RegionLoaded(Scene s)
{ {
@ -110,44 +108,58 @@ namespace OpenSim.Region.ClientStack.Linden
private void DeRegisterPresence(UUID agentId) private void DeRegisterPresence(UUID agentId)
{ {
ScenePresence presence = null; // ScenePresence presence = null;
if (m_scene.TryGetScenePresence(agentId, out presence)) // if (m_scene.TryGetScenePresence(agentId, out presence))
{ {
presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings; // presence.ControllingClient.OnSetAppearance -= CaptureAppearanceSettings;
} }
} }
private void RegisterNewPresence(ScenePresence presence) private void RegisterNewPresence(ScenePresence presence)
{ {
presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings; // presence.ControllingClient.OnSetAppearance += CaptureAppearanceSettings;
} }
private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems) /* not in use. work done in AvatarFactoryModule ValidateBakedTextureCache() and UpdateBakedTextureCache()
{ private void CaptureAppearanceSettings(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 avSize, WearableCacheItem[] cacheItems)
int maxCacheitemsLoop = cacheItems.Length; {
if (maxCacheitemsLoop > AvatarWearable.MAX_WEARABLES) // if cacheItems.Length > 0 viewer is giving us current textures information.
{ // baked ones should had been uploaded and in assets cache as local itens
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>();
if (cacheItems.Length > 0) if (cacheItems.Length == 0)
{ return; // no textures information, nothing to do
m_log.Debug("[Cacheitems]: " + cacheItems.Length);
for (int iter = 0; iter < maxCacheitemsLoop; iter++) ScenePresence p = null;
{ if (!m_scene.TryGetScenePresence(remoteClient.AgentId, out p))
m_log.Debug("[Cacheitems] {" + iter + "/" + cacheItems[iter].TextureIndex + "}: c-" + cacheItems[iter].CacheId + ", t-" + return; // what are we doing if there is no presence to cache for?
cacheItems[iter].TextureID);
} if (p.IsDeleted)
return; // does this really work?
ScenePresence p = null;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out p)) 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; WearableCacheItem[] existingitems = p.Appearance.WearableCacheItems;
if (existingitems == null) if (existingitems == null)
{ {
if (m_BakedTextureModule != null) if (m_BakedTextureModule != null)
@ -161,38 +173,22 @@ namespace OpenSim.Region.ClientStack.Linden
p.Appearance.WearableCacheItems = savedcache; p.Appearance.WearableCacheItems = savedcache;
p.Appearance.WearableCacheItemsDirty = false; p.Appearance.WearableCacheItemsDirty = false;
} }
}
}
/*
* The following Catch types DO NOT WORK with m_BakedTextureModule.Get
* it jumps to the General Packet Exception Handler if you don't catch Exception!
*
catch (System.Net.Sockets.SocketException)
{
cacheItems = null;
}
catch (WebException)
{
cacheItems = null;
}
catch (InvalidOperationException)
{
cacheItems = null;
} */
catch (Exception) catch (Exception)
{ {
// The service logs a sufficient error message. // The service logs a sufficient error message.
} }
if (savedcache != null) if (savedcache != null)
existingitems = savedcache; existingitems = savedcache;
} }
} }
// Existing items null means it's a fully new appearance // Existing items null means it's a fully new appearance
if (existingitems == null) if (existingitems == null)
{ {
for (int i = 0; i < maxCacheitemsLoop; i++) for (int i = 0; i < maxCacheitemsLoop; i++)
{ {
if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@ -205,7 +201,7 @@ namespace OpenSim.Region.ClientStack.Linden
AppearanceManager.DEFAULT_AVATAR_TEXTURE; AppearanceManager.DEFAULT_AVATAR_TEXTURE;
continue; continue;
} }
cacheItems[i].TextureID =face.TextureID; cacheItems[i].TextureID = face.TextureID;
if (m_scene.AssetService != null) if (m_scene.AssetService != null)
cacheItems[i].TextureAsset = cacheItems[i].TextureAsset =
m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString()); m_scene.AssetService.GetCached(cacheItems[i].TextureID.ToString());
@ -214,15 +210,10 @@ namespace OpenSim.Region.ClientStack.Linden
{ {
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); 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 else
{
{
// for each uploaded baked texture
for (int i = 0; i < maxCacheitemsLoop; i++) for (int i = 0; i < maxCacheitemsLoop; i++)
{ {
if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex) if (textureEntry.FaceTextures.Length > cacheItems[i].TextureIndex)
@ -253,23 +244,24 @@ namespace OpenSim.Region.ClientStack.Linden
} }
} }
} }
p.Appearance.WearableCacheItems = cacheItems; p.Appearance.WearableCacheItems = cacheItems;
if (m_BakedTextureModule != null) if (m_BakedTextureModule != null)
{ {
m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems); m_BakedTextureModule.Store(remoteClient.AgentId, cacheItems);
p.Appearance.WearableCacheItemsDirty = true; 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 PostInitialise()
{ {
} }

View File

@ -3684,6 +3684,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
avp.Sender.IsTrial = false; avp.Sender.IsTrial = false;
avp.Sender.ID = agentID; avp.Sender.ID = agentID;
avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
// this need be use in future
// avp.AppearanceData[0].AppearanceVersion = 0;
// avp.AppearanceData[0].CofVersion = 0;
//m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
OutPacket(avp, ThrottleOutPacketType.Task); OutPacket(avp, ThrottleOutPacketType.Task);
} }
@ -6535,7 +6540,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length]; WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
for (int i=0; i<appear.WearableData.Length;i++) for (int i=0; i<appear.WearableData.Length;i++)
cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)}; cacheitems[i] = new WearableCacheItem(){
CacheId = appear.WearableData[i].CacheID,
TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)
};
@ -12004,150 +12012,65 @@ namespace OpenSim.Region.ClientStack.LindenUDP
if (cachedtex.AgentData.SessionID != SessionId) if (cachedtex.AgentData.SessionID != SessionId)
return false; return false;
// TODO: don't create new blocks if recycling an old packet // TODO: don't create new blocks if recycling an old packet
cachedresp.AgentData.AgentID = AgentId; cachedresp.AgentData.AgentID = AgentId;
cachedresp.AgentData.SessionID = m_sessionId; cachedresp.AgentData.SessionID = m_sessionId;
cachedresp.AgentData.SerialNum = m_cachedTextureSerial; cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum;
m_cachedTextureSerial++;
cachedresp.WearableData = cachedresp.WearableData =
new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
//IAvatarFactoryModule fac = m_scene.RequestModuleInterface<IAvatarFactoryModule>();
// var item = fac.GetBakedTextureFaces(AgentId);
//WearableCacheItem[] items = fac.GetCachedItems(AgentId);
IAssetService cache = m_scene.AssetService;
IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
//bakedTextureModule = null;
int maxWearablesLoop = cachedtex.WearableData.Length; int maxWearablesLoop = cachedtex.WearableData.Length;
if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
maxWearablesLoop = AvatarWearable.MAX_WEARABLES; maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
if (bakedTextureModule != null && cache != null) int cacheHits = 0;
// We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
WearableCacheItem[] cacheItems = null;
ScenePresence p = m_scene.GetScenePresence(AgentId);
if (p != null && p.Appearance != null)
{ {
// We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid cacheItems = p.Appearance.WearableCacheItems;
}
WearableCacheItem[] cacheItems = null; if (cacheItems != null)
ScenePresence p = m_scene.GetScenePresence(AgentId); {
if (p.Appearance != null) for (int i = 0; i < maxWearablesLoop; i++)
if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
{
try
{
cacheItems = bakedTextureModule.Get(AgentId);
p.Appearance.WearableCacheItems = cacheItems;
p.Appearance.WearableCacheItemsDirty = false;
}
/*
* The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception!
*
catch (System.Net.Sockets.SocketException)
{
cacheItems = null;
}
catch (WebException)
{
cacheItems = null;
}
catch (InvalidOperationException)
{
cacheItems = null;
} */
catch (Exception)
{
cacheItems = null;
}
}
else if (p.Appearance.WearableCacheItems != null)
{
cacheItems = p.Appearance.WearableCacheItems;
}
if (cache != null && cacheItems != null)
{ {
foreach (WearableCacheItem item in cacheItems) int idx = cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i].HostName = new byte[0];
if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
{ {
cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
if (cache.GetCached(item.TextureID.ToString()) == null) cacheHits++;
{
item.TextureAsset.Temporary = true;
cache.Store(item.TextureAsset);
}
} }
} else
if (cacheItems != null)
{
for (int i = 0; i < maxWearablesLoop; i++)
{ {
WearableCacheItem item =
WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i].HostName = new byte[0];
if (item != null && cachedtex.WearableData[i].ID == item.CacheId)
{
cachedresp.WearableData[i].TextureID = item.TextureID;
}
else
{
cachedresp.WearableData[i].TextureID = UUID.Zero;
}
}
}
else
{
for (int i = 0; i < maxWearablesLoop; i++)
{
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i].TextureID = UUID.Zero; cachedresp.WearableData[i].TextureID = UUID.Zero;
//UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].HostName = new byte[0];
} }
} }
} }
else else
{ {
if (cache == null) for (int i = 0; i < maxWearablesLoop; i++)
{ {
for (int i = 0; i < maxWearablesLoop; i++) cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
{ cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); cachedresp.WearableData[i].TextureID = UUID.Zero;
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].TextureID = UUID.Zero; cachedresp.WearableData[i].HostName = new byte[0];
//UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].HostName = new byte[0];
}
}
else
{
for (int i = 0; i < maxWearablesLoop; i++)
{
cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
cachedresp.WearableData[i].TextureID = UUID.Zero;
//UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
else
cachedresp.WearableData[i].TextureID = UUID.Zero;
// UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
cachedresp.WearableData[i].HostName = new byte[0];
}
} }
} }
m_log.DebugFormat("texture cached: hits {0}", cacheHits);
cachedresp.Header.Zerocoded = true; cachedresp.Header.Zerocoded = true;
OutPacket(cachedresp, ThrottleOutPacketType.Task); OutPacket(cachedresp, ThrottleOutPacketType.Task);

View File

@ -1750,25 +1750,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
endPoint, endPoint,
sessionInfo); sessionInfo);
// Send ack straight away to let the viewer know that the connection is active.
// The client will be null if it already exists (e.g. if on a region crossing the client sends a use
// circuit code to the existing child agent. This is not particularly obvious.
SendAckImmediate(endPoint, uccp.Header.Sequence);
// We only want to send initial data to new clients, not ones which are being converted from child to root.
if (client != null)
{
AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
bool tp = (aCircuit.teleportFlags > 0);
// Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
if (!tp)
client.SceneAgent.SendInitialDataToMe();
}
// Now we know we can handle more data // Now we know we can handle more data
Thread.Sleep(200); // Thread.Sleep(200);
// Obtain the queue and remove it from the cache // Obtain the pending queue and remove it from the cache
Queue<UDPPacketBuffer> queue = null; Queue<UDPPacketBuffer> queue = null;
lock (m_pendingCache) lock (m_pendingCache)
@ -1790,6 +1775,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
PacketReceived(buf); PacketReceived(buf);
} }
queue = null; queue = null;
// Send ack straight away to let the viewer know that the connection is active.
// The client will be null if it already exists (e.g. if on a region crossing the client sends a use
// circuit code to the existing child agent. This is not particularly obvious.
SendAckImmediate(endPoint, uccp.Header.Sequence);
// We only want to send initial data to new clients, not ones which are being converted from child to root.
if (client != null)
{
AgentCircuitData aCircuit = m_scene.AuthenticateHandler.GetAgentCircuitData(uccp.CircuitCode.Code);
bool tp = (aCircuit.teleportFlags > 0);
// Let's delay this for TP agents, otherwise the viewer doesn't know where to get resources from
if (!tp)
client.SceneAgent.SendInitialDataToMe();
}
} }
else else
{ {

View File

@ -188,27 +188,7 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
// Process the visual params, this may change height as well // Process the visual params, this may change height as well
if (visualParams != null) if (visualParams != null)
{ {
// string[] visualParamsStrings = new string[visualParams.Length];
// for (int i = 0; i < visualParams.Length; i++)
// visualParamsStrings[i] = visualParams[i].ToString();
// m_log.DebugFormat(
// "[AVFACTORY]: Setting visual params for {0} to {1}",
// client.Name, string.Join(", ", visualParamsStrings));
/*
float oldHeight = sp.Appearance.AvatarHeight;
changed = sp.Appearance.SetVisualParams(visualParams); changed = sp.Appearance.SetVisualParams(visualParams);
if (sp.Appearance.AvatarHeight != oldHeight && sp.Appearance.AvatarHeight > 0)
((ScenePresence)sp).SetHeight(sp.Appearance.AvatarHeight);
*/
// float oldoff = sp.Appearance.AvatarFeetOffset;
// Vector3 oldbox = sp.Appearance.AvatarBoxSize;
changed = sp.Appearance.SetVisualParams(visualParams);
// float off = sp.Appearance.AvatarFeetOffset;
// Vector3 box = sp.Appearance.AvatarBoxSize;
// if(oldoff != off || oldbox != box)
// ((ScenePresence)sp).SetSize(box,off);
} }
// Process the baked texture array // Process the baked texture array
@ -222,9 +202,15 @@ 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 // If bake textures are missing and this is not an NPC, request a rebake from client
if (!ValidateBakedTextureCache(sp) && (((ScenePresence)sp).PresenceType != PresenceType.Npc)) // rebake may messup caching, and should not be needed
RequestRebake(sp, true);
// if (!UpdateBakedTextureCache(sp,cacheItems) && (((ScenePresence)sp).PresenceType != PresenceType.Npc))
// RequestRebake(sp, true);
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
// update transaction. In theory, we should be able to do an immediate // update transaction. In theory, we should be able to do an immediate
@ -377,121 +363,243 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
} }
} }
public bool ValidateBakedTextureCache(IScenePresence sp) // called on textures update
public bool UpdateBakedTextureCache(IScenePresence sp, WearableCacheItem[] cacheItems)
{ {
bool defonly = true; // are we only using default textures bool defonly = true; // are we only using default textures
IImprovedAssetCache cache = m_scene.RequestModuleInterface<IImprovedAssetCache>();
IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
WearableCacheItem[] wearableCache = null;
// Cache wearable data for teleport. // uploaded baked textures will be in assets local cache
// Only makes sense if there's a bake module and a cache module IAssetService cache = m_scene.AssetService;
if (bakedModule != null && cache != null)
int validDirtyBakes = 0;
int hits = 0;
// our main cacheIDs mapper is p.Appearance.WearableCacheItems
WearableCacheItem[] wearableCache = sp.Appearance.WearableCacheItems;
if (wearableCache == null)
{ {
try wearableCache = WearableCacheItem.GetDefaultCacheItem();
{
wearableCache = bakedModule.Get(sp.UUID);
}
catch (Exception)
{
}
if (wearableCache != null)
{
for (int i = 0; i < wearableCache.Length; i++)
{
cache.Cache(wearableCache[i].TextureAsset);
}
}
} }
/*
IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
if (invService.GetRootFolder(userID) != null)
{
WearableCacheItem[] wearableCache = null;
if (bakedModule != null)
{
try
{
wearableCache = bakedModule.Get(userID);
appearance.WearableCacheItems = wearableCache;
appearance.WearableCacheItemsDirty = false;
foreach (WearableCacheItem item in wearableCache)
{
appearance.Texture.FaceTextures[item.TextureIndex].TextureID = item.TextureID;
}
}
catch (Exception)
{
}
}
*/
// Process the texture entry // Process received baked textures
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++) for (int i = 0; i < cacheItems.Length; i++)
{ {
int idx = AvatarAppearance.BAKE_INDICES[i]; int idx = (int)cacheItems[i].TextureIndex;
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx]; Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
// No face, so lets check our baked service cache, teleport or login. // No face
if (face == null) if (face == null)
{ {
if (wearableCache != null) // for some reason viewer is cleaning this
{ sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
// If we find the an appearance item, set it as the textureentry and the face sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
WearableCacheItem searchitem = WearableCacheItem.SearchTextureIndex((uint) idx, wearableCache); wearableCache[idx].CacheId = UUID.Zero;
if (searchitem != null) wearableCache[idx].TextureID = UUID.Zero;
{ wearableCache[idx].TextureAsset = null;
sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint) idx);
sp.Appearance.Texture.FaceTextures[idx].TextureID = searchitem.TextureID;
face = sp.Appearance.Texture.FaceTextures[idx];
}
else
{
// if there is no texture entry and no baked cache, skip it
continue;
}
}
else
{
//No texture entry face and no cache. Skip this face.
continue;
}
}
// m_log.DebugFormat(
// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
// face.TextureID, idx, client.Name, client.AgentId);
// if the texture is one of the "defaults" then skip it
// this should probably be more intelligent (skirt texture doesnt matter
// if the avatar isnt wearing a skirt) but if any of the main baked
// textures is default then the rest should be as well
if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
continue; continue;
defonly = false; // found a non-default texture reference
if (cache != null)
{
if (!cache.Check(face.TextureID.ToString()))
return false;
} }
else else
{ {
if (m_scene.AssetService.Get(face.TextureID.ToString()) == null) if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
return false; {
wearableCache[idx].CacheId = UUID.Zero;
wearableCache[idx].TextureID = UUID.Zero;
wearableCache[idx].TextureAsset = null;
continue;
}
defonly = false; // found a non-default texture reference
if(sp.Appearance.Texture.FaceTextures[idx].TextureID == wearableCache[idx].TextureID)
{
if(wearableCache[idx].CacheId != cacheItems[i].CacheId)
{
wearableCache[idx].CacheId = cacheItems[i].CacheId;
validDirtyBakes++;
hits++;
//assuming this can only happen if asset is in cache
}
continue;
}
wearableCache[idx].TextureAsset = null;
if (cache != null)
wearableCache[idx].TextureAsset = cache.GetCached(face.TextureID.ToString());
if (wearableCache[idx].TextureAsset != null)
{
wearableCache[idx].CacheId = cacheItems[i].CacheId;
wearableCache[idx].TextureID = sp.Appearance.Texture.FaceTextures[idx].TextureID;
validDirtyBakes++;
hits++;
}
else
{
wearableCache[idx].CacheId = UUID.Zero;
wearableCache[idx].TextureID = UUID.Zero;
wearableCache[idx].TextureAsset = null;
continue;
}
} }
} }
// m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1}", sp.Name, sp.UUID); sp.Appearance.WearableCacheItems = wearableCache;
// if we got a full set of baked textures save all in BakedTextureModule
if (validDirtyBakes == cacheItems.Length)
{
IBakedTextureModule m_BakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
if (m_BakedTextureModule != null)
{
m_log.Debug("[UpdateBakedCache] uploading to bakedModule cache");
WearableCacheItem[] toBakedModule = new WearableCacheItem[AvatarAppearance.BAKE_INDICES.Length];
for (int i = 0; i < cacheItems.Length; i++)
{
int idx = (int)cacheItems[i].TextureIndex;
cacheItems[i].CacheId = wearableCache[idx].CacheId;
cacheItems[i].TextureID = wearableCache[idx].TextureID;
cacheItems[i].TextureAsset = wearableCache[idx].TextureAsset;
}
m_BakedTextureModule.Store(sp.UUID, cacheItems);
}
}
// debug
for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
{
int j = AvatarAppearance.BAKE_INDICES[iter];
m_log.Debug("[UpdateBCache] {" + iter + "/" +
sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
sp.Appearance.WearableCacheItems[j].TextureID);
}
// If we only found default textures, then the appearance is not cached // If we only found default textures, then the appearance is not cached
return (defonly ? false : true); return (defonly ? false : true);
} }
// called when we get a new root avatar
public bool ValidateBakedTextureCache(IScenePresence sp)
{
bool defonly = true; // are we only using default textures
IAssetService cache = m_scene.AssetService;
IBakedTextureModule bakedModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
WearableCacheItem[] wearableCache = null;
WearableCacheItem[] bakedModuleCache = null;
wearableCache = WearableCacheItem.GetDefaultCacheItem();
int hits = 0;
// Cache wearable data for teleport.
// Only makes sense if there's a bake module and a cache module
if (bakedModule != null && cache != null)
{
m_log.Debug("[ValidateBakedCache] calling bakedModule");
try
{
bakedModuleCache = bakedModule.Get(sp.UUID);
}
catch (Exception)
{
bakedModuleCache = null;
}
if (bakedModuleCache != null)
{
m_log.Debug("[ValidateBakedCache] got bakedModule cache " + bakedModuleCache.Length);
for (int i = 0; i < bakedModuleCache.Length; i++)
{
int j = (int)bakedModuleCache[i].TextureIndex;
if (bakedModuleCache[i].TextureAsset != null)
{
wearableCache[j].TextureID = bakedModuleCache[i].TextureID;
wearableCache[j].CacheId = bakedModuleCache[i].CacheId;
wearableCache[j].TextureAsset = bakedModuleCache[i].TextureAsset;
bakedModuleCache[i].TextureAsset.Temporary = true;
bakedModuleCache[i].TextureAsset.Local = true;
cache.Store(bakedModuleCache[i].TextureAsset);
}
}
}
}
// Process the baked textures
for (int i = 0; i < AvatarAppearance.BAKE_INDICES.Length; i++)
{
int idx = AvatarAppearance.BAKE_INDICES[i];
Primitive.TextureEntryFace face = sp.Appearance.Texture.FaceTextures[idx];
// No face, so lets check our cache
if (face == null || face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
{
sp.Appearance.Texture.FaceTextures[idx] = sp.Appearance.Texture.CreateFace((uint)idx);
if (wearableCache[idx].TextureID != UUID.Zero)
{
sp.Appearance.Texture.FaceTextures[idx].TextureID = wearableCache[idx].TextureID;
face = sp.Appearance.Texture.FaceTextures[idx];
// let run to end of loop to check cache
}
else
{
sp.Appearance.Texture.FaceTextures[idx].TextureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
face = sp.Appearance.Texture.FaceTextures[idx];
// lets try not invalidating the cache entry
// wearableCache[idx].CacheId = UUID.Zero;
// wearableCache[idx].TextureAsset = null;
continue;
}
}
if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
{
defonly = false; // found a non-default texture reference
continue;
}
if(wearableCache[idx].TextureID != face.TextureID)
{
wearableCache[idx].CacheId = UUID.Zero;
wearableCache[idx].TextureID = UUID.Zero;
wearableCache[idx].TextureAsset = null;
continue;
}
wearableCache[idx].TextureAsset = null;
if (cache != null)
{
wearableCache[idx].TextureAsset = m_scene.AssetService.Get(face.TextureID.ToString());
if (wearableCache[idx].TextureAsset == null)
{
wearableCache[idx].CacheId = UUID.Zero;
wearableCache[idx].TextureID = UUID.Zero;
}
else
hits++;
}
}
sp.Appearance.WearableCacheItems = wearableCache;
m_log.DebugFormat("[AVFACTORY]: Completed texture check for {0} {1} {2} {3}", sp.Name, sp.UUID, hits, defonly.ToString());
// debug
for (int iter = 0; iter < AvatarAppearance.BAKE_INDICES.Length; iter++)
{
int j = AvatarAppearance.BAKE_INDICES[iter];
m_log.Debug("[ValidateBakedCache] {" + iter + "/" +
sp.Appearance.WearableCacheItems[j].TextureIndex + "}: c-" +
sp.Appearance.WearableCacheItems[j].CacheId + ", t-" +
sp.Appearance.WearableCacheItems[j].TextureID);
}
// If we only found default textures, then the appearance is not cached
return (defonly ? false : true);
}
public int RequestRebake(IScenePresence sp, bool missingTexturesOnly) public int RequestRebake(IScenePresence sp, bool missingTexturesOnly)
{ {
int texturesRebaked = 0; int texturesRebaked = 0;
@ -506,14 +614,6 @@ namespace OpenSim.Region.CoreModules.Avatar.AvatarFactory
if (face == null) if (face == null)
continue; continue;
// m_log.DebugFormat(
// "[AVFACTORY]: Looking for texture {0}, id {1} for {2} {3}",
// face.TextureID, idx, client.Name, client.AgentId);
// if the texture is one of the "defaults" then skip it
// this should probably be more intelligent (skirt texture doesnt matter
// if the avatar isnt wearing a skirt) but if any of the main baked
// textures is default then the rest should be as well
if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE) if (face.TextureID == UUID.Zero || face.TextureID == AppearanceManager.DEFAULT_AVATAR_TEXTURE)
continue; continue;

View File

@ -1032,15 +1032,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// object itself before we rez. // object itself before we rez.
// //
// Only do these for the first object if we are rezzing a coalescence. // Only do these for the first object if we are rezzing a coalescence.
if (i == 0) // nahh dont mess with coalescence objects,
// the name in inventory can be change for inventory purpuses only
if (objlist.Count == 1)
{ {
rootPart.Name = item.Name; rootPart.Name = item.Name;
rootPart.Description = item.Description; rootPart.Description = item.Description;
if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0) }
{
rootPart.ObjectSaleType = item.SaleType; if ((item.Flags & (uint)InventoryItemFlags.ObjectSlamSale) != 0)
rootPart.SalePrice = item.SalePrice; {
} rootPart.ObjectSaleType = item.SaleType;
rootPart.SalePrice = item.SalePrice;
} }
so.FromFolderID = item.Folder; so.FromFolderID = item.Folder;

View File

@ -1234,8 +1234,9 @@ namespace OpenSim.Region.Framework.Scenes
{ {
uint perms = taskItem.CurrentPermissions; uint perms = taskItem.CurrentPermissions;
PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms);
agentItem.BasePermissions = perms | (uint)PermissionMask.Move; // agentItem.BasePermissions = perms | (uint)PermissionMask.Move;
agentItem.CurrentPermissions = agentItem.BasePermissions; // agentItem.CurrentPermissions = agentItem.BasePermissions;
agentItem.CurrentPermissions = perms | (uint)PermissionMask.Move;
} }
else else
{ {

File diff suppressed because it is too large Load Diff

View File

@ -917,12 +917,14 @@ namespace OpenSim.Region.Framework.Scenes
// in the serialization, transfer the correct name from the inventory to the // in the serialization, transfer the correct name from the inventory to the
// object itself before we rez. // object itself before we rez.
// Only do these for the first object if we are rezzing a coalescence. // Only do these for the first object if we are rezzing a coalescence.
if (i == 0) // nahh dont mess with coalescence objects,
// the name in inventory can be change for inventory purpuses only
if (objlist.Count == 1)
{ {
rootPart.Name = item.Name; rootPart.Name = item.Name;
rootPart.Description = item.Description; rootPart.Description = item.Description;
} }
/* reverted to old code till part.ApplyPermissionsOnRez is better reviewed/fixed
group.SetGroup(m_part.GroupID, null); group.SetGroup(m_part.GroupID, null);
foreach (SceneObjectPart part in group.Parts) foreach (SceneObjectPart part in group.Parts)
@ -938,7 +940,49 @@ namespace OpenSim.Region.Framework.Scenes
part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene);
} }
*/
// old code start
SceneObjectPart[] partList = group.Parts;
group.SetGroup(m_part.GroupID, null);
// TODO: Remove magic number badness
if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
{
if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
{
foreach (SceneObjectPart part in partList)
{
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
part.EveryoneMask = item.EveryonePermissions;
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
part.NextOwnerMask = item.NextPermissions;
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
part.GroupMask = item.GroupPermissions;
}
group.ApplyNextOwnerPermissions();
}
}
foreach (SceneObjectPart part in partList)
{
// TODO: Remove magic number badness
if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number
{
part.LastOwnerID = part.OwnerID;
part.OwnerID = item.OwnerID;
part.Inventory.ChangeInventoryOwner(item.OwnerID);
}
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0)
part.EveryoneMask = item.EveryonePermissions;
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0)
part.NextOwnerMask = item.NextPermissions;
if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0)
part.GroupMask = item.GroupPermissions;
}
// old code end
rootPart.TrimPermissions(); rootPart.TrimPermissions();
} }

View File

@ -3369,11 +3369,7 @@ namespace OpenSim.Region.Framework.Scenes
public void SendTerseUpdateToAgentClient(ScenePresence p) public void SendTerseUpdateToAgentClient(ScenePresence p)
{ {
// messy checks because a client doesn't know what presence it belongs too
IClientAPI remoteClient = p.ControllingClient; IClientAPI remoteClient = p.ControllingClient;
if (remoteClient == null)
return;
if (!remoteClient.IsActive) if (!remoteClient.IsActive)
return; return;
@ -3381,7 +3377,6 @@ namespace OpenSim.Region.Framework.Scenes
if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200) if (ParcelHideThisAvatar && p.currentParcelUUID != currentParcelUUID && p.GodLevel < 200)
return; return;
//m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity); //m_log.DebugFormat("[SCENE PRESENCE]: " + Name + " sending TerseUpdate to " + remoteClient.Name + " : Pos={0} Rot={1} Vel={2}", m_pos, Rotation, m_velocity);
remoteClient.SendEntityUpdate( remoteClient.SendEntityUpdate(
this, this,
@ -3507,7 +3502,7 @@ namespace OpenSim.Region.Framework.Scenes
// If we aren't using a cached appearance, then clear out the baked textures // If we aren't using a cached appearance, then clear out the baked textures
if (!cachedappearance) if (!cachedappearance)
{ {
Appearance.ResetAppearance(); // Appearance.ResetAppearance();
// save what ???? // save what ????
// maybe needed so the tryretry repair works? // maybe needed so the tryretry repair works?
if (m_scene.AvatarFactory != null) if (m_scene.AvatarFactory != null)
@ -3530,7 +3525,7 @@ namespace OpenSim.Region.Framework.Scenes
// send even grays // send even grays
if (cachedappearance) if (cachedappearance)
{ {
m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name); // m_log.DebugFormat("[SCENE PRESENCE]: Baked textures are in the cache for {0} in {1}", Name, m_scene.Name);
// If the avatars baked textures are all in the cache, then we have a // If the avatars baked textures are all in the cache, then we have a
// complete appearance... send it out, if not, then we'll send it when // complete appearance... send it out, if not, then we'll send it when
// the avatar finishes updating its appearance // the avatar finishes updating its appearance