Use common coalesced serialization code for both tests and the InventoryAccessModule.

Continue to restore original absolute positions of stored scene objects, though it's possible that these aren't used again
bulletsim
Justin Clark-Casey (justincc) 2011-04-13 22:55:26 +01:00
parent c81f5bfc5c
commit c5465414b6
1 changed files with 13 additions and 54 deletions

View File

@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
deletes[g.OwnerID].Add(g); deletes[g.OwnerID].Add(g);
} }
// This is pethod scoped and will be returned. It will be the // This is method scoped and will be returned. It will be the
// last created asset id // last created asset id
UUID assetID = UUID.Zero; UUID assetID = UUID.Zero;
@ -230,8 +230,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
// with distinct destinations as well. // with distinct destinations as well.
foreach (List<SceneObjectGroup> objlist in deletes.Values) foreach (List<SceneObjectGroup> objlist in deletes.Values)
{ {
Dictionary<UUID, string> xmlStrings = CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero);
new Dictionary<UUID, string>(); Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>();
foreach (SceneObjectGroup objectGroup in objlist) foreach (SceneObjectGroup objectGroup in objlist)
{ {
@ -245,7 +245,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
: objectGroup.AbsolutePosition.X, : objectGroup.AbsolutePosition.X,
objectGroup.AbsolutePosition.Z); objectGroup.AbsolutePosition.Z);
Vector3 originalPosition = objectGroup.AbsolutePosition; originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition;
objectGroup.AbsolutePosition = inventoryStoredPosition; objectGroup.AbsolutePosition = inventoryStoredPosition;
@ -260,58 +260,19 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
objectGroup.RootPart.NextOwnerMask |= objectGroup.RootPart.NextOwnerMask |=
(uint)PermissionMask.Move; (uint)PermissionMask.Move;
string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); coa.Add(objectGroup);
objectGroup.AbsolutePosition = originalPosition;
xmlStrings[objectGroup.UUID] = sceneObjectXml;
} }
string itemXml; string itemXml;
if (objlist.Count > 1) if (objlist.Count > 1)
{ itemXml = CoalescedSceneObjectsSerializer.ToXml(coa);
float minX, minY, minZ;
float maxX, maxY, maxZ;
Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist,
out minX, out maxX, out minY, out maxY,
out minZ, out maxZ);
// CreateWrapper
XmlDocument itemDoc = new XmlDocument();
XmlElement root = itemDoc.CreateElement("", "CoalescedObject", "");
itemDoc.AppendChild(root);
// Embed the offsets into the group XML
for ( int i = 0 ; i < objlist.Count ; i++ )
{
XmlDocument doc = new XmlDocument();
SceneObjectGroup g = objlist[i];
doc.LoadXml(xmlStrings[g.UUID]);
XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup");
e.SetAttribute("offsetx", offsets[i].X.ToString());
e.SetAttribute("offsety", offsets[i].Y.ToString());
e.SetAttribute("offsetz", offsets[i].Z.ToString());
XmlNode objectNode = itemDoc.ImportNode(e, true);
root.AppendChild(objectNode);
}
float sizeX = maxX - minX;
float sizeY = maxY - minY;
float sizeZ = maxZ - minZ;
root.SetAttribute("x", sizeX.ToString());
root.SetAttribute("y", sizeY.ToString());
root.SetAttribute("z", sizeZ.ToString());
itemXml = itemDoc.InnerXml;
}
else else
{ itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]);
itemXml = xmlStrings[objlist[0].UUID];
} // Restore the position of each group now that it has been stored to inventory.
foreach (SceneObjectGroup objectGroup in objlist)
objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID];
// Get the user info of the item destination // Get the user info of the item destination
// //
@ -332,7 +293,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
{ {
// All returns / deletes go to the object owner // All returns / deletes go to the object owner
// //
userID = objlist[0].RootPart.OwnerID; userID = objlist[0].RootPart.OwnerID;
} }
@ -548,7 +508,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return assetID; return assetID;
} }
/// <summary> /// <summary>
/// Rez an object into the scene from the user's inventory /// Rez an object into the scene from the user's inventory
/// </summary> /// </summary>