Merge pull request #7681 from hyperlogic/tony/character-controller-leak-fix

Memory leak on exit for CharacterController
This commit is contained in:
Brad Hefta-Gaub 2016-04-19 07:51:08 -07:00
commit d16750c590
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;