mirror of
https://github.com/opensim/opensim.git
synced 2026-08-05 00:46:02 +08:00
Merge branch 'master' into careminster
Conflicts: OpenSim/Framework/Watchdog.cs OpenSim/Region/CoreModules/Avatar/Attachments/AttachmentsModule.cs OpenSim/Region/Framework/Scenes/Scene.cs OpenSim/Region/Framework/Scenes/SceneObjectPart.cs OpenSim/Region/Framework/Scenes/ScenePresence.cs
This commit is contained in:
@@ -147,6 +147,21 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
get { return ParentGroup.RootPart == this; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Is an explicit sit target set for this part?
|
||||
/// </summary>
|
||||
public bool IsSitTargetSet
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
!(SitTargetPosition == Vector3.Zero
|
||||
&& (SitTargetOrientation == Quaternion.Identity // Valid Zero Rotation quaternion
|
||||
|| SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 1f && SitTargetOrientation.W == 0f // W-Z Mapping was invalid at one point
|
||||
|| SitTargetOrientation.X == 0f && SitTargetOrientation.Y == 0f && SitTargetOrientation.Z == 0f && SitTargetOrientation.W == 0f)); // Invalid Quaternion
|
||||
}
|
||||
}
|
||||
|
||||
#region Fields
|
||||
|
||||
public bool AllowedDrop;
|
||||
@@ -426,7 +441,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
private uint _category;
|
||||
private Int32 _creationDate;
|
||||
private uint _parentID = 0;
|
||||
private UUID m_sitTargetAvatar = UUID.Zero;
|
||||
private uint _baseMask = (uint)PermissionMask.All;
|
||||
private uint _ownerMask = (uint)PermissionMask.All;
|
||||
private uint _groupMask = (uint)PermissionMask.None;
|
||||
@@ -1312,13 +1326,20 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ID of the avatar that is sat on us. If there is no such avatar then is UUID.Zero
|
||||
/// ID of the avatar that is sat on us if we have a sit target. If there is no such avatar then is UUID.Zero
|
||||
/// </summary>
|
||||
public UUID SitTargetAvatar
|
||||
{
|
||||
get { return m_sitTargetAvatar; }
|
||||
set { m_sitTargetAvatar = value; }
|
||||
}
|
||||
public UUID SitTargetAvatar { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// IDs of all avatars start on this object part.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// We need to track this so that we can stop sat upon prims from being attached.
|
||||
/// </remarks>
|
||||
/// <value>
|
||||
/// null if there are no sitting avatars. This is to save us create a hashset for every prim in a scene.
|
||||
/// </value>
|
||||
private HashSet<UUID> m_sittingAvatars;
|
||||
|
||||
public virtual UUID RegionID
|
||||
{
|
||||
@@ -5128,5 +5149,99 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
Inventory.UpdateInventoryItem(item, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record an avatar sitting on this part.
|
||||
/// </summary>
|
||||
/// <remarks>This is called for all the sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>
|
||||
/// true if the avatar was not already recorded, false otherwise.
|
||||
/// </returns>
|
||||
/// <param name='avatarId'></param>
|
||||
protected internal bool AddSittingAvatar(UUID avatarId)
|
||||
{
|
||||
if (IsSitTargetSet && SitTargetAvatar == UUID.Zero)
|
||||
SitTargetAvatar = avatarId;
|
||||
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
sittingAvatars = new HashSet<UUID>();
|
||||
|
||||
lock (sittingAvatars)
|
||||
{
|
||||
m_sittingAvatars = sittingAvatars;
|
||||
return m_sittingAvatars.Add(avatarId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Remove an avatar recorded as sitting on this part.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>
|
||||
/// true if the avatar was present and removed, false if it was not present.
|
||||
/// </returns>
|
||||
/// <param name='avatarId'></param>
|
||||
protected internal bool RemoveSittingAvatar(UUID avatarId)
|
||||
{
|
||||
if (SitTargetAvatar == avatarId)
|
||||
SitTargetAvatar = UUID.Zero;
|
||||
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
// This can occur under a race condition where another thread
|
||||
if (sittingAvatars == null)
|
||||
return false;
|
||||
|
||||
lock (sittingAvatars)
|
||||
{
|
||||
if (sittingAvatars.Remove(avatarId))
|
||||
{
|
||||
if (sittingAvatars.Count == 0)
|
||||
m_sittingAvatars = null;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a copy of the list of sitting avatars.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns>A hashset of the sitting avatars. Returns null if there are no sitting avatars.</returns>
|
||||
public HashSet<UUID> GetSittingAvatars()
|
||||
{
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
else
|
||||
{
|
||||
lock (sittingAvatars)
|
||||
return new HashSet<UUID>(sittingAvatars);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the number of sitting avatars.
|
||||
/// </summary>
|
||||
/// <remarks>This applies to all sitting avatars whether there is a sit target set or not.</remarks>
|
||||
/// <returns></returns>
|
||||
public int GetSittingAvatarsCount()
|
||||
{
|
||||
HashSet<UUID> sittingAvatars = m_sittingAvatars;
|
||||
|
||||
if (sittingAvatars == null)
|
||||
return 0;
|
||||
|
||||
lock (sittingAvatars)
|
||||
return sittingAvatars.Count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user