aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs100
1 files changed, 64 insertions, 36 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 542d454..3489873 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.Collections; 30using System.Collections;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Threading;
33using System.Timers; 34using System.Timers;
34using System.Xml; 35using System.Xml;
35using OpenMetaverse; 36using OpenMetaverse;
@@ -2192,60 +2193,87 @@ namespace OpenSim.Region.Framework.Scenes
2192 /// Returns one object if the asset is a regular object, and multiple objects for a coalesced object. 2193 /// Returns one object if the asset is a regular object, and multiple objects for a coalesced object.
2193 /// </remarks> 2194 /// </remarks>
2194 /// <param name="assetData">Asset data</param> 2195 /// <param name="assetData">Asset data</param>
2195 /// <param name="attachment">Whether the item is an attachment</param> 2196 /// <param name="isAttachment">True if the object is an attachment.</param>
2196 /// <param name="objlist">The objects included in the asset</param> 2197 /// <param name="objlist">The objects included in the asset</param>
2197 /// <param name="veclist">Relative positions of the objects</param> 2198 /// <param name="veclist">Relative positions of the objects</param>
2198 /// <param name="bbox">Bounding box of all the objects</param> 2199 /// <param name="bbox">Bounding box of all the objects</param>
2199 /// <param name="offsetHeight">Offset in the Z axis from the centre of the bounding box 2200 /// <param name="offsetHeight">Offset in the Z axis from the centre of the bounding box
2200 /// to the centre of the root prim (relevant only when returning a single object)</param> 2201 /// to the centre of the root prim (relevant only when returning a single object)</param>
2201 /// <returns>true = returning a single object; false = multiple objects</returns> 2202 /// <returns>
2202 public bool GetObjectsToRez(byte[] assetData, bool attachment, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, 2203 /// true if returning a single object or deserialization fails, false if returning the coalesced
2204 /// list of objects
2205 /// </returns>
2206 public bool GetObjectsToRez(
2207 byte[] assetData, bool isAttachment, out List<SceneObjectGroup> objlist, out List<Vector3> veclist,
2203 out Vector3 bbox, out float offsetHeight) 2208 out Vector3 bbox, out float offsetHeight)
2204 { 2209 {
2205 objlist = new List<SceneObjectGroup>(); 2210 objlist = new List<SceneObjectGroup>();
2206 veclist = new List<Vector3>(); 2211 veclist = new List<Vector3>();
2207 2212
2208 XmlDocument doc = new XmlDocument();
2209 string xmlData = Utils.BytesToString(assetData); 2213 string xmlData = Utils.BytesToString(assetData);
2210 doc.LoadXml(xmlData);
2211 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
2212 2214
2213 if (e == null || attachment) // Single 2215 try
2214 { 2216 {
2215 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); 2217 using (XmlTextReader wrappedReader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
2216 objlist.Add(g); 2218 {
2217 veclist.Add(new Vector3(0, 0, 0)); 2219 using (XmlReader reader = XmlReader.Create(wrappedReader, new XmlReaderSettings() { IgnoreWhitespace = true, ConformanceLevel = ConformanceLevel.Fragment }))
2218 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); 2220 {
2219 return true; 2221 reader.Read();
2222 bool isSingleObject = reader.Name != "CoalescedObject";
2223
2224 if (isSingleObject || isAttachment)
2225 {
2226 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(reader);
2227 objlist.Add(g);
2228 veclist.Add(Vector3.Zero);
2229 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight);
2230 return true;
2231 }
2232 else
2233 {
2234 XmlDocument doc = new XmlDocument();
2235 doc.LoadXml(xmlData);
2236 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
2237 XmlElement coll = (XmlElement)e;
2238 float bx = Convert.ToSingle(coll.GetAttribute("x"));
2239 float by = Convert.ToSingle(coll.GetAttribute("y"));
2240 float bz = Convert.ToSingle(coll.GetAttribute("z"));
2241 bbox = new Vector3(bx, by, bz);
2242 offsetHeight = 0;
2243
2244 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
2245 foreach (XmlNode n in groups)
2246 {
2247 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
2248 objlist.Add(g);
2249
2250 XmlElement el = (XmlElement)n;
2251 string rawX = el.GetAttribute("offsetx");
2252 string rawY = el.GetAttribute("offsety");
2253 string rawZ = el.GetAttribute("offsetz");
2254
2255 float x = Convert.ToSingle(rawX);
2256 float y = Convert.ToSingle(rawY);
2257 float z = Convert.ToSingle(rawZ);
2258 veclist.Add(new Vector3(x, y, z));
2259 }
2260
2261 return false;
2262 }
2263 }
2264 }
2220 } 2265 }
2221 else 2266 catch (Exception e)
2222 { 2267 {
2223 XmlElement coll = (XmlElement)e; 2268 m_log.Error(
2224 float bx = Convert.ToSingle(coll.GetAttribute("x")); 2269 "[AGENT INVENTORY]: Deserialization of xml failed when looking for CoalescedObject tag. Exception ",
2225 float by = Convert.ToSingle(coll.GetAttribute("y")); 2270 e);
2226 float bz = Convert.ToSingle(coll.GetAttribute("z"));
2227 bbox = new Vector3(bx, by, bz);
2228 offsetHeight = 0;
2229 2271
2230 XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); 2272 bbox = Vector3.Zero;
2231 foreach (XmlNode n in groups) 2273 offsetHeight = 0;
2232 {
2233 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
2234 objlist.Add(g);
2235
2236 XmlElement el = (XmlElement)n;
2237 string rawX = el.GetAttribute("offsetx");
2238 string rawY = el.GetAttribute("offsety");
2239 string rawZ = el.GetAttribute("offsetz");
2240
2241 float x = Convert.ToSingle(rawX);
2242 float y = Convert.ToSingle(rawY);
2243 float z = Convert.ToSingle(rawZ);
2244 veclist.Add(new Vector3(x, y, z));
2245 }
2246 } 2274 }
2247 2275
2248 return false; 2276 return true;
2249 } 2277 }
2250 2278
2251 /// <summary> 2279 /// <summary>