Fix OdeScene.GetTopColliders() to return the top 25 colliders rather than the first 25 that had non-zero collision scores.

Also zeros collisions scores on all prims after report collection, not just the top 25.
As before, this collision scores are only reset after a report is requested, which may give unrealistic numbers on the first request.
So to see more realistic scores, ignore the first report and then refresh the request after a couple of seconds or so.
0.7.4.1
Justin Clark-Casey (justincc) 2012-06-01 00:26:11 +01:00
parent 0b02a4d42e
commit 878b67b333
1 changed files with 13 additions and 19 deletions

View File

@ -30,20 +30,21 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.IO;
using System.Diagnostics;
using log4net;
using Nini.Config;
using Ode.NET;
using OpenMetaverse;
#if USE_DRAWSTUFF
using Drawstuff.NET;
#endif
using OpenSim.Framework;
using OpenSim.Region.Physics.Manager;
using OpenMetaverse;
namespace OpenSim.Region.Physics.OdePlugin
{
@ -3868,26 +3869,19 @@ namespace OpenSim.Region.Physics.OdePlugin
public override Dictionary<uint, float> GetTopColliders()
{
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>();
int cnt = 0;
Dictionary<uint, float> topColliders;
lock (_prims)
{
foreach (OdePrim prm in _prims)
{
if (prm.CollisionScore > 0)
{
returncolliders.Add(prm.LocalID, prm.CollisionScore);
cnt++;
prm.CollisionScore = 0f;
if (cnt > 25)
{
break;
}
}
}
List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
orderedPrims.OrderByDescending(p => p.CollisionScore).Take(25);
topColliders = orderedPrims.ToDictionary(p => p.LocalID, p => p.CollisionScore);
foreach (OdePrim p in _prims)
p.CollisionScore = 0;
}
return returncolliders;
return topColliders;
}
public override bool SupportsRayCast()