protected override void Dispose(bool isdisposing) { if (isInWorld && isdisposing && m_multibody != null) { BPhysicsWorld pw = BPhysicsWorld.Get(); if (pw != null && pw.world != null) { if (m_baseCollider != null) { pw.world.RemoveCollisionObject(m_baseCollider); } if (m_multibody != null) { ((MultiBodyDynamicsWorld)pw.world).RemoveMultiBody(m_multibody); } } } if (m_multibody != null) { m_multibody.Dispose(); m_multibody = null; } if (m_baseCollider != null) { m_baseCollider.Dispose(); m_baseCollider = null; } if (m_links != null) { m_links.Clear(); m_links = null; } }
protected override void Dispose(bool isdisposing) { if (isInWorld && isdisposing && m_linkCollider != null) { BPhysicsWorld pw = BPhysicsWorld.Get(); if (pw != null && pw.world != null) { //constraints must be removed before rigid body is removed /* * for (int i = m_linkCollider.NumConstraintRefs; i > 0; i--) * { * BTypedConstraint tc = (BTypedConstraint)m_rigidBody.GetConstraintRef(i - 1).Userobject; * ((DiscreteDynamicsWorld)pw.world).RemoveConstraint(tc.GetConstraint()); * } */ ((DiscreteDynamicsWorld)pw.world).RemoveCollisionObject(m_linkCollider); } } if (m_linkCollider != null) { m_linkCollider.Dispose(); m_linkCollider = null; } }