private double GetPriorityByDistance(IClientAPI client, ISceneEntity entity)
{
ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
if (presence != null)
{
// If this is an update for our own avatar give it the highest priority
if (presence == entity)
{
return(0.0);
}
// Use the camera position for local agents and avatar position for remote agents
Vector3 presencePos = (presence.IsChildAgent) ?
presence.AbsolutePosition :
presence.CameraPosition;
// Use group position for child prims
Vector3 entityPos;
if (entity is SceneObjectPart)
{
entityPos = m_scene.GetGroupByPrim(entity.LocalId).AbsolutePosition;
}
else
{
entityPos = entity.AbsolutePosition;
}
return(Vector3.DistanceSquared(presencePos, entityPos));
}
return(double.NaN);
}