diff options
author | UbitUmarov | 2016-08-09 21:46:19 +0100 |
---|---|---|
committer | UbitUmarov | 2016-08-09 21:46:19 +0100 |
commit | 6f5f6431a45cad8e23c2251d661691d905fc08f7 (patch) | |
tree | 8d47a09e2fd5bbe0e3a05d286bbef29bda2b628b /OpenSim/Region/Framework/Scenes/Prioritizer.cs | |
parent | add a simple prim area estimator (diff) | |
download | opensim-SC_OLD-6f5f6431a45cad8e23c2251d661691d905fc08f7.zip opensim-SC_OLD-6f5f6431a45cad8e23c2251d661691d905fc08f7.tar.gz opensim-SC_OLD-6f5f6431a45cad8e23c2251d661691d905fc08f7.tar.bz2 opensim-SC_OLD-6f5f6431a45cad8e23c2251d661691d905fc08f7.tar.xz |
add a SimpleAngularDistance Updates prioritazition scheme. Results don't look that great so don't use it still.
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Prioritizer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Prioritizer.cs | 67 |
1 files changed, 66 insertions, 1 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index c913ec2..5669c43 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -108,6 +108,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
108 | priority = GetPriorityByFrontBack(client, entity); | 108 | priority = GetPriorityByFrontBack(client, entity); |
109 | break; | 109 | break; |
110 | */ | 110 | */ |
111 | case UpdatePrioritizationSchemes.SimpleAngularDistance: | ||
112 | priority = GetPriorityByAngularDistance(client, entity); // TODO: Reimplement SimpleAngularDistance | ||
113 | break; | ||
111 | case UpdatePrioritizationSchemes.BestAvatarResponsiveness: | 114 | case UpdatePrioritizationSchemes.BestAvatarResponsiveness: |
112 | default: | 115 | default: |
113 | priority = GetPriorityByBestAvatarResponsiveness(client, entity); | 116 | priority = GetPriorityByBestAvatarResponsiveness(client, entity); |
@@ -241,7 +244,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
241 | */ | 244 | */ |
242 | if (distance > 10f) | 245 | if (distance > 10f) |
243 | { | 246 | { |
244 | float tmp = (float)Math.Log((double)distance) * 1.4426950408889634073599246810019f - 3.3219280948873623478703194294894f; | 247 | float tmp = (float)Math.Log((double)distance) * 1.442695f - 3.321928f; |
245 | // for a map identical to original: | 248 | // for a map identical to original: |
246 | // now | 249 | // now |
247 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) | 250 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) |
@@ -269,5 +272,67 @@ namespace OpenSim.Region.Framework.Scenes | |||
269 | return pqueue; | 272 | return pqueue; |
270 | } | 273 | } |
271 | 274 | ||
275 | private uint GetPriorityByAngularDistance(IClientAPI client, ISceneEntity entity) | ||
276 | { | ||
277 | uint pqueue = 2; // keep compiler happy | ||
278 | |||
279 | ScenePresence presence = m_scene.GetScenePresence(client.AgentId); | ||
280 | if (presence == null) | ||
281 | return PriorityQueue.NumberOfQueues - 1; | ||
282 | |||
283 | // All avatars other than our own go into pqueue 1 | ||
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; | ||
302 | } | ||
303 | |||
304 | private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity) | ||
305 | { | ||
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 | ||
318 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | ||
319 | uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue | ||
320 | uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; | ||
321 | |||
322 | if (distance > 10f) | ||
323 | { | ||
324 | float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f; | ||
325 | // for a map identical to original: | ||
326 | // now | ||
327 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) | ||
328 | // 2st constant makes it be log2(distance/10) | ||
329 | |||
330 | pqueue += (uint)tmp; | ||
331 | if (pqueue > queues - 1) | ||
332 | pqueue = queues - 1; | ||
333 | } | ||
334 | |||
335 | return pqueue; | ||
336 | } | ||
272 | } | 337 | } |
273 | } | 338 | } |