예제 #1
0
 private void SendInitialObjects()
 {
     //If they are not in this region, we check to make sure that we allow seeing into neighbors
     if (!m_presence.IsChildAgent ||
         (m_presence.Scene.RegionInfo.SeeIntoThisSimFromNeighbor) && m_prioritizer != null)
     {
         try
         {
             m_SentInitialObjects = true;
             ISceneEntity[]         allEntities   = m_presence.Scene.Entities.GetEntities();
             LPriorityQueue         entsqueue     = new LPriorityQueue(new DoubleComparer());
             HashSet <ISceneEntity> NewGrpsInView = new HashSet <ISceneEntity>();
             // build a prioritized list of things we need to send
             int time = Util.EnvironmentTickCount();
             foreach (ISceneEntity e in from e in allEntities where e != null && e is SceneObjectGroup where !e.IsDeleted where !lastGrpsInView.Contains(e) where m_culler != null where m_culler.ShowEntityToClient(m_presence, e, m_scene, time) select e)
             {
                 NewGrpsInView.Add(e);
             }
             //Merge the last seen lists
             lastGrpsInView.UnionWith(NewGrpsInView);
             allEntities = null;
             // send them
             if (NewGrpsInView.Count != 0)
             {
                 SendQueued(NewGrpsInView);
             }
             NewGrpsInView.Clear();
         }
         catch (Exception ex)
         {
             MainConsole.Instance.Warn("[SceneViewer]: Exception occured in sending initial prims, " + ex);
             //An exception occured, don't fail to send all the prims to the client
             m_SentInitialObjects = false;
         }
     }
 }
예제 #2
0
        private void DoSignificantClientMovement(object o)
        {
            //Just return all the entities, its quicker to do the culling check rather than the position check
            ISceneEntity[] entities  = m_presence.Scene.Entities.GetEntities();
            LPriorityQueue entsqueue = new LPriorityQueue(new DoubleComparer());

            // build a prioritized list of things we need to send

            HashSet <ISceneEntity> NewGrpsInView = new HashSet <ISceneEntity>();

            int time = Util.EnvironmentTickCount();

            foreach (ISceneEntity e in from e in entities where e != null where !e.IsDeleted where !lastGrpsInView.Contains(e) where m_culler != null where m_culler.ShowEntityToClient(m_presence, e, m_scene, time) select e)
            {
                NewGrpsInView.Add(e);
            }
            entities = null;
            lastGrpsInView.UnionWith(NewGrpsInView);
            // send them
            if (NewGrpsInView.Count != 0)
            {
                SendQueued(NewGrpsInView);
            }
            NewGrpsInView.Clear();


            //Check for scenepresences as well
            List <IScenePresence> presences = new List <IScenePresence>(m_presence.Scene.Entities.GetPresences());

#if (!ISWIN)
            foreach (IScenePresence presence in presences)
            {
                if (presence != null && presence.UUID != m_presence.UUID)
                {
                    lock (m_lastPresencesInViewLock)
                        if (lastPresencesDInView.ContainsKey(presence.UUID))
                        {
                            continue;
                        }             //Don't resend the update

                    //Check for culling here!
                    if (!m_culler.ShowEntityToClient(m_presence, presence, m_scene, time))
                    {
                        continue; // if 2 far ignore
                    }
                    lock (m_lastPresencesInViewLock)
                        lastPresencesDInView.Add(presence.UUID, presence);

                    SendFullUpdateForPresence(presence);
                }
            }
#else
            foreach (IScenePresence presence in presences.Where(presence => presence != null && presence.UUID != m_presence.UUID))
            {
                lock (m_lastPresencesInViewLock)
                    if (lastPresencesDInView.ContainsKey(presence.UUID))
                    {
                        continue;
                    }             //Don't resend the update

                //Check for culling here!
                if (!m_culler.ShowEntityToClient(m_presence, presence, m_scene, time))
                {
                    continue; // if 2 far ignore
                }
                lock (m_lastPresencesInViewLock)
                    lastPresencesDInView.Add(presence.UUID, presence);

                SendFullUpdateForPresence(presence);
            }
#endif
            presences = null;
        }