diff options
author | UbitUmarov | 2019-01-25 20:49:18 +0000 |
---|---|---|
committer | UbitUmarov | 2019-01-25 20:49:18 +0000 |
commit | 3ee70aac0b41cd28e41f31a679b4ac4d615f46dc (patch) | |
tree | 22a90f918571616cdbfd5240012c65deaca2410a /OpenSim/Region | |
parent | a few changes on priority queues and their heap (diff) | |
download | opensim-SC-3ee70aac0b41cd28e41f31a679b4ac4d615f46dc.zip opensim-SC-3ee70aac0b41cd28e41f31a679b4ac4d615f46dc.tar.gz opensim-SC-3ee70aac0b41cd28e41f31a679b4ac4d615f46dc.tar.bz2 opensim-SC-3ee70aac0b41cd28e41f31a679b4ac4d615f46dc.tar.xz |
mess around with prioritizer
Diffstat (limited to 'OpenSim/Region')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 122 | ||||
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Prioritizer.cs | 82 |
2 files changed, 88 insertions, 116 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 8103eac..cbb1075 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -45,6 +45,7 @@ using OpenSim.Region.Framework.Interfaces; | |||
45 | using OpenSim.Region.Framework.Scenes; | 45 | using OpenSim.Region.Framework.Scenes; |
46 | using OpenSim.Services.Interfaces; | 46 | using OpenSim.Services.Interfaces; |
47 | 47 | ||
48 | |||
48 | using AssetLandmark = OpenSim.Framework.AssetLandmark; | 49 | using AssetLandmark = OpenSim.Framework.AssetLandmark; |
49 | using Caps = OpenSim.Framework.Capabilities.Caps; | 50 | using Caps = OpenSim.Framework.Capabilities.Caps; |
50 | using PermissionMask = OpenSim.Framework.PermissionMask; | 51 | using PermissionMask = OpenSim.Framework.PermissionMask; |
@@ -4097,6 +4098,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4097 | if (!IsActive) | 4098 | if (!IsActive) |
4098 | return; | 4099 | return; |
4099 | 4100 | ||
4101 | ScenePresence mysp = (ScenePresence)SceneAgent; | ||
4102 | if (mysp == null) | ||
4103 | return; | ||
4104 | |||
4100 | List<ObjectUpdatePacket.ObjectDataBlock> objectUpdateBlocks = null; | 4105 | List<ObjectUpdatePacket.ObjectDataBlock> objectUpdateBlocks = null; |
4101 | List<ObjectUpdateCompressedPacket.ObjectDataBlock> compressedUpdateBlocks = null; | 4106 | List<ObjectUpdateCompressedPacket.ObjectDataBlock> compressedUpdateBlocks = null; |
4102 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> terseUpdateBlocks = null; | 4107 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> terseUpdateBlocks = null; |
@@ -4114,39 +4119,36 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4114 | } | 4119 | } |
4115 | 4120 | ||
4116 | EntityUpdate update; | 4121 | EntityUpdate update; |
4117 | Int32 timeinqueue; // this is just debugging code & can be dropped later | ||
4118 | 4122 | ||
4119 | bool doCulling = m_scene.ObjectsCullingByDistance; | 4123 | bool doCulling = m_scene.ObjectsCullingByDistance; |
4120 | float cullingrange = 64.0f; | 4124 | float cullingrange = 64.0f; |
4121 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | ||
4122 | // Vector3 mycamera = Vector3.Zero; | ||
4123 | Vector3 mypos = Vector3.Zero; | 4125 | Vector3 mypos = Vector3.Zero; |
4124 | ScenePresence mysp = (ScenePresence)SceneAgent; | ||
4125 | 4126 | ||
4126 | bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; | 4127 | bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; |
4127 | // we should have a presence | ||
4128 | if(mysp == null) | ||
4129 | return; | ||
4130 | 4128 | ||
4131 | if(doCulling) | 4129 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); |
4130 | |||
4131 | if (doCulling) | ||
4132 | { | 4132 | { |
4133 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; | 4133 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; |
4134 | // mycamera = mysp.CameraPosition; | ||
4135 | mypos = mysp.AbsolutePosition; | 4134 | mypos = mysp.AbsolutePosition; |
4136 | } | 4135 | } |
4137 | 4136 | ||
4138 | while (maxUpdatesBytes > 0) | 4137 | while (maxUpdatesBytes > 0) |
4139 | { | 4138 | { |
4139 | if (!IsActive) | ||
4140 | return; | ||
4141 | |||
4140 | lock (m_entityUpdates.SyncRoot) | 4142 | lock (m_entityUpdates.SyncRoot) |
4141 | { | 4143 | { |
4142 | if(orderedDequeue) | 4144 | if(orderedDequeue) |
4143 | { | 4145 | { |
4144 | if (!m_entityUpdates.TryOrderedDequeue(out update, out timeinqueue)) | 4146 | if (!m_entityUpdates.TryOrderedDequeue(out update)) |
4145 | break; | 4147 | break; |
4146 | } | 4148 | } |
4147 | else | 4149 | else |
4148 | { | 4150 | { |
4149 | if (!m_entityUpdates.TryDequeue(out update, out timeinqueue)) | 4151 | if (!m_entityUpdates.TryDequeue(out update)) |
4150 | break; | 4152 | break; |
4151 | } | 4153 | } |
4152 | } | 4154 | } |
@@ -4166,13 +4168,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4166 | SceneObjectGroup grp = part.ParentGroup; | 4168 | SceneObjectGroup grp = part.ParentGroup; |
4167 | if (grp.inTransit && !update.Flags.HasFlag(PrimUpdateFlags.SendInTransit)) | 4169 | if (grp.inTransit && !update.Flags.HasFlag(PrimUpdateFlags.SendInTransit)) |
4168 | continue; | 4170 | continue; |
4169 | /* debug | ||
4170 | if (update.Flags.HasFlag(PrimUpdateFlags.SendInTransit)) | ||
4171 | { | ||
4172 | |||
4173 | 4171 | ||
4174 | } | ||
4175 | */ | ||
4176 | if (grp.IsDeleted) | 4172 | if (grp.IsDeleted) |
4177 | { | 4173 | { |
4178 | // Don't send updates for objects that have been marked deleted. | 4174 | // Don't send updates for objects that have been marked deleted. |
@@ -4234,20 +4230,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4234 | if(GroupsNeedFullUpdate.Contains(grp)) | 4230 | if(GroupsNeedFullUpdate.Contains(grp)) |
4235 | continue; | 4231 | continue; |
4236 | 4232 | ||
4237 | bool inview = false; | 4233 | bool inViewGroups = false; |
4238 | lock(GroupsInView) | 4234 | lock(GroupsInView) |
4239 | inview = GroupsInView.Contains(grp); | 4235 | inViewGroups = GroupsInView.Contains(grp); |
4240 | 4236 | ||
4241 | if(!inview) | 4237 | if(!inViewGroups) |
4242 | { | 4238 | { |
4243 | float bradius = grp.GetBoundsRadius(); | 4239 | Vector3 partpos = grp.getCenterOffset(); |
4244 | Vector3 partpos = grp.AbsolutePosition + grp.getBoundsCenter(); | ||
4245 | // float dcam = (partpos - mycamera).LengthSquared(); | ||
4246 | float dpos = (partpos - mypos).LengthSquared(); | 4240 | float dpos = (partpos - mypos).LengthSquared(); |
4247 | // if(dcam < dpos) | 4241 | float maxview = grp.GetBoundsRadius() + cullingrange; |
4248 | // dpos = dcam; | 4242 | if (dpos > maxview * maxview) |
4249 | dpos = (float)Math.Sqrt(dpos) - bradius; | ||
4250 | if(dpos > cullingrange) | ||
4251 | continue; | 4243 | continue; |
4252 | 4244 | ||
4253 | GroupsNeedFullUpdate.Add(grp); | 4245 | GroupsNeedFullUpdate.Add(grp); |
@@ -4488,10 +4480,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4488 | { | 4480 | { |
4489 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) | 4481 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) |
4490 | { | 4482 | { |
4491 | foreach(SceneObjectPart p in grp.Parts) | 4483 | lock (GroupsInView) |
4492 | SendEntityUpdate(p,PrimUpdateFlags.CancelKill); | ||
4493 | lock(GroupsInView) | ||
4494 | GroupsInView.Add(grp); | 4484 | GroupsInView.Add(grp); |
4485 | foreach (SceneObjectPart p in grp.Parts) | ||
4486 | SendEntityUpdate(p, PrimUpdateFlags.CancelKill); | ||
4495 | } | 4487 | } |
4496 | } | 4488 | } |
4497 | 4489 | ||
@@ -4542,26 +4534,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4542 | if(!doCulling) | 4534 | if(!doCulling) |
4543 | return; | 4535 | return; |
4544 | 4536 | ||
4545 | if(CheckGroupsInViewBusy) | 4537 | if (!IsActive) |
4546 | return; | 4538 | return; |
4547 | 4539 | ||
4548 | CheckGroupsInViewBusy = true; | 4540 | if (CheckGroupsInViewBusy) |
4541 | return; | ||
4549 | 4542 | ||
4550 | float cullingrange = 64.0f; | ||
4551 | // Vector3 mycamera = Vector3.Zero; | ||
4552 | Vector3 mypos = Vector3.Zero; | ||
4553 | ScenePresence mysp = (ScenePresence)SceneAgent; | 4543 | ScenePresence mysp = (ScenePresence)SceneAgent; |
4554 | if(mysp != null && !mysp.IsDeleted) | 4544 | if (mysp == null || mysp.IsDeleted) |
4555 | { | ||
4556 | cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; | ||
4557 | // mycamera = mysp.CameraPosition; | ||
4558 | mypos = mysp.AbsolutePosition; | ||
4559 | } | ||
4560 | else | ||
4561 | { | ||
4562 | CheckGroupsInViewBusy= false; | ||
4563 | return; | 4545 | return; |
4564 | } | 4546 | |
4547 | CheckGroupsInViewBusy = true; | ||
4548 | |||
4549 | float cullingrange = mysp.DrawDistance + m_scene.ReprioritizationDistance + 16f; | ||
4550 | Vector3 mypos = mysp.AbsolutePosition; | ||
4565 | 4551 | ||
4566 | HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>(); | 4552 | HashSet<SceneObjectGroup> NewGroupsInView = new HashSet<SceneObjectGroup>(); |
4567 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); | 4553 | HashSet<SceneObjectGroup> GroupsNeedFullUpdate = new HashSet<SceneObjectGroup>(); |
@@ -4570,7 +4556,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4570 | EntityBase[] entities = m_scene.Entities.GetEntities(); | 4556 | EntityBase[] entities = m_scene.Entities.GetEntities(); |
4571 | foreach (EntityBase e in entities) | 4557 | foreach (EntityBase e in entities) |
4572 | { | 4558 | { |
4573 | if(!IsActive) | 4559 | if (!IsActive) |
4574 | return; | 4560 | return; |
4575 | 4561 | ||
4576 | if (e != null && e is SceneObjectGroup) | 4562 | if (e != null && e is SceneObjectGroup) |
@@ -4579,27 +4565,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4579 | if(grp.IsDeleted || grp.IsAttachment) | 4565 | if(grp.IsDeleted || grp.IsAttachment) |
4580 | continue; | 4566 | continue; |
4581 | 4567 | ||
4582 | float bradius = grp.GetBoundsRadius(); | 4568 | bool inviewgroups; |
4583 | Vector3 grppos = grp.AbsolutePosition + grp.getBoundsCenter(); | 4569 | lock (GroupsInView) |
4584 | // float dcam = (grppos - mycamera).LengthSquared(); | 4570 | inviewgroups = GroupsInView.Contains(grp); |
4585 | float dpos = (grppos - mypos).LengthSquared(); | ||
4586 | // if(dcam < dpos) | ||
4587 | // dpos = dcam; | ||
4588 | |||
4589 | dpos = (float)Math.Sqrt(dpos) - bradius; | ||
4590 | 4571 | ||
4591 | bool inview; | 4572 | Vector3 grppos = grp.getCenterOffset(); |
4592 | lock(GroupsInView) | 4573 | float dpos = (grppos - mypos).LengthSquared(); |
4593 | inview = GroupsInView.Contains(grp); | ||
4594 | 4574 | ||
4595 | if(dpos > cullingrange) | 4575 | float maxview = grp.GetBoundsRadius() + cullingrange; |
4576 | if (dpos > maxview * maxview) | ||
4596 | { | 4577 | { |
4597 | if(inview) | 4578 | if(inviewgroups) |
4598 | kills.Add(grp); | 4579 | kills.Add(grp); |
4599 | } | 4580 | } |
4600 | else | 4581 | else |
4601 | { | 4582 | { |
4602 | if(!inview) | 4583 | if(!inviewgroups) |
4603 | GroupsNeedFullUpdate.Add(grp); | 4584 | GroupsNeedFullUpdate.Add(grp); |
4604 | NewGroupsInView.Add(grp); | 4585 | NewGroupsInView.Add(grp); |
4605 | } | 4586 | } |
@@ -4614,7 +4595,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4614 | List<uint> partIDs = new List<uint>(); | 4595 | List<uint> partIDs = new List<uint>(); |
4615 | foreach(SceneObjectGroup grp in kills) | 4596 | foreach(SceneObjectGroup grp in kills) |
4616 | { | 4597 | { |
4617 | SendEntityUpdate(grp.RootPart,PrimUpdateFlags.Kill); | 4598 | SendEntityUpdate(grp.RootPart, PrimUpdateFlags.Kill); |
4618 | foreach(SceneObjectPart p in grp.Parts) | 4599 | foreach(SceneObjectPart p in grp.Parts) |
4619 | { | 4600 | { |
4620 | if(p != grp.RootPart) | 4601 | if(p != grp.RootPart) |
@@ -4636,7 +4617,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4636 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) | 4617 | foreach(SceneObjectGroup grp in GroupsNeedFullUpdate) |
4637 | { | 4618 | { |
4638 | foreach(SceneObjectPart p in grp.Parts) | 4619 | foreach(SceneObjectPart p in grp.Parts) |
4639 | SendEntityUpdate(p,PrimUpdateFlags.CancelKill); | 4620 | SendEntityUpdate(p, PrimUpdateFlags.CancelKill); |
4640 | } | 4621 | } |
4641 | } | 4622 | } |
4642 | 4623 | ||
@@ -4645,13 +4626,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4645 | 4626 | ||
4646 | private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) | 4627 | private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity) |
4647 | { | 4628 | { |
4648 | if (entity != null) | 4629 | if (entity == null) |
4649 | { | 4630 | return false; |
4650 | priority = m_prioritizer.GetUpdatePriority(this, entity); | ||
4651 | return true; | ||
4652 | } | ||
4653 | 4631 | ||
4654 | return false; | 4632 | priority = m_prioritizer.GetUpdatePriority(this, entity); |
4633 | return true; | ||
4655 | } | 4634 | } |
4656 | 4635 | ||
4657 | public void FlushPrimUpdates() | 4636 | public void FlushPrimUpdates() |
@@ -4831,7 +4810,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4831 | { | 4810 | { |
4832 | uint priority = 0; // time based ordering only | 4811 | uint priority = 0; // time based ordering only |
4833 | lock (m_entityProps.SyncRoot) | 4812 | lock (m_entityProps.SyncRoot) |
4834 | m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false)); | 4813 | m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity, requestFlags, true, false)); |
4835 | } | 4814 | } |
4836 | 4815 | ||
4837 | private void ResendPropertyUpdate(ObjectPropertyUpdate update) | 4816 | private void ResendPropertyUpdate(ObjectPropertyUpdate update) |
@@ -4885,7 +4864,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4885 | bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; | 4864 | bool orderedDequeue = m_scene.UpdatePrioritizationScheme == UpdatePrioritizationSchemes.SimpleAngularDistance; |
4886 | 4865 | ||
4887 | EntityUpdate iupdate; | 4866 | EntityUpdate iupdate; |
4888 | Int32 timeinqueue; // this is just debugging code & can be dropped later | ||
4889 | 4867 | ||
4890 | while (maxUpdateBytes > 0) | 4868 | while (maxUpdateBytes > 0) |
4891 | { | 4869 | { |
@@ -4893,12 +4871,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4893 | { | 4871 | { |
4894 | if(orderedDequeue) | 4872 | if(orderedDequeue) |
4895 | { | 4873 | { |
4896 | if (!m_entityProps.TryOrderedDequeue(out iupdate, out timeinqueue)) | 4874 | if (!m_entityProps.TryOrderedDequeue(out iupdate)) |
4897 | break; | 4875 | break; |
4898 | } | 4876 | } |
4899 | else | 4877 | else |
4900 | { | 4878 | { |
4901 | if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue)) | 4879 | if (!m_entityProps.TryDequeue(out iupdate)) |
4902 | break; | 4880 | break; |
4903 | } | 4881 | } |
4904 | } | 4882 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Prioritizer.cs b/OpenSim/Region/Framework/Scenes/Prioritizer.cs index cc4df17..4c423d4 100644 --- a/OpenSim/Region/Framework/Scenes/Prioritizer.cs +++ b/OpenSim/Region/Framework/Scenes/Prioritizer.cs | |||
@@ -107,7 +107,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
107 | if(presence.ParentPart.ParentGroup == sog) | 107 | if(presence.ParentPart.ParentGroup == sog) |
108 | return 2; | 108 | return 2; |
109 | } | 109 | } |
110 | 110 | ||
111 | pqueue = ComputeDistancePriority(client, entity, false); | 111 | pqueue = ComputeDistancePriority(client, entity, false); |
112 | 112 | ||
113 | // Non physical prims are lower priority than physical prims | 113 | // Non physical prims are lower priority than physical prims |
@@ -165,15 +165,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | // And convert the distance to a priority queue, this computation gives queues | 165 | // And convert the distance to a priority queue, this computation gives queues |
166 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | 166 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m |
167 | uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue | 167 | uint pqueue = PriorityQueue.NumberOfImmediateQueues + 1; // reserve attachments queue |
168 | uint queues = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues; | ||
169 | /* | ||
170 | for (int i = 0; i < queues - 1; i++) | ||
171 | { | ||
172 | if (distance < 30 * Math.Pow(2.0,i)) | ||
173 | break; | ||
174 | pqueue++; | ||
175 | } | ||
176 | */ | ||
177 | if (distance > 10f) | 168 | if (distance > 10f) |
178 | { | 169 | { |
179 | float tmp = (float)Math.Log((double)distance) * 1.442695f - 3.321928f; | 170 | float tmp = (float)Math.Log((double)distance) * 1.442695f - 3.321928f; |
@@ -182,8 +173,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
182 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) | 173 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) |
183 | // 2st constant makes it be log2(distance/10) | 174 | // 2st constant makes it be log2(distance/10) |
184 | pqueue += (uint)tmp; | 175 | pqueue += (uint)tmp; |
185 | if (pqueue > queues - 1) | ||
186 | pqueue = queues - 1; | ||
187 | } | 176 | } |
188 | 177 | ||
189 | // If this is a root agent, then determine front & back | 178 | // If this is a root agent, then determine front & back |
@@ -216,11 +205,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
216 | 205 | ||
217 | private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity) | 206 | private uint ComputeAngleDistancePriority(ScenePresence presence, ISceneEntity entity) |
218 | { | 207 | { |
219 | // And convert the distance to a priority queue, this computation gives queues | ||
220 | // at 10, 20, 40, 80, 160, 320, 640, and 1280m | ||
221 | // uint minpqueue = PriorityQueue.NumberOfImmediateQueues; | ||
222 | uint maxqueue = PriorityQueue.NumberOfQueues - PriorityQueue.NumberOfImmediateQueues -1; | ||
223 | // uint pqueue = minpqueue; | ||
224 | uint pqueue = PriorityQueue.NumberOfImmediateQueues; | 208 | uint pqueue = PriorityQueue.NumberOfImmediateQueues; |
225 | float distance; | 209 | float distance; |
226 | 210 | ||
@@ -228,36 +212,49 @@ namespace OpenSim.Region.Framework.Scenes | |||
228 | if(entity is ScenePresence) | 212 | if(entity is ScenePresence) |
229 | { | 213 | { |
230 | ScenePresence sp = entity as ScenePresence; | 214 | ScenePresence sp = entity as ScenePresence; |
231 | distance = Vector3.Distance(presencePos, sp.AbsolutePosition); | 215 | distance = Vector3.DistanceSquared(presencePos, sp.AbsolutePosition); |
232 | distance *= 0.5f; | 216 | if (distance > 400f) |
233 | } | ||
234 | else | ||
235 | { | ||
236 | SceneObjectGroup group = (entity as SceneObjectPart).ParentGroup; | ||
237 | if(presence.ParentPart != null) | ||
238 | { | 217 | { |
239 | if(presence.ParentPart.ParentGroup == group) | 218 | float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f; |
240 | return pqueue; | 219 | pqueue += (uint)tmp; |
241 | } | 220 | } |
242 | if(group.IsAttachment) | 221 | return pqueue; |
222 | } | ||
223 | |||
224 | SceneObjectPart sop = entity as SceneObjectPart; | ||
225 | SceneObjectGroup group = sop.ParentGroup; | ||
226 | if(presence.ParentPart != null) | ||
227 | { | ||
228 | if(presence.ParentPart.ParentGroup == group) | ||
229 | return pqueue; | ||
230 | } | ||
231 | |||
232 | if (group.IsAttachment) | ||
233 | { | ||
234 | if(group.RootPart.LocalId == presence.LocalId) | ||
235 | return pqueue; | ||
236 | |||
237 | distance = Vector3.DistanceSquared(presencePos, group.AbsolutePosition); | ||
238 | if (distance > 400f) | ||
243 | { | 239 | { |
244 | if(group.RootPart.LocalId == presence.LocalId) | 240 | float tmp = (float)Math.Log(distance) * 0.7213475f - 4.321928f; |
245 | return pqueue; | 241 | pqueue += (uint)tmp; |
246 | } | 242 | } |
247 | 243 | return pqueue; | |
248 | float bradius = group.GetBoundsRadius(); | ||
249 | Vector3 grppos = group.AbsolutePosition + group.getBoundsCenter(); | ||
250 | distance = Vector3.Distance(presencePos, grppos); | ||
251 | distance -= bradius; | ||
252 | distance *= group.getAreaFactor(); | ||
253 | if(group.IsAttachment) | ||
254 | distance *= 0.5f; | ||
255 | else if(group.UsesPhysics) | ||
256 | distance *= 0.6f; | ||
257 | else if(group.GetSittingAvatarsCount() > 0) | ||
258 | distance *= 0.5f; | ||
259 | } | 244 | } |
260 | 245 | ||
246 | float bradius = group.GetBoundsRadius(); | ||
247 | Vector3 grppos = group.getCenterOffset(); | ||
248 | distance = Vector3.Distance(presencePos, grppos); | ||
249 | distance -= bradius; | ||
250 | distance *= group.getAreaFactor(); | ||
251 | if(group.IsAttachment) | ||
252 | distance *= 0.5f; | ||
253 | else if(group.UsesPhysics) | ||
254 | distance *= 0.6f; | ||
255 | else if(group.GetSittingAvatarsCount() > 0) | ||
256 | distance *= 0.5f; | ||
257 | |||
261 | if (distance > 10f) | 258 | if (distance > 10f) |
262 | { | 259 | { |
263 | float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f; | 260 | float tmp = (float)Math.Log(distance) * 1.442695f - 3.321928f; |
@@ -265,10 +262,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
265 | // now | 262 | // now |
266 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) | 263 | // 1st constant is 1/(log(2)) (natural log) so we get log2(distance) |
267 | // 2st constant makes it be log2(distance/10) | 264 | // 2st constant makes it be log2(distance/10) |
268 | |||
269 | pqueue += (uint)tmp; | 265 | pqueue += (uint)tmp; |
270 | if (pqueue > maxqueue) | ||
271 | pqueue = maxqueue; | ||
272 | } | 266 | } |
273 | 267 | ||
274 | return pqueue; | 268 | return pqueue; |