diff options
author | Justin Clark-Casey (justincc) | 2011-04-13 21:17:43 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2011-04-13 21:17:43 +0100 |
commit | 58efd761d13bd4f2617fcb3f94bbe265880589e3 (patch) | |
tree | 4900fbec5e577c48b42efeb10115fd64dc47681b /OpenSim/Region | |
parent | factor out some test code into the SetUp() (diff) | |
download | opensim-SC_OLD-58efd761d13bd4f2617fcb3f94bbe265880589e3.zip opensim-SC_OLD-58efd761d13bd4f2617fcb3f94bbe265880589e3.tar.gz opensim-SC_OLD-58efd761d13bd4f2617fcb3f94bbe265880589e3.tar.bz2 opensim-SC_OLD-58efd761d13bd4f2617fcb3f94bbe265880589e3.tar.xz |
Add coalesced scene objects class and serializer. This is currently only used by the TestRezCoalescedObject() regression test.
This structure matches the existing one for SceneObjects and will allow code to be reused by the uuid gatherer, other tests, etc.
Test is not yet fully implemented due to a bug in rezzing coalesced objects where they all get the same name as the item.
Only one object should get the same name as the item, which appears to be the one selected last when the the objects were coalesced in the first place.
This bug will be addressed shortly.
Diffstat (limited to 'OpenSim/Region')
7 files changed, 374 insertions, 9 deletions
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 73b0a35..cfcfc79 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs | |||
@@ -274,7 +274,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
274 | float minX, minY, minZ; | 274 | float minX, minY, minZ; |
275 | float maxX, maxY, maxZ; | 275 | float maxX, maxY, maxZ; |
276 | 276 | ||
277 | Vector3[] offsets = m_Scene.GetCombinedBoundingBox(objlist, | 277 | Vector3[] offsets = Scene.GetCombinedBoundingBox(objlist, |
278 | out minX, out maxX, out minY, out maxY, | 278 | out minX, out maxX, out minY, out maxY, |
279 | out minZ, out maxZ); | 279 | out minZ, out maxZ); |
280 | 280 | ||
@@ -289,7 +289,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
289 | XmlDocument doc = new XmlDocument(); | 289 | XmlDocument doc = new XmlDocument(); |
290 | SceneObjectGroup g = objlist[i]; | 290 | SceneObjectGroup g = objlist[i]; |
291 | doc.LoadXml(xmlStrings[g.UUID]); | 291 | doc.LoadXml(xmlStrings[g.UUID]); |
292 | XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); | 292 | XmlElement e = (XmlElement)doc.SelectSingleNode("/SceneObjectGroup"); |
293 | e.SetAttribute("offsetx", offsets[i].X.ToString()); | 293 | e.SetAttribute("offsetx", offsets[i].X.ToString()); |
294 | e.SetAttribute("offsety", offsets[i].Y.ToString()); | 294 | e.SetAttribute("offsety", offsets[i].Y.ToString()); |
295 | e.SetAttribute("offsetz", offsets[i].Z.ToString()); | 295 | e.SetAttribute("offsetz", offsets[i].Z.ToString()); |
@@ -659,9 +659,18 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess | |||
659 | itemId, n.OuterXml); | 659 | itemId, n.OuterXml); |
660 | objlist.Add(g); | 660 | objlist.Add(g); |
661 | XmlElement el = (XmlElement)n; | 661 | XmlElement el = (XmlElement)n; |
662 | float x = Convert.ToSingle(el.GetAttribute("offsetx")); | 662 | |
663 | float y = Convert.ToSingle(el.GetAttribute("offsety")); | 663 | string rawX = el.GetAttribute("offsetx"); |
664 | float z = Convert.ToSingle(el.GetAttribute("offsetz")); | 664 | string rawY = el.GetAttribute("offsety"); |
665 | string rawZ = el.GetAttribute("offsetz"); | ||
666 | // | ||
667 | // m_log.DebugFormat( | ||
668 | // "[INVENTORY ACCESS MODULE]: Converting coalesced object {0} offset <{1}, {2}, {3}>", | ||
669 | // g.Name, rawX, rawY, rawZ); | ||
670 | |||
671 | float x = Convert.ToSingle(rawX); | ||
672 | float y = Convert.ToSingle(rawY); | ||
673 | float z = Convert.ToSingle(rawZ); | ||
665 | veclist.Add(new Vector3(x, y, z)); | 674 | veclist.Add(new Vector3(x, y, z)); |
666 | } | 675 | } |
667 | } | 676 | } |
diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs index 5eca753..f8fa424 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/Tests/InventoryAccessModuleTests.cs | |||
@@ -81,6 +81,85 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess.Tests | |||
81 | } | 81 | } |
82 | 82 | ||
83 | [Test] | 83 | [Test] |
84 | public void TestRezCoalescedObject() | ||
85 | { | ||
86 | TestHelper.InMethod(); | ||
87 | log4net.Config.XmlConfigurator.Configure(); | ||
88 | |||
89 | // Create asset | ||
90 | SceneObjectGroup object1; | ||
91 | { | ||
92 | string partName = "Object1"; | ||
93 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
94 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
95 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
96 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
97 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
98 | |||
99 | SceneObjectPart part1 | ||
100 | = new SceneObjectPart( | ||
101 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
102 | part1.Name = partName; | ||
103 | |||
104 | object1 = new SceneObjectGroup(part1); | ||
105 | } | ||
106 | |||
107 | SceneObjectGroup object2; | ||
108 | { | ||
109 | string partName = "Object2"; | ||
110 | UUID ownerId = UUID.Parse("00000000-0000-0000-0000-000000000040"); | ||
111 | PrimitiveBaseShape shape = PrimitiveBaseShape.CreateSphere(); | ||
112 | Vector3 groupPosition = new Vector3(10, 20, 30); | ||
113 | Quaternion rotationOffset = new Quaternion(20, 30, 40, 50); | ||
114 | Vector3 offsetPosition = new Vector3(5, 10, 15); | ||
115 | |||
116 | SceneObjectPart part1 | ||
117 | = new SceneObjectPart( | ||
118 | ownerId, shape, groupPosition, rotationOffset, offsetPosition); | ||
119 | part1.Name = partName; | ||
120 | |||
121 | object2 = new SceneObjectGroup(part1); | ||
122 | } | ||
123 | |||
124 | CoalescedSceneObjects coa = new CoalescedSceneObjects(m_userId, object1, object2); | ||
125 | |||
126 | UUID asset1Id = UUID.Parse("00000000-0000-0000-0000-000000000060"); | ||
127 | AssetBase asset1 = AssetHelpers.CreateAsset(asset1Id, coa); | ||
128 | m_scene.AssetService.Store(asset1); | ||
129 | |||
130 | // Create item | ||
131 | UUID item1Id = UUID.Parse("00000000-0000-0000-0000-000000000080"); | ||
132 | string item1Name = "My Little Dog"; | ||
133 | InventoryItemBase item1 = new InventoryItemBase(); | ||
134 | item1.Name = item1Name; | ||
135 | item1.AssetID = asset1.FullID; | ||
136 | item1.ID = item1Id; | ||
137 | InventoryFolderBase objsFolder | ||
138 | = InventoryArchiveUtils.FindFolderByPath(m_scene.InventoryService, m_userId, "Objects")[0]; | ||
139 | item1.Folder = objsFolder.ID; | ||
140 | m_scene.AddInventoryItem(item1); | ||
141 | |||
142 | SceneObjectGroup so | ||
143 | = m_iam.RezObject( | ||
144 | m_tc, item1Id, Vector3.Zero, Vector3.Zero, UUID.Zero, 1, false, false, false, UUID.Zero, false); | ||
145 | |||
146 | Assert.That(so, Is.Not.Null); | ||
147 | |||
148 | Assert.That(m_scene.SceneGraph.GetTotalObjectsCount(), Is.EqualTo(2)); | ||
149 | |||
150 | SceneObjectPart retrievedObj1Part = m_scene.GetSceneObjectPart(object1.Name); | ||
151 | Assert.That(retrievedObj1Part, Is.Null); | ||
152 | |||
153 | retrievedObj1Part = m_scene.GetSceneObjectPart(item1.Name); | ||
154 | Assert.That(retrievedObj1Part, Is.Not.Null); | ||
155 | Assert.That(retrievedObj1Part.Name, Is.EqualTo(item1.Name)); | ||
156 | |||
157 | // FIXME: Can't test yet due to a bug where objects in coalescence all get the item name when rerezzed. | ||
158 | // SceneObjectPart retrievedObj2Part = m_scene.GetSceneObjectPart(object2.Name); | ||
159 | // Assert.That(retrievedObj2Part, Is.Not.Null); | ||
160 | } | ||
161 | |||
162 | [Test] | ||
84 | public void TestRezObject() | 163 | public void TestRezObject() |
85 | { | 164 | { |
86 | TestHelper.InMethod(); | 165 | TestHelper.InMethod(); |
diff --git a/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs b/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs new file mode 100644 index 0000000..51eac5f --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/CoalescedSceneObjects.cs | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Linq; | ||
31 | using OpenMetaverse; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Scenes | ||
34 | { | ||
35 | /// <summary> | ||
36 | /// Represents a coalescene of scene objects. A coalescence occurs when objects that are not in the same linkset | ||
37 | /// are grouped together. | ||
38 | /// </summary> | ||
39 | public class CoalescedSceneObjects | ||
40 | { | ||
41 | /// <summary> | ||
42 | /// The creator of this coalesence, though not necessarily the objects within it. | ||
43 | /// </summary> | ||
44 | public UUID CreatorId { get; set; } | ||
45 | |||
46 | /// <summary> | ||
47 | /// The number of objects in this coalesence | ||
48 | /// </summary> | ||
49 | public int Count | ||
50 | { | ||
51 | get | ||
52 | { | ||
53 | lock (m_memberObjects) | ||
54 | return m_memberObjects.Count; | ||
55 | } | ||
56 | } | ||
57 | |||
58 | /// <summary> | ||
59 | /// Does this coalesence have any member objects? | ||
60 | /// </summary> | ||
61 | public bool HasObjects { get { return Count > 0; } } | ||
62 | |||
63 | /// <summary> | ||
64 | /// Get the objects currently in this coalescence | ||
65 | /// </summary> | ||
66 | public List<SceneObjectGroup> Objects | ||
67 | { | ||
68 | get | ||
69 | { | ||
70 | lock (m_memberObjects) | ||
71 | return new List<SceneObjectGroup>(m_memberObjects); | ||
72 | } | ||
73 | } | ||
74 | |||
75 | /// <summary> | ||
76 | /// Get the scene that contains the objects in this coalescence. If there are no objects then null is returned. | ||
77 | /// </summary> | ||
78 | public Scene Scene | ||
79 | { | ||
80 | get | ||
81 | { | ||
82 | if (!HasObjects) | ||
83 | return null; | ||
84 | else | ||
85 | return Objects[0].Scene; | ||
86 | } | ||
87 | } | ||
88 | |||
89 | /// <summary> | ||
90 | /// At this point, we need to preserve the order of objects added to the coalescence, since the first | ||
91 | /// one will end up matching the item name when rerezzed. | ||
92 | /// </summary> | ||
93 | protected List<SceneObjectGroup> m_memberObjects = new List<SceneObjectGroup>(); | ||
94 | |||
95 | public CoalescedSceneObjects(UUID creatorId) | ||
96 | { | ||
97 | CreatorId = creatorId; | ||
98 | } | ||
99 | |||
100 | public CoalescedSceneObjects(UUID creatorId, params SceneObjectGroup[] objs) : this(creatorId) | ||
101 | { | ||
102 | foreach (SceneObjectGroup obj in objs) | ||
103 | Add(obj); | ||
104 | } | ||
105 | |||
106 | /// <summary> | ||
107 | /// Add an object to the coalescence. | ||
108 | /// </summary> | ||
109 | /// <param name="obj"></param> | ||
110 | /// <param name="offset">The offset of the object within the group</param> | ||
111 | public void Add(SceneObjectGroup obj) | ||
112 | { | ||
113 | lock (m_memberObjects) | ||
114 | m_memberObjects.Add(obj); | ||
115 | } | ||
116 | |||
117 | /// <summary> | ||
118 | /// Removes a scene object from the coalescene | ||
119 | /// </summary> | ||
120 | /// <param name="sceneObjectId"></param> | ||
121 | /// <returns>true if the object was there to be removed, false if not.</returns> | ||
122 | public bool Remove(SceneObjectGroup obj) | ||
123 | { | ||
124 | lock (m_memberObjects) | ||
125 | return m_memberObjects.Remove(obj); | ||
126 | } | ||
127 | } | ||
128 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index f0acc38..e6dd489 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -4839,7 +4839,20 @@ namespace OpenSim.Region.Framework.Scenes | |||
4839 | } | 4839 | } |
4840 | } | 4840 | } |
4841 | 4841 | ||
4842 | public Vector3[] GetCombinedBoundingBox(List<SceneObjectGroup> objects, out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | 4842 | /// <summary> |
4843 | /// Get the volume of space that will encompass all the given objects. | ||
4844 | /// </summary> | ||
4845 | /// <param name="objects"></param> | ||
4846 | /// <param name="minX"></param> | ||
4847 | /// <param name="maxX"></param> | ||
4848 | /// <param name="minY"></param> | ||
4849 | /// <param name="maxY"></param> | ||
4850 | /// <param name="minZ"></param> | ||
4851 | /// <param name="maxZ"></param> | ||
4852 | /// <returns></returns> | ||
4853 | public static Vector3[] GetCombinedBoundingBox( | ||
4854 | List<SceneObjectGroup> objects, | ||
4855 | out float minX, out float maxX, out float minY, out float maxY, out float minZ, out float maxZ) | ||
4843 | { | 4856 | { |
4844 | minX = 256; | 4857 | minX = 256; |
4845 | maxX = -256; | 4858 | maxX = -256; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index 97af0a0..72f0402 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -997,6 +997,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
997 | { | 997 | { |
998 | foreach (SceneObjectPart p in ((SceneObjectGroup)entity).Parts) | 998 | foreach (SceneObjectPart p in ((SceneObjectGroup)entity).Parts) |
999 | { | 999 | { |
1000 | // m_log.DebugFormat("[SCENE GRAPH]: Part {0} has name {1}", p.UUID, p.Name); | ||
1001 | |||
1000 | if (p.Name == name) | 1002 | if (p.Name == name) |
1001 | { | 1003 | { |
1002 | sop = p; | 1004 | sop = p; |
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs new file mode 100644 index 0000000..3af2f76 --- /dev/null +++ b/OpenSim/Region/Framework/Scenes/Serialization/CoalescedSceneObjectsSerializer.cs | |||
@@ -0,0 +1,117 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Drawing; | ||
31 | using System.IO; | ||
32 | using System.Reflection; | ||
33 | using System.Xml; | ||
34 | using log4net; | ||
35 | using OpenMetaverse; | ||
36 | using OpenSim.Framework; | ||
37 | using OpenSim.Region.Framework.Interfaces; | ||
38 | using OpenSim.Region.Framework.Scenes; | ||
39 | |||
40 | namespace OpenSim.Region.Framework.Scenes.Serialization | ||
41 | { | ||
42 | /// <summary> | ||
43 | /// Serialize and deserialize coalesced scene objects. | ||
44 | /// </summary> | ||
45 | public class CoalescedSceneObjectsSerializer | ||
46 | { | ||
47 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
48 | |||
49 | /// <summary> | ||
50 | /// Serialize coalesced objects to Xml | ||
51 | /// </summary> | ||
52 | /// <param name="coa"></param> | ||
53 | /// <returns></returns> | ||
54 | public static string ToXml(CoalescedSceneObjects coa) | ||
55 | { | ||
56 | // TODO: Should probably return an empty xml serialization rather than a blank string | ||
57 | if (!coa.HasObjects) | ||
58 | return ""; | ||
59 | |||
60 | using (StringWriter sw = new StringWriter()) | ||
61 | { | ||
62 | using (XmlTextWriter writer = new XmlTextWriter(sw)) | ||
63 | { | ||
64 | List<SceneObjectGroup> coaObjects = coa.Objects; | ||
65 | |||
66 | // m_log.DebugFormat( | ||
67 | // "[COALESCED SCENE OBJECTS SERIALIZER]: Writing {0} objects for coalesced object", | ||
68 | // coaObjects.Count); | ||
69 | |||
70 | float minX, minY, minZ; | ||
71 | float maxX, maxY, maxZ; | ||
72 | |||
73 | Vector3[] offsets = Scene.GetCombinedBoundingBox(coaObjects, | ||
74 | out minX, out maxX, out minY, out maxY, | ||
75 | out minZ, out maxZ); | ||
76 | |||
77 | writer.WriteStartElement("CoalescedObject"); | ||
78 | |||
79 | float sizeX = maxX - minX; | ||
80 | float sizeY = maxY - minY; | ||
81 | float sizeZ = maxZ - minZ; | ||
82 | |||
83 | writer.WriteAttributeString("x", sizeX.ToString()); | ||
84 | writer.WriteAttributeString("y", sizeY.ToString()); | ||
85 | writer.WriteAttributeString("z", sizeZ.ToString()); | ||
86 | |||
87 | // Embed the offsets into the group XML | ||
88 | for (int i = 0; i < coaObjects.Count; i++) | ||
89 | { | ||
90 | SceneObjectGroup obj = coaObjects[i]; | ||
91 | |||
92 | // m_log.DebugFormat( | ||
93 | // "[COALESCED SCENE OBJECTS SERIALIZER]: Writing offset for object {0}, {1}", | ||
94 | // i, obj.Name); | ||
95 | |||
96 | writer.WriteStartElement("SceneObjectGroup"); | ||
97 | writer.WriteAttributeString("offsetx", offsets[i].X.ToString()); | ||
98 | writer.WriteAttributeString("offsety", offsets[i].Y.ToString()); | ||
99 | writer.WriteAttributeString("offsetz", offsets[i].Z.ToString()); | ||
100 | |||
101 | SceneObjectSerializer.ToOriginalXmlFormat(obj, writer, true); | ||
102 | |||
103 | writer.WriteEndElement(); | ||
104 | } | ||
105 | |||
106 | writer.WriteEndElement(); // CoalescedObject | ||
107 | } | ||
108 | |||
109 | string output = sw.ToString(); | ||
110 | |||
111 | // m_log.Debug(output); | ||
112 | |||
113 | return output; | ||
114 | } | ||
115 | } | ||
116 | } | ||
117 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs index b412e25..bb8a83a 100644 --- a/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs +++ b/OpenSim/Region/Framework/Scenes/Serialization/SceneObjectSerializer.cs | |||
@@ -139,6 +139,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
139 | return sw.ToString(); | 139 | return sw.ToString(); |
140 | } | 140 | } |
141 | } | 141 | } |
142 | |||
142 | 143 | ||
143 | /// <summary> | 144 | /// <summary> |
144 | /// Serialize a scene object to the original xml format | 145 | /// Serialize a scene object to the original xml format |
@@ -147,10 +148,24 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
147 | /// <returns></returns> | 148 | /// <returns></returns> |
148 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) | 149 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer) |
149 | { | 150 | { |
151 | ToOriginalXmlFormat(sceneObject, writer, false); | ||
152 | } | ||
153 | |||
154 | /// <summary> | ||
155 | /// Serialize a scene object to the original xml format | ||
156 | /// </summary> | ||
157 | /// <param name="sceneObject"></param> | ||
158 | /// <param name="writer"></param> | ||
159 | /// <param name="noRootElement">If false, don't write the enclosing SceneObjectGroup element</param> | ||
160 | /// <returns></returns> | ||
161 | public static void ToOriginalXmlFormat(SceneObjectGroup sceneObject, XmlTextWriter writer, bool noRootElement) | ||
162 | { | ||
150 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); | 163 | //m_log.DebugFormat("[SERIALIZER]: Starting serialization of {0}", Name); |
151 | //int time = System.Environment.TickCount; | 164 | //int time = System.Environment.TickCount; |
152 | 165 | ||
153 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | 166 | if (!noRootElement) |
167 | writer.WriteStartElement(String.Empty, "SceneObjectGroup", String.Empty); | ||
168 | |||
154 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); | 169 | writer.WriteStartElement(String.Empty, "RootPart", String.Empty); |
155 | ToXmlFormat(sceneObject.RootPart, writer); | 170 | ToXmlFormat(sceneObject.RootPart, writer); |
156 | writer.WriteEndElement(); | 171 | writer.WriteEndElement(); |
@@ -170,10 +185,12 @@ namespace OpenSim.Region.Framework.Scenes.Serialization | |||
170 | 185 | ||
171 | writer.WriteEndElement(); // OtherParts | 186 | writer.WriteEndElement(); // OtherParts |
172 | sceneObject.SaveScriptedState(writer); | 187 | sceneObject.SaveScriptedState(writer); |
173 | writer.WriteEndElement(); // SceneObjectGroup | 188 | |
189 | if (!noRootElement) | ||
190 | writer.WriteEndElement(); // SceneObjectGroup | ||
174 | 191 | ||
175 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); | 192 | //m_log.DebugFormat("[SERIALIZER]: Finished serialization of SOG {0}, {1}ms", Name, System.Environment.TickCount - time); |
176 | } | 193 | } |
177 | 194 | ||
178 | protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) | 195 | protected static void ToXmlFormat(SceneObjectPart part, XmlTextWriter writer) |
179 | { | 196 | { |