diff options
author | Justin Clark-Casey (justincc) | 2011-04-13 22:55:26 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-04-13 22:55:26 +0100 |
commit | c5465414b64d835128827976cc3da32aa462e6a3 (patch) | |
tree | 859a628f047c2da081c386157c953a3cb02406fb | |
parent | Adjust the quanterions used in the rez coalsced object tests to get sensible ... (diff) | |
download | opensim-SC_OLD-c5465414b64d835128827976cc3da32aa462e6a3.zip opensim-SC_OLD-c5465414b64d835128827976cc3da32aa462e6a3.tar.gz opensim-SC_OLD-c5465414b64d835128827976cc3da32aa462e6a3.tar.bz2 opensim-SC_OLD-c5465414b64d835128827976cc3da32aa462e6a3.tar.xz |
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
-rw-r--r-- | OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | 67 |
1 files changed, 13 insertions, 54 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 1f8bad1..c0946f4 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -222,7 +222,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
222 | deletes[g.OwnerID].Add(g); | 222 | deletes[g.OwnerID].Add(g); |
223 | } | 223 | } |
224 | 224 | ||
225 | // This is pethod scoped and will be returned. It will be the | 225 | // This is method scoped and will be returned. It will be the |
226 | // last created asset id | 226 | // last created asset id |
227 | UUID assetID = UUID.Zero; | 227 | UUID assetID = UUID.Zero; |
228 | 228 | ||
@@ -230,8 +230,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
230 | // with distinct destinations as well. | 230 | // with distinct destinations as well. |
231 | foreach (List<SceneObjectGroup> objlist in deletes.Values) | 231 | foreach (List<SceneObjectGroup> objlist in deletes.Values) |
232 | { | 232 | { |
233 | Dictionary<UUID, string> xmlStrings = | 233 | CoalescedSceneObjects coa = new CoalescedSceneObjects(UUID.Zero); |
234 | new Dictionary<UUID, string>(); | 234 | Dictionary<UUID, Vector3> originalPositions = new Dictionary<UUID, Vector3>(); |
235 | 235 | ||
236 | foreach (SceneObjectGroup objectGroup in objlist) | 236 | foreach (SceneObjectGroup objectGroup in objlist) |
237 | { | 237 | { |
@@ -245,7 +245,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
245 | : objectGroup.AbsolutePosition.X, | 245 | : objectGroup.AbsolutePosition.X, |
246 | objectGroup.AbsolutePosition.Z); | 246 | objectGroup.AbsolutePosition.Z); |
247 | 247 | ||
248 | Vector3 originalPosition = objectGroup.AbsolutePosition; | 248 | originalPositions[objectGroup.UUID] = objectGroup.AbsolutePosition; |
249 | 249 | ||
250 | objectGroup.AbsolutePosition = inventoryStoredPosition; | 250 | objectGroup.AbsolutePosition = inventoryStoredPosition; |
251 | 251 | ||
@@ -259,59 +259,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
259 | (uint)PermissionMask.Modify); | 259 | (uint)PermissionMask.Modify); |
260 | objectGroup.RootPart.NextOwnerMask |= | 260 | objectGroup.RootPart.NextOwnerMask |= |
261 | (uint)PermissionMask.Move; | 261 | (uint)PermissionMask.Move; |
262 | 262 | ||
263 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | 263 | coa.Add(objectGroup); |
264 | |||
265 | objectGroup.AbsolutePosition = originalPosition; | ||
266 | |||
267 | xmlStrings[objectGroup.UUID] = sceneObjectXml; | ||
268 | } | 264 | } |
269 | 265 | ||
270 | string itemXml; | 266 | string itemXml; |
271 | 267 | ||
272 | if (objlist.Count > 1) | 268 | if (objlist.Count > 1) |
273 | { | 269 | itemXml = CoalescedSceneObjectsSerializer.ToXml(coa); |
274 | float minX, minY, minZ; | ||
275 | float maxX, maxY, maxZ; | ||
276 | |||
277 | Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist, | ||
278 | out minX, out maxX, out minY, out maxY, | ||
279 | out minZ, out maxZ); | ||
280 | |||
281 | // CreateWrapper | ||
282 | XmlDocument itemDoc = new XmlDocument(); | ||
283 | XmlElement root = itemDoc.CreateElement("", "CoalescedObject", ""); | ||
284 | itemDoc.AppendChild(root); | ||
285 | |||
286 | // Embed the offsets into the group XML | ||
287 | for ( int i = 0 ; i < objlist.Count ; i++ ) | ||
288 | { | ||
289 | XmlDocument doc = new XmlDocument(); | ||
290 | SceneObjectGroup g = objlist[i]; | ||
291 | doc.LoadXml(xmlStrings[g.UUID]); | ||
292 | XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); | ||
293 | e.SetAttribute("offsetx", offsets[i].X.ToString()); | ||
294 | e.SetAttribute("offsety", offsets[i].Y.ToString()); | ||
295 | e.SetAttribute("offsetz", offsets[i].Z.ToString()); | ||
296 | |||
297 | XmlNode objectNode = itemDoc.ImportNode(e, true); | ||
298 | root.AppendChild(objectNode); | ||
299 | } | ||
300 | |||
301 | float sizeX = maxX - minX; | ||
302 | float sizeY = maxY - minY; | ||
303 | float sizeZ = maxZ - minZ; | ||
304 | |||
305 | root.SetAttribute("x", sizeX.ToString()); | ||
306 | root.SetAttribute("y", sizeY.ToString()); | ||
307 | root.SetAttribute("z", sizeZ.ToString()); | ||
308 | |||
309 | itemXml = itemDoc.InnerXml; | ||
310 | } | ||
311 | else | 270 | else |
312 | { | 271 | itemXml = SceneObjectSerializer.ToOriginalXmlFormat(objlist[0]); |
313 | itemXml = xmlStrings[objlist[0].UUID]; | 272 | |
314 | } | 273 | // Restore the position of each group now that it has been stored to inventory. |
274 | foreach (SceneObjectGroup objectGroup in objlist) | ||
275 | objectGroup.AbsolutePosition = originalPositions[objectGroup.UUID]; | ||
315 | 276 | ||
316 | // Get the user info of the item destination | 277 | // Get the user info of the item destination |
317 | // | 278 | // |
@@ -332,7 +293,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
332 | { | 293 | { |
333 | // All returns / deletes go to the object owner | 294 | // All returns / deletes go to the object owner |
334 | // | 295 | // |
335 | |||
336 | userID = objlist[0].RootPart.OwnerID; | 296 | userID = objlist[0].RootPart.OwnerID; |
337 | } | 297 | } |
338 | 298 | ||
@@ -346,7 +306,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
346 | // Delete is treated like return in this case | 306 | // Delete is treated like return in this case |
347 | // Deleting your own items makes them go to trash | 307 | // Deleting your own items makes them go to trash |
348 | // | 308 | // |
349 | 309 | ||
350 | InventoryFolderBase folder = null; | 310 | InventoryFolderBase folder = null; |
351 | InventoryItemBase item = null; | 311 | InventoryItemBase item = null; |
352 | 312 | ||
@@ -548,7 +508,6 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
548 | return assetID; | 508 | return assetID; |
549 | } | 509 | } |
550 | 510 | ||
551 | |||
552 | /// <summary> | 511 | /// <summary> |
553 | /// Rez an object into the scene from the user's inventory | 512 | /// Rez an object into the scene from the user's inventory |
554 | /// </summary> | 513 | /// </summary> |