From 68cc5b46fefdf4db68cae1202086257ce731f8a1 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 13 Apr 2011 21:48:16 +0100
Subject: refactor: move code to obtain the coalescence size and object offsets
into CoalescedSceneObjects from the serializer.
---
.../Tests/InventoryAccessModuleTests.cs | 2 +-
.../Framework/Scenes/CoalescedSceneObjects.cs | 26 +++++++++++++++++++++
.../CoalescedSceneObjectsSerializer.cs | 27 ++++++++++------------
3 files changed, 39 insertions(+), 16 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
index 0f2b610..c197cb9 100644
--- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
+++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs
@@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
public void TestRezCoalescedObject()
{
TestHelper.InMethod();
- log4net.Config.XmlConfigurator.Configure();
+// log4net.Config.XmlConfigurator.Configure();
// Create asset
SceneObjectGroup object1;
diff --git a/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs b/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs
index 51eac5f..af8ccda 100644
--- a/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs
+++ b/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs
@@ -124,5 +124,31 @@ namespace OpenSim.Region.Framework.Scenes
lock (m_memberObjects)
return m_memberObjects.Remove(obj);
}
+
+ ///
+ /// Get the total size of the coalescence (the size required to cover all the objects within it) and the
+ /// offsets of each of those objects.
+ ///
+ ///
+ ///
+ /// An array of offsets. The order of objects is the same as returned from the Objects property
+ ///
+ public Vector3[] GetSizeAndOffsets(out Vector3 size)
+ {
+ float minX, minY, minZ;
+ float maxX, maxY, maxZ;
+
+ Vector3[] offsets
+ = Scene.GetCombinedBoundingBox(
+ Objects, out minX, out maxX, out minY, out maxY, out minZ, out maxZ);
+
+ float sizeX = maxX - minX;
+ float sizeY = maxY - minY;
+ float sizeZ = maxZ - minZ;
+
+ size = new Vector3(sizeX, sizeY, sizeZ);
+
+ return offsets;
+ }
}
}
\ No newline at end of file
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
index 3af2f76..a0e120a 100644
--- a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
+++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs
@@ -42,6 +42,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
///
/// Serialize and deserialize coalesced scene objects.
///
+ ///
+ /// Deserialization not yet here.
+ ///
public class CoalescedSceneObjectsSerializer
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -60,29 +63,23 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
using (StringWriter sw = new StringWriter())
{
using (XmlTextWriter writer = new XmlTextWriter(sw))
- {
+ {
+ Vector3 size;
+
List coaObjects = coa.Objects;
// m_log.DebugFormat(
// "[COALESCED SCENE OBJECTS SERIALIZER]: Writing {0} objects for coalesced object",
// coaObjects.Count);
- float minX, minY, minZ;
- float maxX, maxY, maxZ;
-
- Vector3[] offsets = Scene.GetCombinedBoundingBox(coaObjects,
- out minX, out maxX, out minY, out maxY,
- out minZ, out maxZ);
+ // This is weak - we're relying on the set of coalesced objects still being identical
+ Vector3[] offsets = coa.GetSizeAndOffsets(out size);
writer.WriteStartElement("CoalescedObject");
- float sizeX = maxX - minX;
- float sizeY = maxY - minY;
- float sizeZ = maxZ - minZ;
-
- writer.WriteAttributeString("x", sizeX.ToString());
- writer.WriteAttributeString("y", sizeY.ToString());
- writer.WriteAttributeString("z", sizeZ.ToString());
+ writer.WriteAttributeString("x", size.X.ToString());
+ writer.WriteAttributeString("y", size.Y.ToString());
+ writer.WriteAttributeString("z", size.Z.ToString());
// Embed the offsets into the group XML
for (int i = 0; i < coaObjects.Count; i++)
@@ -100,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true);
- writer.WriteEndElement();
+ writer.WriteEndElement(); // SceneObjectGroup
}
writer.WriteEndElement(); // CoalescedObject
--
cgit v1.1