diff --git a/CONTRIBUTORS.txt b/CONTRIBUTORS.txt index ef84315cc7..9114fc578a 100644 --- a/CONTRIBUTORS.txt +++ b/CONTRIBUTORS.txt @@ -75,6 +75,7 @@ what it is today. * Chris Yeoh (IBM) * controlbreak * coyled +* ctrlaltdavid (David Rowe) * Daedius * daTwitch * devalnor-#708 diff --git a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs index 5453420bce..cf2e037e26 100644 --- a/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs +++ b/OpenSim/ApplicationPlugins/RemoteController/RemoteAdminPlugin.cs @@ -2942,15 +2942,13 @@ namespace OpenSim.ApplicationPlugins.RemoteController /// private void ApplyNextOwnerPermissions(InventoryItemBase item) { - if (item.InvType == (int)InventoryType.Object && (item.CurrentPermissions & 7) != 0) + if (item.InvType == (int)InventoryType.Object) { - if ((item.CurrentPermissions & ((uint)PermissionMask.Copy >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Copy; - if ((item.CurrentPermissions & ((uint)PermissionMask.Transfer >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Transfer; - if ((item.CurrentPermissions & ((uint)PermissionMask.Modify >> 13)) == 0) - item.CurrentPermissions &= ~(uint)PermissionMask.Modify; + uint perms = item.CurrentPermissions; + PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref perms); + item.CurrentPermissions = perms; } + item.CurrentPermissions &= item.NextPermissions; item.BasePermissions &= item.NextPermissions; item.EveryOnePermissions &= item.NextPermissions; diff --git a/OpenSim/Framework/PermissionsUtil.cs b/OpenSim/Framework/PermissionsUtil.cs new file mode 100644 index 0000000000..d785a781f5 --- /dev/null +++ b/OpenSim/Framework/PermissionsUtil.cs @@ -0,0 +1,87 @@ +/* + * Copyright (c) Contributors, http://opensimulator.org/ + * See CONTRIBUTORS.TXT for a full list of copyright holders. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of the OpenSimulator Project nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +using System; +using System.Collections.Generic; +using System.Reflection; +using System.Text; +using log4net; + +namespace OpenSim.Framework +{ + public static class PermissionsUtil + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + + /// + /// Logs permissions flags. Useful when debugging permission problems. + /// + /// + public static void LogPermissions(String name, String message, uint basePerm, uint curPerm, uint nextPerm) + { + m_log.DebugFormat("Permissions of \"{0}\" at \"{1}\": Base {2} ({3:X4}), Current {4} ({5:X4}), NextOwner {6} ({7:X4})", + name, message, + PermissionsToString(basePerm), basePerm, PermissionsToString(curPerm), curPerm, PermissionsToString(nextPerm), nextPerm); + } + + /// + /// Converts a permissions bit-mask to a string (e.g., "MCT"). + /// + private static string PermissionsToString(uint perms) + { + string str = ""; + if ((perms & (int)PermissionMask.Modify) != 0) + str += "M"; + if ((perms & (int)PermissionMask.Copy) != 0) + str += "C"; + if ((perms & (int)PermissionMask.Transfer) != 0) + str += "T"; + if (str == "") + str = "."; + return str; + } + + /// + /// Applies an object's folded permissions to its regular permissions. + /// + /// The folded permissions. Only the lowest 7 bits are examined. + /// The permissions variable to modify. + public static void ApplyFoldedPermissions(uint foldedPerms, ref uint mainPerms) + { + if ((foldedPerms & 7) == 0) + return; // assume that if the folded permissions are 0 then this means that they weren't actually recorded + + if ((foldedPerms & ((uint)PermissionMask.Copy >> 13)) == 0) + mainPerms &= ~(uint)PermissionMask.Copy; + if ((foldedPerms & ((uint)PermissionMask.Transfer >> 13)) == 0) + mainPerms &= ~(uint)PermissionMask.Transfer; + if ((foldedPerms & ((uint)PermissionMask.Modify >> 13)) == 0) + mainPerms &= ~(uint)PermissionMask.Modify; + } + + } +} diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 87a53ff5ba..eefbde5d7e 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs @@ -2084,8 +2084,10 @@ namespace OpenSim.Framework #region Xml Serialization Utilities public static bool ReadBoolean(XmlTextReader reader) { + // AuroraSim uses "int" for some fields that are boolean in OpenSim, e.g. "PassCollisions". Don't fail because of this. reader.ReadStartElement(); - bool result = Boolean.Parse(reader.ReadContentAsString().ToLower()); + string val = reader.ReadContentAsString().ToLower(); + bool result = val.Equals("true") || val.Equals("1"); reader.ReadEndElement(); return result; diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs index 6251266d52..fadcd5eecf 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs @@ -439,17 +439,28 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (item == null) return null; + + item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); + item.CreatorData = objlist[0].RootPart.CreatorData; - // Can't know creator is the same, so null it in inventory if (objlist.Count > 1) { - item.CreatorId = UUID.Zero.ToString(); item.Flags = (uint)InventoryItemFlags.ObjectHasMultipleItems; + + // If the objects have different creators then don't specify a creator at all + foreach (SceneObjectGroup objectGroup in objlist) + { + if ((objectGroup.RootPart.CreatorID.ToString() != item.CreatorId) + || (objectGroup.RootPart.CreatorData.ToString() != item.CreatorData)) + { + item.CreatorId = UUID.Zero.ToString(); + item.CreatorData = string.Empty; + break; + } + } } else { - item.CreatorId = objlist[0].RootPart.CreatorID.ToString(); - item.CreatorData = objlist[0].RootPart.CreatorData; item.SaleType = objlist[0].RootPart.ObjectSaleType; item.SalePrice = objlist[0].RootPart.SalePrice; } @@ -470,13 +481,13 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } else { - AddPermissions(item, objlist[0], objlist, remoteClient); - item.CreationDate = Util.UnixTimeSinceEpoch(); item.Description = asset.Description; item.Name = asset.Name; item.AssetType = asset.Type; + AddPermissions(item, objlist[0], objlist, remoteClient); + m_Scene.AddInventoryItem(item); if (remoteClient != null && item.Owner == remoteClient.AgentId) @@ -531,16 +542,12 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess } effectivePerms |= (uint)PermissionMask.Move; + //PermissionsUtil.LogPermissions(item.Name, "Before AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); + if (remoteClient != null && (remoteClient.AgentId != so.RootPart.OwnerID) && m_Scene.Permissions.PropagatePermissions()) { uint perms = effectivePerms; - uint nextPerms = (perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; + PermissionsUtil.ApplyFoldedPermissions(effectivePerms, ref perms); item.BasePermissions = perms & so.RootPart.NextOwnerMask; item.CurrentPermissions = item.BasePermissions; @@ -548,10 +555,8 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess item.EveryOnePermissions = so.RootPart.EveryoneMask & so.RootPart.NextOwnerMask; item.GroupPermissions = so.RootPart.GroupMask & so.RootPart.NextOwnerMask; - // Magic number badness. Maybe this deserves an enum. - // bit 4 (16) is the "Slam" bit, it means treat as passed - // and apply next owner perms on rez - item.CurrentPermissions |= 16; // Slam! + // apply next owner perms on rez + item.CurrentPermissions |= SceneObjectGroup.SLAM; } else { @@ -568,8 +573,10 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess (uint)PermissionMask.Move | (uint)PermissionMask.Export | 7); // Preserve folded permissions - } - + } + + //PermissionsUtil.LogPermissions(item.Name, "After AddPermissions", item.BasePermissions, item.CurrentPermissions, item.NextPermissions); + return item; } @@ -864,11 +871,15 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; } - foreach (SceneObjectPart part in group.Parts) + if (item == null) { - // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. - part.LastOwnerID = part.OwnerID; - part.OwnerID = remoteClient.AgentId; + // Change ownership. Normally this is done in DoPreRezWhenFromItem(), but in this case we must do it here. + foreach (SceneObjectPart part in group.Parts) + { + // Make the rezzer the owner, as this is not necessarily set correctly in the serialized asset. + part.LastOwnerID = part.OwnerID; + part.OwnerID = remoteClient.AgentId; + } } if (!attachment) @@ -1077,7 +1088,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess part.GroupMask = item.GroupPermissions; } } - + rootPart.TrimPermissions(); if (isAttachment) diff --git a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs index 28daf2f03b..d4e4c252cc 100644 --- a/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs +++ b/OpenSim/Region/CoreModules/World/Objects/BuySell/BuySellModule.cs @@ -205,13 +205,7 @@ namespace OpenSim.Region.CoreModules.World.Objects.BuySell item.InvType = (int)InventoryType.Object; item.Folder = categoryID; - uint nextPerms=(perms & 7) << 13; - if ((nextPerms & (uint)PermissionMask.Copy) == 0) - perms &= ~(uint)PermissionMask.Copy; - if ((nextPerms & (uint)PermissionMask.Transfer) == 0) - perms &= ~(uint)PermissionMask.Transfer; - if ((nextPerms & (uint)PermissionMask.Modify) == 0) - perms &= ~(uint)PermissionMask.Modify; + PermissionsUtil.ApplyFoldedPermissions(perms, ref perms); item.BasePermissions = perms & part.NextOwnerMask; item.CurrentPermissions = perms & part.NextOwnerMask; diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index f384462ffb..cba75f1aa3 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs @@ -664,17 +664,13 @@ namespace OpenSim.Region.Framework.Scenes // a mask if (item.InvType == (int)InventoryType.Object) { - // Create a safe mask for the current perms - uint foldedPerms = (item.CurrentPermissions & 7) << 13; - foldedPerms |= permsMask; - bool isRootMod = (item.CurrentPermissions & (uint)PermissionMask.Modify) != 0 ? true : false; // Mask the owner perms to the folded perms - ownerPerms &= foldedPerms; - basePerms &= foldedPerms; + PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref ownerPerms); + PermissionsUtil.ApplyFoldedPermissions(item.CurrentPermissions, ref basePerms); // If the root was mod, let the mask reflect that // We also need to adjust the base here, because @@ -1235,9 +1231,16 @@ namespace OpenSim.Region.Framework.Scenes { agentItem.BasePermissions = taskItem.BasePermissions & (taskItem.NextPermissions | (uint)PermissionMask.Move); if (taskItem.InvType == (int)InventoryType.Object) - agentItem.CurrentPermissions = agentItem.BasePermissions & (((taskItem.CurrentPermissions & 7) << 13) | (taskItem.CurrentPermissions & (uint)PermissionMask.Move)); + { + uint perms = taskItem.CurrentPermissions; + PermissionsUtil.ApplyFoldedPermissions(taskItem.CurrentPermissions, ref perms); + agentItem.BasePermissions = perms | (uint)PermissionMask.Move; + agentItem.CurrentPermissions = agentItem.BasePermissions; + } else + { agentItem.CurrentPermissions = agentItem.BasePermissions & taskItem.CurrentPermissions; + } agentItem.Flags |= (uint)InventoryItemFlags.ObjectSlamPerm; agentItem.NextPermissions = taskItem.NextPermissions; diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 9db34fdcdc..2420048db7 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -111,6 +111,9 @@ namespace OpenSim.Region.Framework.Scenes STATUS_ROTATE_Z = 0x008, } + // This flag has the same purpose as InventoryItemFlags.ObjectSlamPerm + public static readonly uint SLAM = 16; + // private PrimCountTaintedDelegate handlerPrimCountTainted = null; /// @@ -3810,13 +3813,10 @@ namespace OpenSim.Region.Framework.Scenes // needs to be called with phys building true Vector3 oldPos; - // FIXME: This improves the situation where editing just the root prim of an attached object would send - // all the other parts to oblivion after detach/reattach. However, a problem remains since the root prim - // still ends up in the wrong position on reattach. if (IsAttachment) - oldPos = RootPart.OffsetPosition; + oldPos = m_rootPart.AttachedPos + m_rootPart.OffsetPosition; // OffsetPosition should always be 0 in an attachments's root prim else - oldPos = AbsolutePosition + RootPart.OffsetPosition; + oldPos = AbsolutePosition + m_rootPart.OffsetPosition; Vector3 diff = oldPos - newPos; Quaternion partRotation = m_rootPart.RotationOffset; @@ -3831,6 +3831,9 @@ namespace OpenSim.Region.Framework.Scenes } AbsolutePosition = newPos; + + if (IsAttachment) + m_rootPart.AttachedPos = newPos; HasGroupChanged = true; if (m_rootPart.Undoing) diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 5851ec6bee..ce9baaac61 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs @@ -5293,6 +5293,64 @@ namespace OpenSim.Region.Framework.Scenes { ParentGroup.AddScriptLPS(count); } + + /// + /// Sets a prim's owner and permissions when it's rezzed. + /// + /// The inventory item from which the item was rezzed + /// True: the item is being rezzed from the user's inventory. False: from a prim's inventory. + /// The scene the prim is being rezzed into + public void ApplyPermissionsOnRez(InventoryItemBase item, bool userInventory, Scene scene) + { + if ((OwnerID != item.Owner) || ((item.CurrentPermissions & SceneObjectGroup.SLAM) != 0) || ((item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0)) + { + if (scene.Permissions.PropagatePermissions()) + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectHasMultipleItems) == 0) + { + // Apply the item's permissions to the object + //LogPermissions("Before applying item permissions"); + if (userInventory) + { + EveryoneMask = item.EveryOnePermissions; + NextOwnerMask = item.NextPermissions; + } + else + { + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) + EveryoneMask = item.EveryOnePermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) + NextOwnerMask = item.NextPermissions; + if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) + GroupMask = item.GroupPermissions; + } + //LogPermissions("After applying item permissions"); + } + } + + GroupMask = 0; // DO NOT propagate here + } + + if (OwnerID != item.Owner) + { + //LogPermissions("Before ApplyNextOwnerPermissions"); + ApplyNextOwnerPermissions(); + //LogPermissions("After ApplyNextOwnerPermissions"); + + LastOwnerID = OwnerID; + OwnerID = item.Owner; + Inventory.ChangeInventoryOwner(item.Owner); + } + } + + /// + /// Logs the prim's permissions. Useful when debugging permission problems. + /// + /// + private void LogPermissions(String message) + { + PermissionsUtil.LogPermissions(Name, message, BaseMask, OwnerMask, NextOwnerMask); + } public void ApplyNextOwnerPermissions() { diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index b4fc47229b..8893cc0ade 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs @@ -916,48 +916,27 @@ namespace OpenSim.Region.Framework.Scenes // Since renaming the item in the inventory does not affect the name stored // in the serialization, transfer the correct name from the inventory to the // object itself before we rez. - rootPart.Name = item.Name; - rootPart.Description = item.Description; - - SceneObjectPart[] partList = group.Parts; + // Only do these for the first object if we are rezzing a coalescence. + if (i == 0) + { + rootPart.Name = item.Name; + rootPart.Description = item.Description; + } group.SetGroup(m_part.GroupID, null); - // TODO: Remove magic number badness - if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number + foreach (SceneObjectPart part in group.Parts) { - if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions()) - { - foreach (SceneObjectPart part in partList) - { - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) - part.EveryoneMask = item.EveryonePermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) - part.NextOwnerMask = item.NextPermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) - part.GroupMask = item.GroupPermissions; - } + // Convert between InventoryItem classes. You can never have too many similar but slightly different classes :) + InventoryItemBase dest = new InventoryItemBase(item.ItemID, item.OwnerID); + dest.BasePermissions = item.BasePermissions; + dest.CurrentPermissions = item.CurrentPermissions; + dest.EveryOnePermissions = item.EveryonePermissions; + dest.GroupPermissions = item.GroupPermissions; + dest.NextPermissions = item.NextPermissions; + dest.Flags = item.Flags; - group.ApplyNextOwnerPermissions(); - } - } - - foreach (SceneObjectPart part in partList) - { - // TODO: Remove magic number badness - if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0 || (item.Flags & (uint)InventoryItemFlags.ObjectSlamPerm) != 0) // Magic number - { - part.LastOwnerID = part.OwnerID; - part.OwnerID = item.OwnerID; - part.Inventory.ChangeInventoryOwner(item.OwnerID); - } - - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteEveryone) != 0) - part.EveryoneMask = item.EveryonePermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteNextOwner) != 0) - part.NextOwnerMask = item.NextPermissions; - if ((item.Flags & (uint)InventoryItemFlags.ObjectOverwriteGroup) != 0) - part.GroupMask = item.GroupPermissions; + part.ApplyPermissionsOnRez(dest, false, m_part.ParentGroup.Scene); } rootPart.TrimPermissions(); diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 8ff17f6d5c..252c72fc1f 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs @@ -1903,6 +1903,8 @@ namespace OpenSim.Region.Framework.Scenes ControllingClient.SendAgentTerseUpdate(this); PhysicsActor actor = PhysicsActor; + + // This will be the case if the agent is sitting on the groudn or on an object. if (actor == null) { SendControlsToScripts(flagsForScripts); diff --git a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs index 5a0a14cd74..fe5ff6ccd6 100755 --- a/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs +++ b/OpenSim/Region/Physics/BulletSPlugin/BSShapes.cs @@ -71,7 +71,7 @@ public abstract class BSShape lastReferenced = DateTime.Now; } - // Called when this shape is being used again. + // Called when this shape is done being used. protected virtual void DecrementReference() { referenceCount--; @@ -868,6 +868,8 @@ public class BSShapeHull : BSShape public class BSShapeCompound : BSShape { private static string LogHeader = "[BULLETSIM SHAPE COMPOUND]"; + public static Dictionary CompoundShapes = new Dictionary(); + public BSShapeCompound(BulletShape pShape) : base(pShape) { } @@ -875,7 +877,9 @@ public class BSShapeCompound : BSShape { // Base compound shapes are not shared so this returns a raw shape. // A built compound shape can be reused in linksets. - return new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); + BSShapeCompound ret = new BSShapeCompound(CreatePhysicalCompoundShape(physicsScene)); + CompoundShapes.Add(ret.AddrString, ret); + return ret; } public override BSShape GetReference(BSScene physicsScene, BSPhysObject prim) { @@ -913,10 +917,21 @@ public class BSShapeCompound : BSShape BulletShape childShape = physicsScene.PE.RemoveChildShapeFromCompoundShapeIndex(physShapeInfo, ii); DereferenceAnonCollisionShape(physicsScene, childShape); } + + lock (CompoundShapes) + CompoundShapes.Remove(physShapeInfo.AddrString); physicsScene.PE.DeleteCollisionShape(physicsScene.World, physShapeInfo); } } } + public static bool TryGetCompoundByPtr(BulletShape pShape, out BSShapeCompound outCompound) + { + lock (CompoundShapes) + { + string addr = pShape.AddrString; + return CompoundShapes.TryGetValue(addr, out outCompound); + } + } private static BulletShape CreatePhysicalCompoundShape(BSScene physicsScene) { BulletShape cShape = physicsScene.PE.CreateCompoundShape(physicsScene.World, false); @@ -928,10 +943,13 @@ public class BSShapeCompound : BSShape private void DereferenceAnonCollisionShape(BSScene physicsScene, BulletShape pShape) { // TODO: figure a better way to go through all the shape types and find a possible instance. + physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,shape={1}", + BSScene.DetailLogZero, pShape); BSShapeMesh meshDesc; if (BSShapeMesh.TryGetMeshByPtr(pShape, out meshDesc)) { meshDesc.Dereference(physicsScene); + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundMesh,shape={1}", BSScene.DetailLogZero, pShape); } else { @@ -939,13 +957,15 @@ public class BSShapeCompound : BSShape if (BSShapeHull.TryGetHullByPtr(pShape, out hullDesc)) { hullDesc.Dereference(physicsScene); + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundHull,shape={1}", BSScene.DetailLogZero, pShape); } else { BSShapeConvexHull chullDesc; - if (BSShapeConvexHull.TryGetHullByPtr(pShape, out chullDesc)) + if (BSShapeConvexHull.TryGetConvexHullByPtr(pShape, out chullDesc)) { chullDesc.Dereference(physicsScene); + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundConvexHull,shape={1}", BSScene.DetailLogZero, pShape); } else { @@ -953,20 +973,23 @@ public class BSShapeCompound : BSShape if (BSShapeGImpact.TryGetGImpactByPtr(pShape, out gImpactDesc)) { gImpactDesc.Dereference(physicsScene); + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,foundgImpact,shape={1}", BSScene.DetailLogZero, pShape); } else { // Didn't find it in the lists of specific types. It could be compound. - if (physicsScene.PE.IsCompound(pShape)) + BSShapeCompound compoundDesc; + if (BSShapeCompound.TryGetCompoundByPtr(pShape, out compoundDesc)) { - BSShapeCompound recursiveCompound = new BSShapeCompound(pShape); - recursiveCompound.Dereference(physicsScene); + compoundDesc.Dereference(physicsScene); + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,recursiveCompoundShape,shape={1}", BSScene.DetailLogZero, pShape); } else { // If none of the above, maybe it is a simple native shape. if (physicsScene.PE.IsNativeShape(pShape)) { + // physicsScene.DetailLog("{0},BSShapeCompound.DereferenceAnonCollisionShape,assumingNative,shape={1}", BSScene.DetailLogZero, pShape); BSShapeNative nativeShape = new BSShapeNative(pShape); nativeShape.Dereference(physicsScene); } @@ -1023,6 +1046,8 @@ public class BSShapeConvexHull : BSShape convexShape = physicsScene.PE.BuildConvexHullShapeFromMesh(physicsScene.World, baseMesh.physShapeInfo); convexShape.shapeKey = newMeshKey; ConvexHulls.Add(convexShape.shapeKey, retConvexHull); + physicsScene.DetailLog("{0},BSShapeConvexHull.GetReference,addingNewlyCreatedShape,shape={1}", + BSScene.DetailLogZero, convexShape); } // Done with the base mesh @@ -1051,7 +1076,7 @@ public class BSShapeConvexHull : BSShape } } // Loop through all the known hulls and return the description based on the physical address. - public static bool TryGetHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) + public static bool TryGetConvexHullByPtr(BulletShape pShape, out BSShapeConvexHull outHull) { bool ret = false; BSShapeConvexHull foundDesc = null; diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index 74f4f4b029..cfec6303ca 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -4812,6 +4812,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api UUID av = new UUID(); if (!UUID.TryParse(agent,out av)) { + LSLError("First parameter to llTextBox needs to be a key"); return; } diff --git a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs index 5f5b7a70f6..32ea4eef29 100644 --- a/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/UserAgentServiceConnector.cs @@ -555,7 +555,7 @@ namespace OpenSim.Services.Connectors.Hypergrid } catch { - m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs", m_ServerURL); + m_log.DebugFormat("[USER AGENT CONNECTOR]: Unable to contact remote server {0} for GetServerURLs for user {1}", m_ServerURL, userID); // reason = "Exception: " + e.Message; return serverURLs; } diff --git a/bin/assets/ScriptsAssetSet/ScriptsAssetSet.xml b/bin/assets/ScriptsAssetSet/ScriptsAssetSet.xml index c76cb78ee2..eae9642275 100644 --- a/bin/assets/ScriptsAssetSet/ScriptsAssetSet.xml +++ b/bin/assets/ScriptsAssetSet/ScriptsAssetSet.xml @@ -89,9 +89,9 @@ -
+
- +
@@ -240,4 +240,4 @@
- \ No newline at end of file + diff --git a/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml b/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml index df9d867b5d..6e51d0bd78 100644 --- a/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml +++ b/bin/inventory/ScriptsLibrary/ScriptsLibraryItems.xml @@ -195,7 +195,7 @@
- +