Use SP.ParentPart instead of ParentID in places where it's more efficient (saving extra null checks, etc.)
However, it looks like we should retain SP.ParentID since it's much easier to use that in places where another thread could change ParentPart to null. Otherwise one has to clumsily put ParentPart in a reference, etc. to avoid a race.0.7.4.1
parent
b454326273
commit
94e58ff6b9
|
@ -215,27 +215,13 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (sp.IsChildAgent)
|
||||
continue;
|
||||
|
||||
if (sp.ParentID != 0)
|
||||
{
|
||||
// sitting avatar
|
||||
SceneObjectPart sop = m_parentScene.GetSceneObjectPart(sp.ParentID);
|
||||
if (sop != null)
|
||||
{
|
||||
coarseLocations.Add(sop.AbsolutePosition + sp.OffsetPosition);
|
||||
avatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we can't find the parent.. ! arg!
|
||||
coarseLocations.Add(sp.AbsolutePosition);
|
||||
avatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
}
|
||||
SceneObjectPart sitPart = sp.ParentPart;
|
||||
if (sitPart != null)
|
||||
coarseLocations.Add(sitPart.AbsolutePosition + sp.OffsetPosition);
|
||||
else
|
||||
{
|
||||
coarseLocations.Add(sp.AbsolutePosition);
|
||||
avatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
|
||||
avatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -432,7 +432,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
get
|
||||
{
|
||||
if (PhysicsActor != null && m_parentID == 0)
|
||||
if (PhysicsActor != null && ParentID == 0)
|
||||
{
|
||||
m_pos = PhysicsActor.Position;
|
||||
|
||||
|
@ -504,6 +504,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// There is no offset position when not seated
|
||||
if (ParentID == 0)
|
||||
return;
|
||||
|
||||
m_pos = value;
|
||||
}
|
||||
}
|
||||
|
@ -562,19 +563,18 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public bool IsChildAgent { get; set; }
|
||||
|
||||
public uint ParentID
|
||||
{
|
||||
get { return m_parentID; }
|
||||
set { m_parentID = value; }
|
||||
}
|
||||
private uint m_parentID;
|
||||
/// <summary>
|
||||
/// If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero.
|
||||
/// </summary>
|
||||
public uint ParentID { get; set; }
|
||||
|
||||
public SceneObjectPart ParentPart
|
||||
{
|
||||
get { return m_parentPart; }
|
||||
set { m_parentPart = value; }
|
||||
}
|
||||
private SceneObjectPart m_parentPart = null;
|
||||
/// <summary>
|
||||
/// If the avatar is sitting, the prim that it's sitting on. If not sitting then null.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// If you use this property then you must take a reference since another thread could set it to null.
|
||||
/// </remarks>
|
||||
public SceneObjectPart ParentPart { get; set; }
|
||||
|
||||
public float Health
|
||||
{
|
||||
|
|
|
@ -716,29 +716,17 @@ namespace OpenSim.Region.RegionCombinerModule
|
|||
{
|
||||
if (sp.UUID != presence.UUID)
|
||||
{
|
||||
if (sp.ParentID != 0)
|
||||
{
|
||||
// sitting avatar
|
||||
SceneObjectPart sop = connectiondata.RegionScene.GetSceneObjectPart(sp.ParentID);
|
||||
if (sop != null)
|
||||
{
|
||||
CoarseLocations.Add(sop.AbsolutePosition + sp.AbsolutePosition);
|
||||
AvatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
else
|
||||
{
|
||||
// we can't find the parent.. ! arg!
|
||||
CoarseLocations.Add(sp.AbsolutePosition);
|
||||
AvatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
}
|
||||
SceneObjectPart sitPart = sp.ParentPart;
|
||||
|
||||
if (sitPart != null)
|
||||
CoarseLocations.Add(sitPart.AbsolutePosition + sp.AbsolutePosition);
|
||||
else
|
||||
{
|
||||
CoarseLocations.Add(sp.AbsolutePosition);
|
||||
AvatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
|
||||
AvatarUUIDs.Add(sp.UUID);
|
||||
}
|
||||
});
|
||||
|
||||
DistributeCourseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
|
||||
}
|
||||
|
||||
|
|
|
@ -3825,7 +3825,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
List<String> nametable = new List<String>();
|
||||
World.ForEachRootScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
|
||||
SceneObjectPart sitPart = presence.ParentPart;
|
||||
if (sitPart != null && m_host.ParentGroup.HasChildPrim(sitPart.LocalId))
|
||||
nametable.Add(presence.ControllingClient.Name);
|
||||
});
|
||||
|
||||
|
@ -4393,22 +4394,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
// Find pushee position
|
||||
// Pushee Linked?
|
||||
if (pusheeav.ParentID != 0)
|
||||
{
|
||||
SceneObjectPart parentobj = World.GetSceneObjectPart(pusheeav.ParentID);
|
||||
if (parentobj != null)
|
||||
{
|
||||
PusheePos = parentobj.AbsolutePosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
PusheePos = pusheeav.AbsolutePosition;
|
||||
}
|
||||
}
|
||||
SceneObjectPart sitPart = pusheeav.ParentPart;
|
||||
if (sitPart != null)
|
||||
PusheePos = sitPart.AbsolutePosition;
|
||||
else
|
||||
{
|
||||
PusheePos = pusheeav.AbsolutePosition;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pusheeIsAvatar)
|
||||
|
@ -5603,7 +5593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
flags |= ScriptBaseClass.AGENT_IN_AIR;
|
||||
}
|
||||
|
||||
if (agent.ParentID != 0)
|
||||
if (agent.ParentPart != null)
|
||||
{
|
||||
flags |= ScriptBaseClass.AGENT_ON_OBJECT;
|
||||
flags |= ScriptBaseClass.AGENT_SITTING;
|
||||
|
@ -7692,7 +7682,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
World.ForEachRootScenePresence(delegate(ScenePresence presence)
|
||||
{
|
||||
if (presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
|
||||
avatarCount++;
|
||||
avatarCount++;
|
||||
});
|
||||
|
||||
return m_host.ParentGroup.PrimCount + avatarCount;
|
||||
|
|
Loading…
Reference in New Issue