diff options
Merge branch 'master' into careminster
Conflicts:
OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.Inventory.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | 135 |
1 files changed, 113 insertions, 22 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index 659bde9..f384462 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -31,6 +31,7 @@ using System.Collections; | |||
31 | using System.Reflection; | 31 | using System.Reflection; |
32 | using System.Text; | 32 | using System.Text; |
33 | using System.Timers; | 33 | using System.Timers; |
34 | using System.Xml; | ||
34 | using OpenMetaverse; | 35 | using OpenMetaverse; |
35 | using OpenMetaverse.Packets; | 36 | using OpenMetaverse.Packets; |
36 | using log4net; | 37 | using log4net; |
@@ -2301,6 +2302,85 @@ namespace OpenSim.Region.Framework.Scenes | |||
2301 | } | 2302 | } |
2302 | 2303 | ||
2303 | /// <summary> | 2304 | /// <summary> |
2305 | /// Returns the list of Scene Objects in an asset. | ||
2306 | /// </summary> | ||
2307 | /// <remarks> | ||
2308 | /// Returns one object if the asset is a regular object, and multiple objects for a coalesced object. | ||
2309 | /// </remarks> | ||
2310 | /// <param name="assetData">Asset data</param> | ||
2311 | /// <param name="attachment">Whether the item is an attachment</param> | ||
2312 | /// <param name="objlist">The objects included in the asset</param> | ||
2313 | /// <param name="veclist">Relative positions of the objects</param> | ||
2314 | /// <param name="bbox">Bounding box of all the objects</param> | ||
2315 | /// <param name="offsetHeight">Offset in the Z axis from the centre of the bounding box | ||
2316 | /// to the centre of the root prim (relevant only when returning a single object)</param> | ||
2317 | /// <returns>true = returning a single object; false = multiple objects</returns> | ||
2318 | public bool GetObjectsToRez(byte[] assetData, bool attachment, out List<SceneObjectGroup> objlist, out List<Vector3> veclist, | ||
2319 | out Vector3 bbox, out float offsetHeight) | ||
2320 | { | ||
2321 | objlist = new List<SceneObjectGroup>(); | ||
2322 | veclist = new List<Vector3>(); | ||
2323 | |||
2324 | XmlDocument doc = new XmlDocument(); | ||
2325 | string xmlData = Utils.BytesToString(assetData); | ||
2326 | doc.LoadXml(xmlData); | ||
2327 | XmlElement e = (XmlElement)doc.SelectSingleNode("/CoalescedObject"); | ||
2328 | |||
2329 | if (e == null || attachment) // Single | ||
2330 | { | ||
2331 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(xmlData); | ||
2332 | |||
2333 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2334 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
2335 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2336 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2337 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2338 | g.RootPart.Shape.State = 0; | ||
2339 | |||
2340 | objlist.Add(g); | ||
2341 | veclist.Add(new Vector3(0, 0, 0)); | ||
2342 | bbox = g.GetAxisAlignedBoundingBox(out offsetHeight); | ||
2343 | return true; | ||
2344 | } | ||
2345 | else | ||
2346 | { | ||
2347 | XmlElement coll = (XmlElement)e; | ||
2348 | float bx = Convert.ToSingle(coll.GetAttribute("x")); | ||
2349 | float by = Convert.ToSingle(coll.GetAttribute("y")); | ||
2350 | float bz = Convert.ToSingle(coll.GetAttribute("z")); | ||
2351 | bbox = new Vector3(bx, by, bz); | ||
2352 | offsetHeight = 0; | ||
2353 | |||
2354 | XmlNodeList groups = e.SelectNodes("SceneObjectGroup"); | ||
2355 | foreach (XmlNode n in groups) | ||
2356 | { | ||
2357 | SceneObjectGroup g = SceneObjectSerializer.FromOriginalXmlFormat(n.OuterXml); | ||
2358 | |||
2359 | g.RootPart.AttachPoint = g.RootPart.Shape.State; | ||
2360 | g.RootPart.AttachOffset = g.AbsolutePosition; | ||
2361 | g.RootPart.AttachRotation = g.GroupRotation; | ||
2362 | if (g.RootPart.Shape.PCode != (byte)PCode.NewTree && | ||
2363 | g.RootPart.Shape.PCode != (byte)PCode.Tree) | ||
2364 | g.RootPart.Shape.State = 0; | ||
2365 | |||
2366 | objlist.Add(g); | ||
2367 | |||
2368 | XmlElement el = (XmlElement)n; | ||
2369 | string rawX = el.GetAttribute("offsetx"); | ||
2370 | string rawY = el.GetAttribute("offsety"); | ||
2371 | string rawZ = el.GetAttribute("offsetz"); | ||
2372 | |||
2373 | float x = Convert.ToSingle(rawX); | ||
2374 | float y = Convert.ToSingle(rawY); | ||
2375 | float z = Convert.ToSingle(rawZ); | ||
2376 | veclist.Add(new Vector3(x, y, z)); | ||
2377 | } | ||
2378 | } | ||
2379 | |||
2380 | return false; | ||
2381 | } | ||
2382 | |||
2383 | /// <summary> | ||
2304 | /// Event Handler Rez an object into a scene | 2384 | /// Event Handler Rez an object into a scene |
2305 | /// Calls the non-void event handler | 2385 | /// Calls the non-void event handler |
2306 | /// </summary> | 2386 | /// </summary> |
@@ -2375,19 +2455,25 @@ namespace OpenSim.Region.Framework.Scenes | |||
2375 | /// will be used if it exists.</param> | 2455 | /// will be used if it exists.</param> |
2376 | /// <param name="vel">The velocity of the rezzed object.</param> | 2456 | /// <param name="vel">The velocity of the rezzed object.</param> |
2377 | /// <param name="param"></param> | 2457 | /// <param name="param"></param> |
2378 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful</returns> | 2458 | /// <returns>The SceneObjectGroup(s) rezzed, or null if rez was unsuccessful</returns> |
2379 | public virtual SceneObjectGroup RezObject( | 2459 | public virtual List<SceneObjectGroup> RezObject( |
2380 | SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) | 2460 | SceneObjectPart sourcePart, TaskInventoryItem item, Vector3 pos, Quaternion? rot, Vector3 vel, int param) |
2381 | { | 2461 | { |
2382 | if (null == item) | 2462 | if (null == item) |
2383 | return null; | 2463 | return null; |
2464 | |||
2465 | List<SceneObjectGroup> objlist; | ||
2466 | List<Vector3> veclist; | ||
2384 | 2467 | ||
2385 | SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item); | 2468 | bool success = sourcePart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); |
2386 | 2469 | if (!success) | |
2387 | if (null == group) | ||
2388 | return null; | 2470 | return null; |
2389 | 2471 | ||
2390 | if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos)) | 2472 | int totalPrims = 0; |
2473 | foreach (SceneObjectGroup group in objlist) | ||
2474 | totalPrims += group.PrimCount; | ||
2475 | |||
2476 | if (!Permissions.CanRezObject(totalPrims, item.OwnerID, pos)) | ||
2391 | return null; | 2477 | return null; |
2392 | 2478 | ||
2393 | if (!Permissions.BypassPermissions()) | 2479 | if (!Permissions.BypassPermissions()) |
@@ -2396,23 +2482,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
2396 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); | 2482 | sourcePart.Inventory.RemoveInventoryItem(item.ItemID); |
2397 | } | 2483 | } |
2398 | 2484 | ||
2399 | 2485 | for (int i = 0; i < objlist.Count; i++) | |
2400 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) | ||
2401 | { | 2486 | { |
2402 | group.RootPart.AttachedPos = group.AbsolutePosition; | 2487 | SceneObjectGroup group = objlist[i]; |
2403 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; | 2488 | Vector3 curpos = pos + veclist[i]; |
2489 | |||
2490 | if (group.IsAttachment == false && group.RootPart.Shape.State != 0) | ||
2491 | { | ||
2492 | group.RootPart.AttachedPos = group.AbsolutePosition; | ||
2493 | group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; | ||
2494 | } | ||
2495 | |||
2496 | group.FromPartID = sourcePart.UUID; | ||
2497 | AddNewSceneObject(group, true, curpos, rot, vel); | ||
2498 | |||
2499 | // We can only call this after adding the scene object, since the scene object references the scene | ||
2500 | // to find out if scripts should be activated at all. | ||
2501 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); | ||
2502 | |||
2503 | group.ScheduleGroupForFullUpdate(); | ||
2404 | } | 2504 | } |
2405 | 2505 | ||
2406 | group.FromPartID = sourcePart.UUID; | 2506 | return objlist; |
2407 | AddNewSceneObject(group, true, pos, rot, vel); | ||
2408 | |||
2409 | // We can only call this after adding the scene object, since the scene object references the scene | ||
2410 | // to find out if scripts should be activated at all. | ||
2411 | group.CreateScriptInstances(param, true, DefaultScriptEngine, 3); | ||
2412 | |||
2413 | group.ScheduleGroupForFullUpdate(); | ||
2414 | |||
2415 | return group; | ||
2416 | } | 2507 | } |
2417 | 2508 | ||
2418 | public virtual bool returnObjects(SceneObjectGroup[] returnobjects, | 2509 | public virtual bool returnObjects(SceneObjectGroup[] returnobjects, |