29 using System.Collections.Generic;
32 using OpenSim.Framework;
34 using OpenSim.Region.PhysicsModules.SharedBase;
48 namespace OpenSim.
Region.Framework.Scenes
61 private static readonly ILog m_log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
63 private Scene m_scene;
85 m_log.WarnFormat(
"[PRIORITIZER] attempt to prioritize null entity");
86 throw new InvalidOperationException(
"Prioritization entity not defined");
95 switch (m_scene.UpdatePrioritizationScheme)
111 case UpdatePrioritizationSchemes.BestAvatarResponsiveness:
113 priority = GetPriorityByBestAvatarResponsiveness(client, entity);
125 SceneObjectPart sop = (SceneObjectPart)entity;
130 return PriorityQueue.NumberOfImmediateQueues;
136 if (entity is SceneObjectPart)
138 SceneObjectPart sop = (SceneObjectPart)entity;
139 if (sop.ParentGroup.IsAttachment && client.
AgentId == sop.ParentGroup.AttachedAvatar)
143 return ComputeDistancePriority(client,entity,
false);
149 if (entity is SceneObjectPart)
151 SceneObjectPart sop = (SceneObjectPart)entity;
152 if (sop.ParentGroup.IsAttachment && client.
AgentId == sop.ParentGroup.AttachedAvatar)
156 return ComputeDistancePriority(client,entity,
true);
163 ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
164 if (presence != null)
167 if (entity is ScenePresence)
170 if (entity is SceneObjectPart)
173 if (((SceneObjectPart)entity).ParentGroup.IsAttachment)
176 pqueue = ComputeDistancePriority(client, entity,
false);
179 PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor;
180 if (physActor == null || !physActor.
IsPhysical)
185 pqueue = ComputeDistancePriority(client, entity,
false);
193 ScenePresence presence = m_scene.GetScenePresence(client.AgentId);
194 if (presence == null)
202 return PriorityQueue.NumberOfQueues - 1;
209 Vector3 entityPos = entity.AbsolutePosition;
210 if (entity is SceneObjectPart)
212 SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup;
213 entityPos = group.AbsolutePosition;
225 Vector3 presencePos = presence.AbsolutePosition;
228 double distance = Vector3.Distance(presencePos, entityPos);
232 uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1;
233 uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues;
244 float tmp = (float)Math.Log((
double)distance) * 1.4426950408889634073599246810019f - 3.3219280948873623478703194294894f;
250 if (pqueue > queues - 1)
256 if (useFrontBack && ! presence.IsChildAgent)
259 Vector3 camPosition = presence.CameraPosition;
260 Vector3 camAtAxis = presence.CameraAtAxis;
263 float d = -Vector3.Dot(camPosition, camAtAxis);
264 float p = Vector3.Dot(camAtAxis, entityPos) + d;
uint GetUpdatePriority(IClientAPI client, ISceneEntity entity)
Returns the priority queue into which the update should be placed. Updates within a queue will be pro...
SceneObjectGroup ParentGroup
UUID AttachedAvatar
The avatar to which this scene object is attached.
UpdatePrioritizationSchemes
bool IsAttachment
Is this scene object acting as an attachment?