Example #1
0
        private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity)
        {
            // And convert the distance to a priority queue, this computation gives queues
            // at 10, 20, 40, 80, 160, 320, 640, and 1280m
//            uint minpqueue = PriorityQueue.NumberOfImmediateQueues;
            uint maxqueue = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues - 1;
//            uint pqueue = minpqueue;
            uint  pqueue = PriorityQueue.NumberOfImmediateQueues;
            float distance;

            Vector3 presencePos = presence.AbsolutePosition;

            if (entity is ScenePresence)
            {
                ScenePresence sp = entity as ScenePresence;
                distance  = Vector3.Distance(presencePos, sp.AbsolutePosition);
                distance *= 0.5f;
            }
            else
            {
                SceneObjectGroup group   = (entity as SceneObjectPart).ParentGroup;
                float            bradius = group.GetBoundsRadius();
                Vector3          grppos  = group.AbsolutePosition + group.getBoundsCenter();
                distance  = Vector3.Distance(presencePos, grppos);
                distance -= bradius;
                distance *= group.getAreaFactor();
                if (group.IsAttachment)
                {
                    distance *= 0.5f;
                }
                else if (group.UsesPhysics)
                {
                    distance *= 0.6f;
                }
                else if (group.GetSittingAvatarsCount() > 0)
                {
                    distance *= 0.5f;
                }
            }

            if (distance > 10f)
            {
                float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f;
                // for a map identical to original:
                // now
                // 1st constant is 1/(log(2)) (natural log) so we get log2(distance)
                // 2st constant makes it be log2(distance/10)

                pqueue += (uint)tmp;
                if (pqueue > maxqueue)
                {
                    pqueue = maxqueue;
                }
            }

            return(pqueue);
        }
Example #2
0
        private int ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity)
        {
            int   pqueue = PriorityQueue.NumberOfImmediateQueues;
            float distance;

            Vector3 presencePos = presence.AbsolutePosition;

            if (entity is ScenePresence)
            {
                ScenePresence sp = entity as ScenePresence;
                distance = Vector3.DistanceSquared(presencePos, sp.AbsolutePosition);
                if (distance > 400f)
                {
                    float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f;
                    pqueue += (int)tmp;
                }
                return(pqueue);
            }

            SceneObjectPart  sop   = entity as SceneObjectPart;
            SceneObjectGroup group = sop.ParentGroup;

            if (presence.ParentPart != null)
            {
                if (presence.ParentPart.ParentGroup == group)
                {
                    return(pqueue);
                }
            }

            if (group.IsAttachment)
            {
                if (group.RootPart.LocalId == presence.LocalId)
                {
                    return(pqueue);
                }

                distance = Vector3.DistanceSquared(presencePos, group.AbsolutePosition);
                if (distance > 400f)
                {
                    float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f;
                    pqueue += (int)tmp;
                }
                return(pqueue);
            }

            float   bradius = group.GetBoundsRadius();
            Vector3 grppos  = group.getCenterOffset();

            distance  = Vector3.Distance(presencePos, grppos);
            distance -= bradius;
            if (distance < 0)
            {
                return(pqueue);
            }

            distance *= group.getAreaFactor();
            if (group.IsAttachment)
            {
                distance *= 0.5f;
            }
            else if (group.UsesPhysics)
            {
                distance *= 0.6f;
            }
            else if (group.GetSittingAvatarsCount() > 0)
            {
                distance *= 0.5f;
            }

            if (distance > 10f)
            {
                float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f;
                // for a map identical to original:
                // now
                // 1st constant is 1/(log(2)) (natural log) so we get log2(distance)
                // 2st constant makes it be log2(distance/10)
                pqueue += (int)tmp;
            }

            return(pqueue);
        }