public GetUpdatePriority ( IClientAPI client, ISceneEntity entity ) : double | ||
client | IClientAPI | |
entity | ISceneEntity | |
return | double |
private int sortPriority(ISceneEntity a, ISceneEntity b) { int prioA = (int)m_prioritizer.GetUpdatePriority(m_presence, a); int prioB = (int)m_prioritizer.GetUpdatePriority(m_presence, b); return(prioB.CompareTo(prioA)); }
private void DoSignificantClientMovement(object o) { ISceneEntity[] entities = m_presence.Scene.Entities.GetEntities(m_presence.AbsolutePosition, m_presence.DrawDistance); PriorityQueue <EntityUpdate, double> m_entsqueue = new PriorityQueue <EntityUpdate, double> (entities.Length); // build a prioritized list of things we need to send HashSet <ISceneEntity> NewGrpsInView = new HashSet <ISceneEntity> (); foreach (ISceneEntity e in entities) { if (e != null) { if (e.IsDeleted) { continue; } //Check for culling here! if (!Culler.ShowEntityToClient(m_presence, e)) { continue; // if 2 far ignore } double priority = m_prioritizer.GetUpdatePriority(m_presence, e); NewGrpsInView.Add(e); if (lastGrpsInView.Contains(e)) { continue; } //Send the root object first! EntityUpdate rootupdate = new EntityUpdate(e.RootChild, PrimUpdateFlags.FullUpdate); PriorityQueueItem <EntityUpdate, double> rootitem = new PriorityQueueItem <EntityUpdate, double> (); rootitem.Value = rootupdate; rootitem.Priority = priority; m_entsqueue.Enqueue(rootitem); foreach (ISceneChildEntity child in e.ChildrenEntities()) { if (child == e.RootChild) { continue; //Already sent } EntityUpdate update = new EntityUpdate(child, PrimUpdateFlags.FullUpdate); PriorityQueueItem <EntityUpdate, double> item = new PriorityQueueItem <EntityUpdate, double> (); item.Value = update; item.Priority = priority; m_entsqueue.Enqueue(item); } } } entities = null; lastGrpsInView.Clear(); lastGrpsInView.UnionWith(NewGrpsInView); NewGrpsInView.Clear(); // send them SendQueued(m_entsqueue); }