When uploading mesh objects with textures also create inventory items for uploaded textures.
This implements: http://opensimulator.org/mantis/view.php?id=72500.8.0.3
parent
e87a0d9db1
commit
45e280274c
|
@ -44,6 +44,7 @@ using OpenSim.Region.Framework.Scenes;
|
|||
using OpenSim.Region.Framework.Scenes.Serialization;
|
||||
using OpenSim.Framework.Servers;
|
||||
using OpenSim.Framework.Servers.HttpServer;
|
||||
using OpenSim.Framework.Client;
|
||||
using OpenSim.Services.Interfaces;
|
||||
|
||||
using Caps = OpenSim.Framework.Capabilities.Caps;
|
||||
|
@ -536,6 +537,39 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
OSDArray texture_list = (OSDArray)request["texture_list"];
|
||||
SceneObjectGroup grp = null;
|
||||
|
||||
InventoryFolderBase textureUploadFolder = null;
|
||||
|
||||
List<InventoryFolderBase> foldersToUpdate = new List<InventoryFolderBase>();
|
||||
List<InventoryItemBase> itemsToUpdate = new List<InventoryItemBase>();
|
||||
IClientInventory clientInv = null;
|
||||
|
||||
if (texture_list.Count > 0)
|
||||
{
|
||||
ScenePresence avatar = null;
|
||||
IClientAPI client = null;
|
||||
m_Scene.TryGetScenePresence(m_HostCapsObj.AgentID, out avatar);
|
||||
|
||||
if (avatar != null)
|
||||
{
|
||||
IClientCore core = (IClientCore)avatar.ControllingClient;
|
||||
|
||||
if (core.TryGet<IClientInventory>(out clientInv))
|
||||
{
|
||||
var systemTextureFolder = m_Scene.InventoryService.GetFolderForType(m_HostCapsObj.AgentID, AssetType.Texture);
|
||||
textureUploadFolder = new InventoryFolderBase(UUID.Random(), assetName, m_HostCapsObj.AgentID, (short)AssetType.Unknown, systemTextureFolder.ID, 1);
|
||||
if (m_Scene.InventoryService.AddFolder(textureUploadFolder))
|
||||
{
|
||||
foldersToUpdate.Add(textureUploadFolder);
|
||||
m_log.DebugFormat("Created new folder '{0}' ({1}) for textures uploaded with mesh object {2}", textureUploadFolder.Name, textureUploadFolder.ID, assetName);
|
||||
}
|
||||
else
|
||||
{
|
||||
textureUploadFolder = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<UUID> textures = new List<UUID>();
|
||||
for (int i = 0; i < texture_list.Count; i++)
|
||||
{
|
||||
|
@ -543,6 +577,35 @@ namespace OpenSim.Region.ClientStack.Linden
|
|||
textureAsset.Data = texture_list[i].AsBinary();
|
||||
m_assetService.Store(textureAsset);
|
||||
textures.Add(textureAsset.FullID);
|
||||
|
||||
if (textureUploadFolder != null)
|
||||
{
|
||||
InventoryItemBase textureItem = new InventoryItemBase();
|
||||
textureItem.Owner = m_HostCapsObj.AgentID;
|
||||
textureItem.CreatorId = m_HostCapsObj.AgentID.ToString();
|
||||
textureItem.CreatorData = String.Empty;
|
||||
textureItem.ID = UUID.Random();
|
||||
textureItem.AssetID = textureAsset.FullID;
|
||||
textureItem.Description = assetDescription;
|
||||
textureItem.Name = assetName + " - Texture " + (i + 1).ToString();
|
||||
textureItem.AssetType = (int)AssetType.Texture;
|
||||
textureItem.InvType = (int)InventoryType.Texture;
|
||||
textureItem.Folder = textureUploadFolder.ID;
|
||||
textureItem.CurrentPermissions
|
||||
= (uint)(PermissionMask.Move | PermissionMask.Copy | PermissionMask.Modify | PermissionMask.Transfer | PermissionMask.Export);
|
||||
textureItem.BasePermissions = (uint)PermissionMask.All | (uint)PermissionMask.Export;
|
||||
textureItem.EveryOnePermissions = 0;
|
||||
textureItem.NextPermissions = (uint)PermissionMask.All;
|
||||
textureItem.CreationDate = Util.UnixTimeSinceEpoch();
|
||||
m_Scene.InventoryService.AddItem(textureItem);
|
||||
itemsToUpdate.Add(textureItem);
|
||||
m_log.DebugFormat("Created new inventory item '{0}' ({1}) for texture uploaded with mesh object {2}", textureItem.Name, textureItem.ID, assetName);
|
||||
}
|
||||
}
|
||||
|
||||
if (clientInv != null && (foldersToUpdate.Count > 0 || itemsToUpdate.Count > 0))
|
||||
{
|
||||
clientInv.SendBulkUpdateInventory(foldersToUpdate.ToArray(), itemsToUpdate.ToArray());
|
||||
}
|
||||
|
||||
for (int i = 0; i < mesh_list.Count; i++)
|
||||
|
|
Loading…
Reference in New Issue