(fixture *B2Fixture)
| 651 | } |
| 652 | |
| 653 | func (body *B2Body) DestroyFixture(fixture *B2Fixture) { |
| 654 | |
| 655 | if fixture == nil { |
| 656 | return |
| 657 | } |
| 658 | |
| 659 | B2Assert(body.M_world.IsLocked() == false) |
| 660 | if body.M_world.IsLocked() == true { |
| 661 | return |
| 662 | } |
| 663 | |
| 664 | B2Assert(fixture.M_body == body) |
| 665 | |
| 666 | // Remove the fixture from this body's singly linked list. |
| 667 | B2Assert(body.M_fixtureCount > 0) |
| 668 | node := &body.M_fixtureList |
| 669 | found := false |
| 670 | for *node != nil { |
| 671 | if *node == fixture { |
| 672 | *node = fixture.M_next |
| 673 | found = true |
| 674 | break |
| 675 | } |
| 676 | |
| 677 | node = &(*node).M_next |
| 678 | } |
| 679 | |
| 680 | // You tried to remove a shape that is not attached to this body. |
| 681 | B2Assert(found) |
| 682 | |
| 683 | // Destroy any contacts associated with the fixture. |
| 684 | edge := body.M_contactList |
| 685 | for edge != nil { |
| 686 | c := edge.Contact |
| 687 | edge = edge.Next |
| 688 | |
| 689 | fixtureA := c.GetFixtureA() |
| 690 | fixtureB := c.GetFixtureB() |
| 691 | |
| 692 | if fixture == fixtureA || fixture == fixtureB { |
| 693 | // This destroys the contact and removes it from |
| 694 | // this body's contact list. |
| 695 | body.M_world.M_contactManager.Destroy(c) |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | if (body.M_flags & B2Body_Flags.E_activeFlag) != 0x0000 { |
| 700 | broadPhase := &body.M_world.M_contactManager.M_broadPhase |
| 701 | fixture.DestroyProxies(broadPhase) |
| 702 | } |
| 703 | |
| 704 | fixture.M_body = nil |
| 705 | fixture.M_next = nil |
| 706 | fixture.Destroy() |
| 707 | |
| 708 | body.M_fixtureCount-- |
| 709 | |
| 710 | // Reset the mass data. |
nothing calls this directly
no test coverage detected