Merge branch 'master' into careminster-presence-refactor

This was rather conflicted. Please test linking.
This commit is contained in:
Melanie
2010-08-26 00:11:07 +01:00
23 changed files with 1279 additions and 609 deletions

View File

@@ -2022,60 +2022,13 @@ namespace OpenSim.Region.Framework.Scenes
if (null == item)
return null;
UUID ownerID = item.OwnerID;
AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
if (null == rezAsset)
return null;
string xmlData = Utils.BytesToString(rezAsset.Data);
SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
if (!Permissions.CanRezObject(group.Children.Count, ownerID, pos))
return null;
group.ResetIDs();
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
// 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;
List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
group.SetGroup(sourcePart.GroupID, null);
if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
{
if (Permissions.PropagatePermissions())
{
foreach (SceneObjectPart part in partList)
{
part.EveryoneMask = item.EveryonePermissions;
part.NextOwnerMask = item.NextPermissions;
}
group.ApplyNextOwnerPermissions();
}
}
foreach (SceneObjectPart part in partList)
{
if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
{
part.LastOwnerID = part.OwnerID;
part.OwnerID = item.OwnerID;
part.Inventory.ChangeInventoryOwner(item.OwnerID);
}
part.EveryoneMask = item.EveryonePermissions;
part.NextOwnerMask = item.NextPermissions;
}
SceneObjectGroup group = sourcePart.Inventory.GetRezReadySceneObject(item);
rootPart.TrimPermissions();
if (null == group)
return null;
if (!Permissions.CanRezObject(group.PrimCount, item.OwnerID, pos))
return null;
if (!Permissions.BypassPermissions())
{
@@ -2091,7 +2044,7 @@ namespace OpenSim.Region.Framework.Scenes
group.ScheduleGroupForFullUpdate();
return rootPart.ParentGroup;
return group;
}
public virtual bool returnObjects(SceneObjectGroup[] returnobjects, UUID AgentId)
@@ -2151,8 +2104,11 @@ namespace OpenSim.Region.Framework.Scenes
sog.SetGroup(groupID, remoteClient);
sog.ScheduleGroupForFullUpdate();
foreach (SceneObjectPart child in sog.Children.Values)
child.Inventory.ChangeInventoryOwner(ownerID);
lock (sog.Children)
{
foreach (SceneObjectPart child in sog.Children.Values)
child.Inventory.ChangeInventoryOwner(ownerID);
}
}
else
{
@@ -2162,16 +2118,18 @@ namespace OpenSim.Region.Framework.Scenes
if (sog.GroupID != groupID)
continue;
foreach (SceneObjectPart child in sog.Children.Values)
lock (sog.Children)
{
child.LastOwnerID = child.OwnerID;
child.Inventory.ChangeInventoryOwner(groupID);
foreach (SceneObjectPart child in sog.Children.Values)
{
child.LastOwnerID = child.OwnerID;
child.Inventory.ChangeInventoryOwner(groupID);
}
}
sog.SetOwnerId(groupID);
sog.ApplyNextOwnerPermissions();
}
}
}
foreach (uint localID in localIDs)

View File

@@ -156,21 +156,29 @@ namespace OpenSim.Region.Framework.Scenes
}
break;
}
else
{
// We also need to check the children of this prim as they
// can be selected as well and send property information
bool foundPrim = false;
foreach (KeyValuePair<UUID, SceneObjectPart> child in ((SceneObjectGroup) ent).Children)
{
if (child.Value.LocalId == primLocalID)
{
child.Value.GetProperties(remoteClient);
foundPrim = true;
break;
}
}
if (foundPrim) break;
else
{
// We also need to check the children of this prim as they
// can be selected as well and send property information
bool foundPrim = false;
SceneObjectGroup sog = ent as SceneObjectGroup;
lock (sog.Children)
{
foreach (KeyValuePair<UUID, SceneObjectPart> child in (sog.Children))
{
if (child.Value.LocalId == primLocalID)
{
child.Value.GetProperties(remoteClient);
foundPrim = true;
break;
}
}
}
if (foundPrim)
break;
}
}
}

View File

@@ -1790,8 +1790,9 @@ namespace OpenSim.Region.Framework.Scenes
if (group.RootPart == null)
{
m_log.ErrorFormat("[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children",
group.Children == null ? 0 : group.Children.Count);
m_log.ErrorFormat(
"[SCENE]: Found a SceneObjectGroup with m_rootPart == null and {0} children",
group.Children == null ? 0 : group.PrimCount);
}
AddRestoredSceneObject(group, true, true);
@@ -2130,18 +2131,22 @@ namespace OpenSim.Region.Framework.Scenes
group.RemoveScriptInstances(true);
}
foreach (SceneObjectPart part in group.Children.Values)
lock (group.Children)
{
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
foreach (SceneObjectPart part in group.Children.Values)
{
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
}
else if (part.PhysActor != null)
{
PhysicsScene.RemovePrim(part.PhysActor);
part.PhysActor = null;
if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
{
PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
}
else if (part.PhysActor != null)
{
PhysicsScene.RemovePrim(part.PhysActor);
part.PhysActor = null;
}
}
}
// if (rootPart.PhysActor != null)
// {
// PhysicsScene.RemovePrim(rootPart.PhysActor);
@@ -2498,14 +2503,16 @@ namespace OpenSim.Region.Framework.Scenes
// Force allocation of new LocalId
//
foreach (SceneObjectPart p in sceneObject.Children.Values)
p.LocalId = 0;
lock (sceneObject.Children)
{
foreach (SceneObjectPart p in sceneObject.Children.Values)
p.LocalId = 0;
}
if (sceneObject.IsAttachmentCheckFull()) // Attachment
{
sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
// Don't sent a full update here because this will cause full updates to be sent twice for
// attachments on region crossings, resulting in viewer glitches.
@@ -2519,7 +2526,6 @@ namespace OpenSim.Region.Framework.Scenes
if (sp != null)
{
SceneObjectGroup grp = sceneObject;
m_log.DebugFormat(

View File

@@ -384,34 +384,35 @@ namespace OpenSim.Region.Framework.Scenes
// "[SCENE GRAPH]: Adding object {0} {1} to region {2}",
// sceneObject.Name, sceneObject.UUID, m_parentScene.RegionInfo.RegionName);
if (m_parentScene.m_clampPrimSize)
lock (sceneObject.Children)
{
foreach (SceneObjectPart part in sceneObject.Children.Values)
if (m_parentScene.m_clampPrimSize)
{
Vector3 scale = part.Shape.Scale;
if (scale.X > m_parentScene.m_maxNonphys)
scale.X = m_parentScene.m_maxNonphys;
if (scale.Y > m_parentScene.m_maxNonphys)
scale.Y = m_parentScene.m_maxNonphys;
if (scale.Z > m_parentScene.m_maxNonphys)
scale.Z = m_parentScene.m_maxNonphys;
part.Shape.Scale = scale;
foreach (SceneObjectPart part in sceneObject.Children.Values)
{
Vector3 scale = part.Shape.Scale;
if (scale.X > m_parentScene.m_maxNonphys)
scale.X = m_parentScene.m_maxNonphys;
if (scale.Y > m_parentScene.m_maxNonphys)
scale.Y = m_parentScene.m_maxNonphys;
if (scale.Z > m_parentScene.m_maxNonphys)
scale.Z = m_parentScene.m_maxNonphys;
part.Shape.Scale = scale;
}
}
}
sceneObject.AttachToScene(m_parentScene);
if (sendClientUpdates)
sceneObject.ScheduleGroupForFullUpdate();
Entities.Add(sceneObject);
m_numPrim += sceneObject.Children.Count;
sceneObject.AttachToScene(m_parentScene);
if (attachToBackup)
{
sceneObject.AttachToBackup();
if (sendClientUpdates)
sceneObject.ScheduleGroupForFullUpdate();
Entities.Add(sceneObject);
m_numPrim += sceneObject.Children.Count;
if (attachToBackup)
sceneObject.AttachToBackup();
}
if (OnObjectCreate != null)
@@ -448,10 +449,10 @@ namespace OpenSim.Region.Framework.Scenes
if (!resultOfObjectLinked)
{
m_numPrim -= ((SceneObjectGroup) Entities[uuid]).Children.Count;
m_numPrim -= grp.PrimCount;
if ((grp.RootPart.Flags & PrimFlags.Physics) == PrimFlags.Physics)
RemovePhysicalPrim(grp.Children.Count);
RemovePhysicalPrim(grp.PrimCount);
}
if (OnObjectRemove != null)
@@ -966,8 +967,12 @@ namespace OpenSim.Region.Framework.Scenes
{
if (SceneObjectGroupsByFullID.TryGetValue(fullID, out sog))
{
if (sog.Children.ContainsKey(fullID))
return sog;
lock (sog.Children)
{
if (sog.Children.ContainsKey(fullID))
return sog;
}
SceneObjectGroupsByFullID.Remove(fullID);
}
}
@@ -1678,7 +1683,7 @@ namespace OpenSim.Region.Framework.Scenes
{
if (part != null)
{
if (part.ParentGroup.Children.Count != 1) // Skip single
if (part.ParentGroup.PrimCount != 1) // Skip single
{
if (part.LinkNum < 2) // Root
rootParts.Add(part);
@@ -1717,8 +1722,15 @@ namespace OpenSim.Region.Framework.Scenes
// However, editing linked parts and unlinking may be different
//
SceneObjectGroup group = root.ParentGroup;
List<SceneObjectPart> newSet = new List<SceneObjectPart>(group.Children.Values);
int numChildren = group.Children.Count;
List<SceneObjectPart> newSet = null;
int numChildren = -1;
lock (group.Children)
{
newSet = new List<SceneObjectPart>(group.Children.Values);
numChildren = group.PrimCount;
}
// If there are prims left in a link set, but the root is
// slated for unlink, we need to do this
@@ -1808,12 +1820,17 @@ namespace OpenSim.Region.Framework.Scenes
{
if (ent is SceneObjectGroup)
{
foreach (KeyValuePair<UUID, SceneObjectPart> subent in ((SceneObjectGroup)ent).Children)
SceneObjectGroup sog = ent as SceneObjectGroup;
lock (sog.Children)
{
if (subent.Value.LocalId == localID)
foreach (KeyValuePair<UUID, SceneObjectPart> subent in sog.Children)
{
objid = subent.Key;
obj = subent.Value;
if (subent.Value.LocalId == localID)
{
objid = subent.Key;
obj = subent.Value;
}
}
}
}
@@ -1878,7 +1895,8 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectGroup original = GetGroupByPrim(originalPrimID);
if (original != null)
{
if (m_parentScene.Permissions.CanDuplicateObject(original.Children.Count, original.UUID, AgentID, original.AbsolutePosition))
if (m_parentScene.Permissions.CanDuplicateObject(
original.PrimCount, original.UUID, AgentID, original.AbsolutePosition))
{
SceneObjectGroup copy = original.Copy(true);
copy.AbsolutePosition = copy.AbsolutePosition + offset;

View File

@@ -360,7 +360,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public int PrimCount
{
get { return m_parts.Count; }
get { lock (m_parts) { return m_parts.Count; } }
}
protected Quaternion m_rotation = Quaternion.Identity;
@@ -398,6 +398,7 @@ namespace OpenSim.Region.Framework.Scenes
/// <value>
/// The parts of this scene object group. You must lock this property before using it.
/// If you want to know the number of children, consider using the PrimCount property instead
/// </value>
public Dictionary<UUID, SceneObjectPart> Children
{
@@ -521,7 +522,16 @@ namespace OpenSim.Region.Framework.Scenes
public override UUID UUID
{
get { return m_rootPart.UUID; }
set { m_rootPart.UUID = value; }
set
{
m_rootPart.UUID = value;
lock (m_parts)
{
m_parts.Remove(m_rootPart.UUID);
m_parts.Add(m_rootPart.UUID, m_rootPart);
}
}
}
public UUID OwnerID
@@ -742,21 +752,23 @@ namespace OpenSim.Region.Framework.Scenes
if (m_rootPart.LocalId == 0)
m_rootPart.LocalId = m_scene.AllocateLocalId();
// No need to lock here since the object isn't yet in a scene
foreach (SceneObjectPart part in m_parts.Values)
lock (m_parts)
{
if (Object.ReferenceEquals(part, m_rootPart))
foreach (SceneObjectPart part in m_parts.Values)
{
continue;
if (Object.ReferenceEquals(part, m_rootPart))
{
continue;
}
if (part.LocalId == 0)
{
part.LocalId = m_scene.AllocateLocalId();
}
part.ParentID = m_rootPart.LocalId;
//m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
}
if (part.LocalId == 0)
{
part.LocalId = m_scene.AllocateLocalId();
}
part.ParentID = m_rootPart.LocalId;
//m_log.DebugFormat("[SCENE]: Given local id {0} to part {1}, linknum {2}, parent {3} {4}", part.LocalId, part.UUID, part.LinkNum, part.ParentID, part.ParentUUID);
}
ApplyPhysics(m_scene.m_physicalPrim);
@@ -1238,9 +1250,12 @@ namespace OpenSim.Region.Framework.Scenes
m_rootPart.AttachedAvatar = agentID;
//Anakin Lohner bug #3839
foreach (SceneObjectPart p in m_parts.Values)
lock (m_parts)
{
p.AttachedAvatar = agentID;
foreach (SceneObjectPart p in m_parts.Values)
{
p.AttachedAvatar = agentID;
}
}
if (m_rootPart.PhysActor != null)
@@ -1308,10 +1323,14 @@ namespace OpenSim.Region.Framework.Scenes
AbsolutePosition = detachedpos;
m_rootPart.AttachedAvatar = UUID.Zero;
//Anakin Lohner bug #3839
foreach (SceneObjectPart p in m_parts.Values)
//Anakin Lohner bug #3839
lock (m_parts)
{
p.AttachedAvatar = UUID.Zero;
foreach (SceneObjectPart p in m_parts.Values)
{
p.AttachedAvatar = UUID.Zero;
}
}
m_rootPart.SetParentLocalId(0);
@@ -1337,10 +1356,14 @@ namespace OpenSim.Region.Framework.Scenes
}
m_rootPart.AttachedAvatar = UUID.Zero;
//Anakin Lohner bug #3839
foreach (SceneObjectPart p in m_parts.Values)
lock (m_parts)
{
p.AttachedAvatar = UUID.Zero;
foreach (SceneObjectPart p in m_parts.Values)
{
p.AttachedAvatar = UUID.Zero;
}
}
m_rootPart.SetParentLocalId(0);
@@ -1406,9 +1429,8 @@ namespace OpenSim.Region.Framework.Scenes
part.ParentID = 0;
part.LinkNum = 0;
// No locking required since the SOG should not be in the scene yet - one can't change root parts after
// the scene object has been attached to the scene
m_parts.Add(m_rootPart.UUID, m_rootPart);
lock (m_parts)
m_parts.Add(m_rootPart.UUID, m_rootPart);
}
/// <summary>
@@ -1928,14 +1950,14 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <summary>
///
/// Copy the given part as the root part of this scene object.
/// </summary>
/// <param name="part"></param>
/// <param name="cAgentID"></param>
/// <param name="cGroupID"></param>
public void CopyRootPart(SceneObjectPart part, UUID cAgentID, UUID cGroupID, bool userExposed)
{
SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, m_parts.Count, userExposed));
SetRootPart(part.Copy(m_scene.AllocateLocalId(), OwnerID, GroupID, 0, userExposed));
}
public void ScriptSetPhysicsStatus(bool UsePhysics)
@@ -2234,14 +2256,15 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void ResetIDs()
{
// As this is only ever called for prims which are not currently part of the scene (and hence
// not accessible by clients), there should be no need to lock
List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
m_parts.Clear();
foreach (SceneObjectPart part in partsList)
lock (m_parts)
{
part.ResetIDs(part.LinkNum); // Don't change link nums
m_parts.Add(part.UUID, part);
List<SceneObjectPart> partsList = new List<SceneObjectPart>(m_parts.Values);
m_parts.Clear();
foreach (SceneObjectPart part in partsList)
{
part.ResetIDs(part.LinkNum); // Don't change link nums
m_parts.Add(part.UUID, part);
}
}
}
@@ -2479,10 +2502,15 @@ namespace OpenSim.Region.Framework.Scenes
public SceneObjectPart GetChildPart(UUID primID)
{
SceneObjectPart childPart = null;
if (m_parts.ContainsKey(primID))
lock (m_parts)
{
childPart = m_parts[primID];
if (m_parts.ContainsKey(primID))
{
childPart = m_parts[primID];
}
}
return childPart;
}
@@ -2519,9 +2547,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns>
public bool HasChildPrim(UUID primID)
{
if (m_parts.ContainsKey(primID))
lock (m_parts)
{
return true;
if (m_parts.ContainsKey(primID))
return true;
}
return false;
@@ -3132,9 +3161,11 @@ namespace OpenSim.Region.Framework.Scenes
public void UpdatePermissions(UUID AgentID, byte field, uint localID,
uint mask, byte addRemTF)
{
foreach (SceneObjectPart part in m_parts.Values)
part.UpdatePermissions(AgentID, field, localID, mask,
addRemTF);
lock (m_parts)
{
foreach (SceneObjectPart part in m_parts.Values)
part.UpdatePermissions(AgentID, field, localID, mask, addRemTF);
}
HasGroupChanged = true;
}

View File

@@ -37,6 +37,7 @@ using log4net;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Scripting;
using OpenSim.Region.Framework.Scenes.Serialization;
namespace OpenSim.Region.Framework.Scenes
{
@@ -722,6 +723,71 @@ namespace OpenSim.Region.Framework.Scenes
return items;
}
public SceneObjectGroup GetRezReadySceneObject(TaskInventoryItem item)
{
UUID ownerID = item.OwnerID;
AssetBase rezAsset = m_part.ParentGroup.Scene.AssetService.Get(item.AssetID.ToString());
if (null == rezAsset)
{
m_log.WarnFormat(
"[PRIM INVENTORY]: Could not find asset {0} for inventory item {1} in {2}",
item.AssetID, item.Name, m_part.Name);
return null;
}
string xmlData = Utils.BytesToString(rezAsset.Data);
SceneObjectGroup group = SceneObjectSerializer.FromOriginalXmlFormat(xmlData);
group.ResetIDs();
SceneObjectPart rootPart = group.GetChildPart(group.UUID);
// 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;
List<SceneObjectPart> partList = null;
lock (group.Children)
partList = new List<SceneObjectPart>(group.Children.Values);
group.SetGroup(m_part.GroupID, null);
if ((rootPart.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
{
if (m_part.ParentGroup.Scene.Permissions.PropagatePermissions())
{
foreach (SceneObjectPart part in partList)
{
part.EveryoneMask = item.EveryonePermissions;
part.NextOwnerMask = item.NextPermissions;
}
group.ApplyNextOwnerPermissions();
}
}
foreach (SceneObjectPart part in partList)
{
if ((part.OwnerID != item.OwnerID) || (item.CurrentPermissions & 16) != 0)
{
part.LastOwnerID = part.OwnerID;
part.OwnerID = item.OwnerID;
part.Inventory.ChangeInventoryOwner(item.OwnerID);
}
part.EveryoneMask = item.EveryonePermissions;
part.NextOwnerMask = item.NextPermissions;
}
rootPart.TrimPermissions();
return group;
}
/// <summary>
/// Update an existing inventory item.
/// </summary>
@@ -1197,6 +1263,5 @@ namespace OpenSim.Region.Framework.Scenes
Items.LockItemsForRead(false);
}
}
}
}