ubitODE leaks

avinationmerge
UbitUmarov 2012-07-11 08:13:57 +01:00
parent bb78b327c0
commit 84ab4c4462
3 changed files with 33 additions and 25 deletions

View File

@ -740,6 +740,7 @@ namespace OpenSim.Region.Physics.OdePlugin
if (Shell != IntPtr.Zero)
{
_parent_scene.geom_name_map.Remove(Shell);
_parent_scene.actor_name_map.Remove(Shell);
_parent_scene.waitForSpaceUnlock(_parent_scene.ActiveSpace);
d.GeomDestroy(Shell);
Shell = IntPtr.Zero;
@ -1188,6 +1189,7 @@ namespace OpenSim.Region.Physics.OdePlugin
}
else
{
_parent_scene.RemoveCollisionEventReporting(this);
_parent_scene.RemoveCharacter(this);
// destroy avatar capsule and related ODE data
AvatarGeomAndBodyDestroy();

View File

@ -943,6 +943,8 @@ namespace OpenSim.Region.Physics.OdePlugin
CollisionEventsThisFrame = null;
}
m_eventsubscription = 0;
// for now still done on odescene
// _parent_scene.RemoveCollisionEventReporting(this);
}
public void AddCollisionEvent(uint CollidedWith, ContactPoint contact)

View File

@ -175,7 +175,7 @@ namespace OpenSim.Region.Physics.OdePlugin
const d.ContactFlags comumContactFlags = d.ContactFlags.SoftERP | d.ContactFlags.SoftCFM |d.ContactFlags.Approx1 | d.ContactFlags.Bounce;
const float MaxERP = 0.8f;
const float minERP = 0.2f;
const float minERP = 0.1f;
const float comumContactCFM = 0.0001f;
float frictionMovementMult = 0.8f;
@ -237,20 +237,20 @@ namespace OpenSim.Region.Physics.OdePlugin
private d.NearCallback nearCallback;
private readonly HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
private readonly HashSet<OdePrim> _prims = new HashSet<OdePrim>();
private readonly HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
private readonly HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
private HashSet<OdeCharacter> _characters = new HashSet<OdeCharacter>();
private HashSet<OdePrim> _prims = new HashSet<OdePrim>();
private HashSet<OdePrim> _activeprims = new HashSet<OdePrim>();
private HashSet<OdePrim> _activegroups = new HashSet<OdePrim>();
public OpenSim.Framework.LocklessQueue<ODEchangeitem> ChangesQueue = new OpenSim.Framework.LocklessQueue<ODEchangeitem>();
/// <summary>
/// A list of actors that should receive collision events.
/// </summary>
private readonly List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
private readonly List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
private List<PhysicsActor> _collisionEventPrim = new List<PhysicsActor>();
private List<PhysicsActor> _collisionEventPrimRemove = new List<PhysicsActor>();
private readonly HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
private HashSet<OdeCharacter> _badCharacter = new HashSet<OdeCharacter>();
public Dictionary<IntPtr, String> geom_name_map = new Dictionary<IntPtr, String>();
public Dictionary<IntPtr, PhysicsActor> actor_name_map = new Dictionary<IntPtr, PhysicsActor>();
@ -264,26 +264,21 @@ namespace OpenSim.Region.Physics.OdePlugin
private volatile int m_global_contactcount = 0;
private readonly IntPtr contactgroup;
private IntPtr contactgroup;
public ContactData[] m_materialContactsData = new ContactData[8];
private readonly Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
private readonly Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
private readonly Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
private Dictionary<Vector3, IntPtr> RegionTerrain = new Dictionary<Vector3, IntPtr>();
private Dictionary<IntPtr, float[]> TerrainHeightFieldHeights = new Dictionary<IntPtr, float[]>();
private Dictionary<IntPtr, GCHandle> TerrainHeightFieldHeightsHandlers = new Dictionary<IntPtr, GCHandle>();
private int m_physicsiterations = 10;
private const float m_SkipFramesAtms = 0.40f; // Drop frames gracefully at a 400 ms lag
private readonly PhysicsActor PANull = new NullPhysicsActor();
private PhysicsActor PANull = new NullPhysicsActor();
private float step_time = 0.0f;
public IntPtr world;
private uint obj2LocalID = 0;
private OdeCharacter cc1;
private OdePrim cp1;
private OdeCharacter cc2;
private OdePrim cp2;
// split the spaces acording to contents type
// ActiveSpace contains characters and active prims
@ -921,8 +916,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm;
if (cfm > 0.01f)
cfm = 0.01f;
else if (cfm < 0.0001f)
cfm = 0.0001f;
else if (cfm < 0.00001f)
cfm = 0.00001f;
if ((Math.Abs(p2.Velocity.X - p1.Velocity.X) > 0.1f || Math.Abs(p2.Velocity.Y - p1.Velocity.Y) > 0.1f))
mu *= frictionMovementMult;
@ -949,8 +944,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm;
if (cfm > 0.01f)
cfm = 0.01f;
else if (cfm < 0.0001f)
cfm = 0.0001f;
else if (cfm < 0.00001f)
cfm = 0.00001f;
if (d.GeomGetClass(g1) == d.GeomClassID.TriMeshClass)
{
@ -993,6 +988,8 @@ namespace OpenSim.Region.Physics.OdePlugin
cfm = 0.0001f / cfm;
if (cfm > 0.01f)
cfm = 0.01f;
else if (cfm < 0.00001f)
cfm = 0.00001f;
if (curContact.side1 > 0) // should be 2 ?
IgnoreNegSides = true;
@ -1159,7 +1156,13 @@ namespace OpenSim.Region.Physics.OdePlugin
private void collision_accounting_events(PhysicsActor p1, PhysicsActor p2, ContactPoint contact)
{
obj2LocalID = 0;
OdeCharacter cc1;
OdePrim cp1;
OdeCharacter cc2;
OdePrim cp2;
uint obj2LocalID = 0;
bool p1events = p1.SubscribedEvents();
bool p2events = p2.SubscribedEvents();
@ -1963,6 +1966,7 @@ namespace OpenSim.Region.Physics.OdePlugin
{
RemoveCharacter(defect);
}
defects.Clear();
}
}
@ -2068,13 +2072,13 @@ namespace OpenSim.Region.Physics.OdePlugin
_badCharacter.Clear();
}
}
/*
int nactivegeoms = d.SpaceGetNumGeoms(ActiveSpace);
int nstaticgeoms = d.SpaceGetNumGeoms(StaticSpace);
int ntopgeoms = d.SpaceGetNumGeoms(TopSpace);
int nbodies = d.NTotalBodies;
int ngeoms = d.NTotalGeoms;
*/
// Finished with all sim stepping. If requested, dump world state to file for debugging.
// TODO: This call to the export function is already inside lock (OdeLock) - but is an extra lock needed?
// TODO: This overwrites all dump files in-place. Should this be a growing logfile, or separate snapshots?