| 677 | } |
| 678 | |
| 679 | void PhysicsWorld::removeJoint(PhysicsJoint* joint, bool destroy) |
| 680 | { |
| 681 | if (joint) |
| 682 | { |
| 683 | if (joint->getWorld() != this && destroy) |
| 684 | { |
| 685 | AXLOGD( |
| 686 | "physics warning: the joint is not in this world, it won't be destroyed until the body it connects is " |
| 687 | "destroyed"); |
| 688 | return; |
| 689 | } |
| 690 | |
| 691 | joint->_destroyMark = destroy; |
| 692 | |
| 693 | bool removedFromDelayAdd = false; |
| 694 | auto it = std::find(_delayAddJoints.begin(), _delayAddJoints.end(), joint); |
| 695 | if (it != _delayAddJoints.end()) |
| 696 | { |
| 697 | _delayAddJoints.erase(it); |
| 698 | removedFromDelayAdd = true; |
| 699 | } |
| 700 | |
| 701 | if (cpSpaceIsLocked(_cpSpace)) |
| 702 | { |
| 703 | if (removedFromDelayAdd) |
| 704 | return; |
| 705 | if (std::find(_delayRemoveJoints.rbegin(), _delayRemoveJoints.rend(), joint) == _delayRemoveJoints.rend()) |
| 706 | { |
| 707 | _delayRemoveJoints.emplace_back(joint); |
| 708 | } |
| 709 | } |
| 710 | else |
| 711 | { |
| 712 | doRemoveJoint(joint); |
| 713 | } |
| 714 | } |
| 715 | } |
| 716 | |
| 717 | void PhysicsWorld::updateJoints() |
| 718 | { |
no test coverage detected