aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--OpenSim/Region/Framework/Scenes/Prioritizer.cs67
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs17
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs24
3 files changed, 97 insertions, 11 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}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index efc1413..e17ef2b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -1586,12 +1586,22 @@ namespace OpenSim.Region.Framework.Scenes
1586 return m_boundsCenter; 1586 return m_boundsCenter;
1587 } 1587 }
1588 1588
1589 private float m_areaFactor;
1590 public float getAreaFactor()
1591 {
1592 // math is done in GetBoundsRadius();
1593 if(m_boundsRadius == null)
1594 GetBoundsRadius();
1595 return m_areaFactor;
1596 }
1597
1589 public float GetBoundsRadius() 1598 public float GetBoundsRadius()
1590 { 1599 {
1591 // this may need more threading work 1600 // this may need more threading work
1592 if(m_boundsRadius == null) 1601 if(m_boundsRadius == null)
1593 { 1602 {
1594 float res = 0; 1603 float res = 0;
1604 float areaF = 0;
1595 SceneObjectPart p; 1605 SceneObjectPart p;
1596 SceneObjectPart[] parts; 1606 SceneObjectPart[] parts;
1597 float partR; 1607 float partR;
@@ -1613,12 +1623,19 @@ namespace OpenSim.Region.Framework.Scenes
1613 } 1623 }
1614 if(partR > res) 1624 if(partR > res)
1615 res = partR; 1625 res = partR;
1626 if(p.maxSimpleArea() > areaF)
1627 areaF = p.maxSimpleArea();
1616 } 1628 }
1617 if(parts.Length > 1) 1629 if(parts.Length > 1)
1618 { 1630 {
1619 offset /= parts.Length; // basicly geometric center 1631 offset /= parts.Length; // basicly geometric center
1620 offset = offset * RootPart.RotationOffset; 1632 offset = offset * RootPart.RotationOffset;
1621 } 1633 }
1634
1635 areaF = 10.0f / areaF; // scale it
1636 areaF = Util.Clamp(areaF, 0.001f, 1000f); // clamp it
1637
1638 m_areaFactor = (float)Math.Sqrt(areaF);
1622 m_boundsCenter = offset; 1639 m_boundsCenter = offset;
1623 m_boundsRadius = res; 1640 m_boundsRadius = res;
1624 return res; 1641 return res;
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 90be18f..bc603ae 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -1191,24 +1191,28 @@ namespace OpenSim.Region.Framework.Scenes
1191 public float maxSimpleArea() 1191 public float maxSimpleArea()
1192 { 1192 {
1193 float a,b; 1193 float a,b;
1194 if(m_shape.Scale.X > m_shape.Scale.Y) 1194 float sx = m_shape.Scale.X;
1195 float sy = m_shape.Scale.Y;
1196 float sz = m_shape.Scale.Z;
1197
1198 if( sx > sy)
1195 { 1199 {
1196 a = m_shape.Scale.X; 1200 a = sx;
1197 if(m_shape.Scale.Y > m_shape.Scale.Z) 1201 if(sy > sz)
1198 b = m_shape.Scale.Y; 1202 b = sy;
1199 else 1203 else
1200 b = m_shape.Scale.Z; 1204 b = sz;
1201 } 1205 }
1202 else 1206 else
1203 { 1207 {
1204 a = m_shape.Scale.Y; 1208 a = sy;
1205 if(m_shape.Scale.X > m_shape.Scale.Z) 1209 if(sx > sz)
1206 b = m_shape.Scale.X; 1210 b = sx;
1207 else 1211 else
1208 b = m_shape.Scale.Z; 1212 b = sz;
1209 } 1213 }
1210 1214
1211 return a*b; 1215 return a * b;
1212 } 1216 }
1213 1217
1214 public UpdateRequired UpdateFlag { get; set; } 1218 public UpdateRequired UpdateFlag { get; set; }