private void Decompose() { //Unsubsribe from the PostSolve delegate _world.ContactManager.PostSolve -= PostSolve; for (int i = 0; i < Parts.Count; i++) { Fixture oldFixture = Parts[i]; Shape shape = oldFixture.Shape.Clone(); object userData = oldFixture.UserData; MainBody.DestroyFixture(oldFixture); Body body = BodyFactory.CreateBody(_world, MainBody.Position, MainBody.Rotation, BodyType.Dynamic, MainBody.UserData); Fixture newFixture = body.CreateFixture(shape); newFixture.UserData = userData; Parts[i] = newFixture; body.AngularVelocity = _angularVelocitiesCache[i]; body.LinearVelocity = _velocitiesCache[i]; } _world.RemoveBody(MainBody); _world.RemoveBreakableBody(this); }
public void Dispose() { if (!IsDisposed) { _world.RemoveBody(this); IsDisposed = true; GC.SuppressFinalize(this); } }