protected virtual void Dispose(bool disposing) { if (disposing) { //BUG: this will dispose ALL world's bodies. CJoint[] joints = new CJoint[CHashTables.Joint.Count]; CHashTables.Joint.Values.CopyTo(joints, 0); foreach (CJoint joint in joints) joint.Dispose(); CBody[] bodies = new CBody[CHashTables.Body.Count]; CHashTables.Body.Values.CopyTo(bodies, 0); foreach (CBody body in bodies) body.Dispose(); if (m_Handle != IntPtr.Zero) { Newton.NewtonDestroy(m_Handle); m_Handle = IntPtr.Zero; } // Stuff was left behind, so I'm clearing everything (there's likely only one world anyway) CHashTables.Clear(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { //BUG: this will dispose ALL world's bodies. CJoint[] joints = new CJoint[CHashTables.Joint.Count]; CHashTables.Joint.Values.CopyTo(joints, 0); foreach (CJoint joint in joints) { joint.Dispose(); } CBody[] bodies = new CBody[CHashTables.Body.Count]; CHashTables.Body.Values.CopyTo(bodies, 0); foreach (CBody body in bodies) { body.Dispose(); } if (m_Handle != IntPtr.Zero) { Newton.NewtonDestroy(m_Handle); m_Handle = IntPtr.Zero; } // Stuff was left behind, so I'm clearing everything (there's likely only one world anyway) CHashTables.Clear(); } }
public CTire(CJoint pVehicle, IntPtr pHandle) { m_Vehicle = pVehicle; m_Handle = pHandle; CHashTables.Tire.Add(m_Handle, this); }
protected void RebuildJoint() { VerifyAccess(); if (IsInitialised) { if (_initialising > 0) _needsRebuild = true; else { _joint.Dispose(); _isInitialised = false; _joint = OnInitialise(); if (_joint != null) _isInitialised = true; _needsRebuild = false; } } }
public void Initialise(World world, Body parent, Body child) { if (_isInitialised) return; VerifyAccess(); if (world == null) throw new ArgumentNullException("world"); if (parent == null) throw new ArgumentNullException("parent"); parent.VerifyInitialised("Parent"); if (child == null) throw new ArgumentNullException("child"); child.VerifyInitialised("Child"); _world = world; _parentBody = parent; _childBody = child; _joint = OnInitialise(); if (_joint != null) { _joint.CollisionState = (int)(CollisionState)this.CollisionState; if (this.Stiffness != null) _joint.Stiffness = (float)this.Stiffness; _isInitialised = true; AfterInitialise(); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (_joint != null) { if (_isInitialised) { _joint.UserData = null; _joint.Dispose(); _isInitialised = false; } _joint = null; } } }