refactor: move code to obtain the coalescence size and object offsets into CoalescedSceneObjects from the serializer.
parent
d8d28c3737
commit
68cc5b46fe
|
@ -84,7 +84,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests
|
||||||
public void TestRezCoalescedObject()
|
public void TestRezCoalescedObject()
|
||||||
{
|
{
|
||||||
TestHelper.InMethod();
|
TestHelper.InMethod();
|
||||||
log4net.Config.XmlConfigurator.Configure();
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
||||||
// Create asset
|
// Create asset
|
||||||
SceneObjectGroup object1;
|
SceneObjectGroup object1;
|
||||||
|
|
|
@ -124,5 +124,31 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
lock (m_memberObjects)
|
lock (m_memberObjects)
|
||||||
return m_memberObjects.Remove(obj);
|
return m_memberObjects.Remove(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <returns>
|
||||||
|
/// An array of offsets. The order of objects is the same as returned from the Objects property
|
||||||
|
/// </returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,6 +42,9 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize and deserialize coalesced scene objects.
|
/// Serialize and deserialize coalesced scene objects.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// Deserialization not yet here.
|
||||||
|
/// </remarks>
|
||||||
public class CoalescedSceneObjectsSerializer
|
public class CoalescedSceneObjectsSerializer
|
||||||
{
|
{
|
||||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
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 (StringWriter sw = new StringWriter())
|
||||||
{
|
{
|
||||||
using (XmlTextWriter writer = new XmlTextWriter(sw))
|
using (XmlTextWriter writer = new XmlTextWriter(sw))
|
||||||
{
|
{
|
||||||
|
Vector3 size;
|
||||||
|
|
||||||
List<SceneObjectGroup> coaObjects = coa.Objects;
|
List<SceneObjectGroup> coaObjects = coa.Objects;
|
||||||
|
|
||||||
// m_log.DebugFormat(
|
// m_log.DebugFormat(
|
||||||
// "[COALESCED SCENE OBJECTS SERIALIZER]: Writing {0} objects for coalesced object",
|
// "[COALESCED SCENE OBJECTS SERIALIZER]: Writing {0} objects for coalesced object",
|
||||||
// coaObjects.Count);
|
// coaObjects.Count);
|
||||||
|
|
||||||
float minX, minY, minZ;
|
// This is weak - we're relying on the set of coalesced objects still being identical
|
||||||
float maxX, maxY, maxZ;
|
Vector3[] offsets = coa.GetSizeAndOffsets(out size);
|
||||||
|
|
||||||
Vector3[] offsets = Scene.GetCombinedBoundingBox(coaObjects,
|
|
||||||
out minX, out maxX, out minY, out maxY,
|
|
||||||
out minZ, out maxZ);
|
|
||||||
|
|
||||||
writer.WriteStartElement("CoalescedObject");
|
writer.WriteStartElement("CoalescedObject");
|
||||||
|
|
||||||
float sizeX = maxX - minX;
|
writer.WriteAttributeString("x", size.X.ToString());
|
||||||
float sizeY = maxY - minY;
|
writer.WriteAttributeString("y", size.Y.ToString());
|
||||||
float sizeZ = maxZ - minZ;
|
writer.WriteAttributeString("z", size.Z.ToString());
|
||||||
|
|
||||||
writer.WriteAttributeString("x", sizeX.ToString());
|
|
||||||
writer.WriteAttributeString("y", sizeY.ToString());
|
|
||||||
writer.WriteAttributeString("z", sizeZ.ToString());
|
|
||||||
|
|
||||||
// Embed the offsets into the group XML
|
// Embed the offsets into the group XML
|
||||||
for (int i = 0; i < coaObjects.Count; i++)
|
for (int i = 0; i < coaObjects.Count; i++)
|
||||||
|
@ -100,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
|
||||||
|
|
||||||
SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true);
|
SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true);
|
||||||
|
|
||||||
writer.WriteEndElement();
|
writer.WriteEndElement(); // SceneObjectGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
writer.WriteEndElement(); // CoalescedObject
|
writer.WriteEndElement(); // CoalescedObject
|
||||||
|
|
Loading…
Reference in New Issue