diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Prioritizer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Prioritizer.cs | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index 5669c43..97009a0 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -274,50 +274,46 @@ namespace OpenSim.Region.Framework.Scenes | |||
274 | 274 | ||
275 | private uint GetPriorityByAngularDistance(IClientAPI client, ISceneEntity entity) | 275 | private uint GetPriorityByAngularDistance(IClientAPI client, ISceneEntity entity) |
276 | { | 276 | { |
277 | uint pqueue = 2; // keep compiler happy | ||
278 | |||
279 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | 277 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); |
280 | if (presence == null) | 278 | if (presence == null) |
281 | return PriorityQueue.NumberOfQueues - 1; | 279 | return PriorityQueue.NumberOfQueues - 1; |
282 | 280 | ||
283 | // All avatars other than our own go into pqueue 1 | 281 | uint pqueue = ComputeAngleDistancePriority(presence, entity); |
284 | if (entity is ScenePresence) | ||
285 | return 1; | ||
286 | |||
287 | if (entity is SceneObjectPart) | ||
288 | { | ||
289 | // Attachments are high priority, | ||
290 | if (((SceneObjectPart)entity).ParentGroup.IsAttachment) | ||
291 | return 2; | ||
292 | |||
293 | pqueue = ComputeAngleDistancePriority(presence, entity); | ||
294 | |||
295 | // Non physical prims are lower priority than physical prims | ||
296 | PhysicsActor physActor = ((SceneObjectPart)entity).ParentGroup.RootPart.PhysActor; | ||
297 | if (physActor == null || !physActor.IsPhysical) | ||
298 | pqueue++; | ||
299 | } | ||
300 | |||
301 | return pqueue; | 282 | return pqueue; |
302 | } | 283 | } |
303 | 284 | ||
304 | private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity) | 285 | private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity) |
305 | { | 286 | { |
306 | double distance; | ||
307 | |||
308 | Vector3 presencePos = presence.AbsolutePosition; | ||
309 | |||
310 | SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; | ||
311 | float bradius = group.GetBoundsRadius(); | ||
312 | Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter(); | ||
313 | distance = Vector3.Distance(presencePos, grppos); | ||
314 | distance -= bradius; | ||
315 | distance *= group.getAreaFactor(); | ||
316 | |||
317 | // And convert the distance to a priority queue, this computation gives queues | 287 | // And convert the distance to a priority queue, this computation gives queues |
318 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | 288 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m |
319 | uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue | 289 | // uint minpqueue = PriorityQueue.NumberOfImmediateQueues; |
320 | uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; | 290 | uint maxqueue = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues -1; |
291 | // uint pqueue = minpqueue; | ||
292 | uint pqueue = PriorityQueue.NumberOfImmediateQueues; | ||
293 | float distance; | ||
294 | |||
295 | Vector3 presencePos = presence.AbsolutePosition; | ||
296 | if(entity is ScenePresence) | ||
297 | { | ||
298 | ScenePresence sp = entity as ScenePresence; | ||
299 | distance = Vector3.Distance(presencePos, sp.AbsolutePosition); | ||
300 | distance *= 0.5f; | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; | ||
305 | float bradius = group.GetBoundsRadius(); | ||
306 | Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter(); | ||
307 | distance = Vector3.Distance(presencePos, grppos); | ||
308 | distance -= bradius; | ||
309 | distance *= group.getAreaFactor(); | ||
310 | if(group.IsAttachment) | ||
311 | distance *= 0.5f; | ||
312 | else if(group.UsesPhysics) | ||
313 | distance *= 0.6f; | ||
314 | else if(group.GetSittingAvatarsCount() > 0) | ||
315 | distance *= 0.5f; | ||
316 | } | ||
321 | 317 | ||
322 | if (distance > 10f) | 318 | if (distance > 10f) |
323 | { | 319 | { |
@@ -328,8 +324,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
328 | // 2st constant makes it be log2(distance/10) | 324 | // 2st constant makes it be log2(distance/10) |
329 | 325 | ||
330 | pqueue += (uint)tmp; | 326 | pqueue += (uint)tmp; |
331 | if (pqueue > queues - 1) | 327 | if (pqueue > maxqueue) |
332 | pqueue = queues - 1; | 328 | pqueue = maxqueue; |
333 | } | 329 | } |
334 | 330 | ||
335 | return pqueue; | 331 | return pqueue; |