PhysicsBody::~PhysicsBody() { for (auto it = _joints.begin(); it != _joints.end(); ++it) { PhysicsJoint* joint = *it; PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA(); other->removeJoint(joint); delete joint; } CC_SAFE_DELETE(_info); }
PhysicsBody::~PhysicsBody() { CC_SAFE_DELETE(_info); removeAllShapes(); for (auto it = _joints.begin(); it != _joints.end(); ++it) { PhysicsJoint* joint = *it; PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyA() : joint->getBodyB(); other->_joints.erase(std::find(other->_joints.begin(), other->_joints.end(), joint)); delete joint; } }
PhysicsBody::~PhysicsBody() { for (auto it = _joints.begin(); it != _joints.end(); ++it) { PhysicsJoint* joint = *it; PhysicsBody* other = joint->getBodyA() == this ? joint->getBodyB() : joint->getBodyA(); other->removeJoint(joint); delete joint; } if (_cpBody) { cpBodyFree(_cpBody); } }