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.cs97
1 files changed, 61 insertions, 36 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 542d454..cbb4fe7 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,84 @@ 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 reader = new XmlTextReader(xmlData, XmlNodeType.Element, null))
2216 objlist.Add(g); 2218 {
2217 veclist.Add(new Vector3(0, 0, 0)); 2219 reader.Read();
2218 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); 2220 bool isSingleObject = reader.Name != "CoalescedObject";
2219 return true; 2221
2222 if (isSingleObject || isAttachment)
2223 {
2224 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(reader);
2225 objlist.Add(g);
2226 veclist.Add(Vector3.Zero);
2227 bbox = g.GetAxisAlignedBoundingBox(out offsetHeight);
2228 return true;
2229 }
2230 else
2231 {
2232 XmlDocument doc = new XmlDocument();
2233 doc.LoadXml(xmlData);
2234 XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject");
2235 XmlElement coll = (XmlElement)e;
2236 float bx = Convert.ToSingle(coll.GetAttribute("x"));
2237 float by = Convert.ToSingle(coll.GetAttribute("y"));
2238 float bz = Convert.ToSingle(coll.GetAttribute("z"));
2239 bbox = new Vector3(bx, by, bz);
2240 offsetHeight = 0;
2241
2242 XmlNodeList groups = e.SelectNodes("SceneObjectGroup");
2243 foreach (XmlNode n in groups)
2244 {
2245 SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml);
2246 objlist.Add(g);
2247
2248 XmlElement el = (XmlElement)n;
2249 string rawX = el.GetAttribute("offsetx");
2250 string rawY = el.GetAttribute("offsety");
2251 string rawZ = el.GetAttribute("offsetz");
2252
2253 float x = Convert.ToSingle(rawX);
2254 float y = Convert.ToSingle(rawY);
2255 float z = Convert.ToSingle(rawZ);
2256 veclist.Add(new Vector3(x, y, z));
2257 }
2258
2259 return false;
2260 }
2261 }
2220 } 2262 }
2221 else 2263 catch (Exception e)
2222 { 2264 {
2223 XmlElement coll = (XmlElement)e; 2265 m_log.Error(
2224 float bx = Convert.ToSingle(coll.GetAttribute("x")); 2266 "[AGENT INVENTORY]: Deserialization of xml failed when looking for CoalescedObject tag. Exception ",
2225 float by = Convert.ToSingle(coll.GetAttribute("y")); 2267 e);
2226 float bz = Convert.ToSingle(coll.GetAttribute("z"));
2227 bbox = new Vector3(bx, by, bz);
2228 offsetHeight = 0;
2229 2268
2230 XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); 2269 bbox = Vector3.Zero;
2231 foreach (XmlNode n in groups) 2270 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 } 2271 }
2247 2272
2248 return false; 2273 return true;
2249 } 2274 }
2250 2275
2251 /// <summary> 2276 /// <summary>