CharacterController: leak fix for btRigidBody and it's shape

This commit is contained in:
Anthony J. Thibault 2016-04-15 15:05:54 -07:00
parent e4f8a67e60
commit 0b7a5c4df8
2 changed files with 12 additions and 1 deletions

View file

@ -72,6 +72,17 @@ CharacterController::CharacterController() {
_pendingFlags = PENDING_FLAG_UPDATE_SHAPE;
}
CharacterController::~CharacterController() {
if (_rigidBody) {
btCollisionShape* shape = _rigidBody->getCollisionShape();
if (shape) {
delete shape;
}
delete _rigidBody;
_rigidBody = nullptr;
}
}
bool CharacterController::needsRemoval() const {
return ((_pendingFlags & PENDING_FLAG_REMOVE_FROM_SIMULATION) == PENDING_FLAG_REMOVE_FROM_SIMULATION);
}

View file

@ -36,7 +36,7 @@ class btDynamicsWorld;
class CharacterController : public btCharacterControllerInterface {
public:
CharacterController();
virtual ~CharacterController() {}
virtual ~CharacterController();
bool needsRemoval() const;
bool needsAddition() const;