mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 18:42:58 +02:00
Merge pull request #4532 from AndrewMeadows/inertia
fix crash in PhysicsEngine on shutdown
This commit is contained in:
commit
f116ac131d
3 changed files with 17 additions and 1 deletions
|
@ -608,6 +608,7 @@ Application::~Application() {
|
||||||
|
|
||||||
Menu::getInstance()->deleteLater();
|
Menu::getInstance()->deleteLater();
|
||||||
|
|
||||||
|
_physicsEngine.setCharacterController(NULL);
|
||||||
_myAvatar = NULL;
|
_myAvatar = NULL;
|
||||||
|
|
||||||
ModelEntityItem::cleanupLoadedAnimations();
|
ModelEntityItem::cleanupLoadedAnimations();
|
||||||
|
|
|
@ -241,6 +241,12 @@ CharacterController::CharacterController(AvatarData* avatarData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CharacterController::~CharacterController() {
|
CharacterController::~CharacterController() {
|
||||||
|
delete _ghostObject;
|
||||||
|
_ghostObject = NULL;
|
||||||
|
delete _convexShape;
|
||||||
|
_convexShape = NULL;
|
||||||
|
// make sure you remove this Character from its DynamicsWorld before reaching this spot
|
||||||
|
assert(_dynamicsWorld == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
btPairCachingGhostObject* CharacterController::getGhostObject() {
|
btPairCachingGhostObject* CharacterController::getGhostObject() {
|
||||||
|
|
|
@ -28,6 +28,9 @@ PhysicsEngine::PhysicsEngine(const glm::vec3& offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
PhysicsEngine::~PhysicsEngine() {
|
PhysicsEngine::~PhysicsEngine() {
|
||||||
|
if (_characterController) {
|
||||||
|
_characterController->setDynamicsWorld(NULL);
|
||||||
|
}
|
||||||
// TODO: delete engine components... if we ever plan to create more than one instance
|
// TODO: delete engine components... if we ever plan to create more than one instance
|
||||||
delete _collisionConfig;
|
delete _collisionConfig;
|
||||||
delete _collisionDispatcher;
|
delete _collisionDispatcher;
|
||||||
|
@ -614,8 +617,14 @@ bool PhysicsEngine::updateObjectHard(btRigidBody* body, ObjectMotionState* motio
|
||||||
}
|
}
|
||||||
|
|
||||||
void PhysicsEngine::setCharacterController(CharacterController* character) {
|
void PhysicsEngine::setCharacterController(CharacterController* character) {
|
||||||
if (!_characterController) {
|
if (_characterController != character) {
|
||||||
lock();
|
lock();
|
||||||
|
if (_characterController) {
|
||||||
|
// remove the character from the DynamicsWorld immediately
|
||||||
|
_characterController->setDynamicsWorld(NULL);
|
||||||
|
_characterController = NULL;
|
||||||
|
}
|
||||||
|
// the character will be added to the DynamicsWorld later
|
||||||
_characterController = character;
|
_characterController = character;
|
||||||
unlock();
|
unlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue