refactor: split out the code which actually copies a particular bundle to inventory

bulletsim
Justin Clark-Casey (justincc) 2011-04-18 21:59:01 +01:00
parent 71114d4ad1
commit 61619ddefc
1 changed files with 123 additions and 114 deletions

View File

@ -214,18 +214,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return UUID.Zero; return UUID.Zero;
} }
/// <summary>
/// Delete a scene object from a scene and place in the given avatar's inventory.
/// Returns the UUID of the newly created asset.
/// </summary>
/// <param name="action"></param>
/// <param name="folderID"></param>
/// <param name="objectGroup"></param>
/// <param name="remoteClient"> </param>
public virtual UUID CopyToInventory(DeRezAction action, UUID folderID, public virtual UUID CopyToInventory(DeRezAction action, UUID folderID,
List<SceneObjectGroup> objectGroups, IClientAPI remoteClient) List<SceneObjectGroup> objectGroups, IClientAPI remoteClient)
{ {
Dictionary<UUID, List<SceneObjectGroup>> deletes = new Dictionary<UUID, List<SceneObjectGroup>>(); Dictionary<UUID, List<SceneObjectGroup>> bundlesToCopy = new Dictionary<UUID, List<SceneObjectGroup>>();
if (CoalesceMultipleObjectsToInventory) if (CoalesceMultipleObjectsToInventory)
{ {
@ -234,10 +226,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// reasons. // reasons.
foreach (SceneObjectGroup g in objectGroups) foreach (SceneObjectGroup g in objectGroups)
{ {
if (!deletes.ContainsKey(g.OwnerID)) if (!bundlesToCopy.ContainsKey(g.OwnerID))
deletes[g.OwnerID] = new List<SceneObjectGroup>(); bundlesToCopy[g.OwnerID] = new List<SceneObjectGroup>();
deletes[g.OwnerID].Add(g); bundlesToCopy[g.OwnerID].Add(g);
} }
} }
else else
@ -247,7 +239,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{ {
List<SceneObjectGroup> bundle = new List<SceneObjectGroup>(); List<SceneObjectGroup> bundle = new List<SceneObjectGroup>();
bundle.Add(g); bundle.Add(g);
deletes[g.UUID] = bundle; bundlesToCopy[g.UUID] = bundle;
} }
} }
@ -257,8 +249,26 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// Each iteration is really a separate asset being created, // Each iteration is really a separate asset being created,
// with distinct destinations as well. // with distinct destinations as well.
foreach (List<SceneObjectGroup> objlist in deletes.Values) foreach (List<SceneObjectGroup> bundle in bundlesToCopy.Values)
assetID = CopyBundleToInventory(action, folderID, bundle, remoteClient);
return assetID;
}
/// <summary>
/// Copy a bundle of objects to inventory. If there is only one object, then this will create an object
/// item. If there are multiple objects then these will be saved as a single coalesced item.
/// </summary>
/// <param name="action"></param>
/// <param name="folderID"></param>
/// <param name="objlist"></param>
/// <param name="remoteClient"></param>
/// <returns></returns>
protected UUID CopyBundleToInventory(
DeRezAction action, UUID folderID, List<SceneObjectGroup> objlist, IClientAPI remoteClient)
{ {
UUID assetID = UUID.Zero;
CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
@ -362,7 +372,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// This is a hook to do some per-asset post-processing for subclasses that need that // This is a hook to do some per-asset post-processing for subclasses that need that
ExportAsset(remoteClient.AgentId, assetID); ExportAsset(remoteClient.AgentId, assetID);
}
return assetID; return assetID;
} }