I'm trying to implement a "passable" flag where a static object can switch between being impassable (i.e. rigid body with mass = 0) and passable (a so-called GhostObject?)
I'd like the same collision shape to be used for both, the only difference in operation is whether one is "solid" or not. Also, they should both report collisions though obviously in the case of a ghost there should be no response. Is there an easier way to do this than removing the btCollisionBody and re-creating as the other type, similar to this psuedocode:
Code: Select all
Object::setPassable(bool enable)
{
if(enable && isGhost()) { //Changing from ghost -> passable
delete collision object;
collision object = new ghost object using old shape;
} else if(!enable && !isGhost()) //Changing from passable -> ghost
{
delete collision object;
collision object = new rigid body using old shape;
}
}
Also, it is my understanding (from reading the source) that any objects created by the user are not freed by Bullet (e.g. the shape), does this apply to all parts of the API?