change ODEs topcolliders code ( still bad), plus a few memory leaks

LSLKeyTest
UbitUmarov 2016-08-22 20:28:15 +01:00
parent a2c80b20d7
commit 133fce98e7
5 changed files with 34 additions and 40 deletions

View File

@ -97,9 +97,8 @@ namespace OpenSim.Region.UserStatistics
sdr.Read(); sdr.Read();
totalregions = Convert.ToInt32(sdr["regcnt"]); totalregions = Convert.ToInt32(sdr["regcnt"]);
} }
sdr.Close(); sdr.Close();
sdr.Dispose(); cmd.Dispose();
sql = sql =
"select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;"; "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
@ -120,7 +119,7 @@ namespace OpenSim.Region.UserStatistics
} }
} }
sdr.Close(); sdr.Close();
sdr.Dispose(); cmd.Dispose();
if (totalregions > 1) if (totalregions > 1)
{ {
@ -143,11 +142,8 @@ namespace OpenSim.Region.UserStatistics
} }
} }
sdr.Close(); sdr.Close();
sdr.Dispose(); cmd.Dispose();
} }
} }
foreach (ClientVersionData cvd in cliRegData) foreach (ClientVersionData cvd in cliRegData)
@ -163,9 +159,6 @@ namespace OpenSim.Region.UserStatistics
{ {
regionTotals.Add(cvd.region_id, cvd.count); regionTotals.Add(cvd.region_id, cvd.count);
} }
} }
modeldata["ClientData"] = clidata; modeldata["ClientData"] = clidata;

View File

@ -227,7 +227,10 @@ TD.align_top { vertical-align: top; }
returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]); returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
} }
sdr.Close();
cmd.Dispose();
} }
return returnstruct; return returnstruct;
} }

View File

@ -145,8 +145,7 @@ namespace OpenSim.Region.UserStatistics
} }
} }
sdr.Close(); sdr.Close();
sdr.Dispose(); cmd.Dispose();
} }
modeldata["SessionData"] = lstSessions; modeldata["SessionData"] = lstSessions;
return modeldata; return modeldata;

View File

@ -3452,6 +3452,11 @@ namespace OpenSim.Region.PhysicsModule.ODE
} }
} }
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders() public override Dictionary<uint, float> GetTopColliders()
{ {
Dictionary<uint, float> topColliders; Dictionary<uint, float> topColliders;
@ -3459,7 +3464,7 @@ namespace OpenSim.Region.PhysicsModule.ODE
lock (_prims) lock (_prims)
{ {
List<OdePrim> orderedPrims = new List<OdePrim>(_prims); List<OdePrim> orderedPrims = new List<OdePrim>(_prims);
orderedPrims.OrderByDescending(p => p.CollisionScore); orderedPrims.Sort(compareByCollisionsDesc);
topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore); topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
foreach (OdePrim p in _prims) foreach (OdePrim p in _prims)

View File

@ -30,6 +30,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Threading; using System.Threading;
@ -803,14 +804,6 @@ namespace OpenSim.Region.PhysicsModule.ubOde
return; return;
} }
// update actors collision score
if (p1.CollisionScore >= float.MaxValue - count)
p1.CollisionScore = 0;
p1.CollisionScore += count;
if (p2.CollisionScore >= float.MaxValue - count)
p2.CollisionScore = 0;
p2.CollisionScore += count;
// get first contact // get first contact
d.ContactGeom curContact = new d.ContactGeom(); d.ContactGeom curContact = new d.ContactGeom();
@ -1056,6 +1049,12 @@ namespace OpenSim.Region.PhysicsModule.ubOde
{ {
uint obj2LocalID = 0; uint obj2LocalID = 0;
// update actors collision score
if (p1.CollisionScore < float.MaxValue)
p1.CollisionScore += 1.0f;
if (p2.CollisionScore < float.MaxValue)
p2.CollisionScore += 1.0f;
bool p1events = p1.SubscribedEvents(); bool p1events = p1.SubscribedEvents();
bool p2events = p2.SubscribedEvents(); bool p2events = p2.SubscribedEvents();
@ -2569,27 +2568,22 @@ namespace OpenSim.Region.PhysicsModule.ubOde
} }
} }
private int compareByCollisionsDesc(OdePrim A, OdePrim B)
{
return -A.CollisionScore.CompareTo(B.CollisionScore);
}
public override Dictionary<uint, float> GetTopColliders() public override Dictionary<uint, float> GetTopColliders()
{ {
Dictionary<uint, float> returncolliders = new Dictionary<uint, float>(); Dictionary<uint, float> topColliders;
int cnt = 0; List<OdePrim> orderedPrims;
lock (_prims) lock (_activeprims)
{ orderedPrims = new List<OdePrim>(_activeprims);
foreach (OdePrim prm in _prims.Values)
{ orderedPrims.Sort(compareByCollisionsDesc);
if (prm.CollisionScore > 0) topColliders = orderedPrims.Take(25).ToDictionary(p => p.LocalID, p => p.CollisionScore);
{
returncolliders.Add(prm.LocalID, prm.CollisionScore); return topColliders;
cnt++;
prm.CollisionScore = 0f;
if (cnt > 25)
{
break;
}
}
}
}
return returncolliders;
} }
public override bool SupportsRayCast() public override bool SupportsRayCast()