diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Prioritizer.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Prioritizer.cs | 82 |
1 files changed, 38 insertions, 44 deletions
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; |