Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
May 3, 2015, 12:19:49 PM (9 years ago)
Author:
landauf
Message:

added check to detect if a collision shape is destroyed during a simulation step of bullet. this usually happens if a collision (or a 'hit') triggers an event which deletes an object. this yields undefined behavior and often leads to crashes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core7/src/orxonox/collisionshapes/CollisionShape.cc

    r10362 r10415  
    4141#include "CompoundCollisionShape.h"
    4242#include "WorldEntityCollisionShape.h"
     43#include "Scene.h"
    4344
    4445namespace orxonox
     
    7475    {
    7576        // Detach from parent CompoundCollisionShape.
    76         if (this->isInitialized() && this->parent_)
    77             this->parent_->detach(this);
     77        if (this->isInitialized())
     78        {
     79            if (this->getScene() && this->getScene()->isUpdatingPhysics())
     80                orxout(internal_error) << "Don't destroy collision shapes while the physics is updated! This will lead to crashes" << endl;
     81
     82            if (this->parent_)
     83                this->parent_->detach(this);
     84        }
    7885    }
    7986
Note: See TracChangeset for help on using the changeset viewer.