I have a setup like this for collision detection:
struct ZombieBulletCallback : public btCollisionWorld::ContactResultCallback
{
ZombieBulletCallback(BulletStuff* ptr) : bullet(ptr) {}
btScalar addSingleResult(btManifoldPoint& cp,
const btCollisionObjectWrapper* colObj0Wrap,
int partId0,
int index0,
const btCollisionObjectWrapper* colObj1Wrap,
int partId1,
int index1)
{
// your callback code here
char strr[256];
sprintf_s(strr, "zombie-bullet collision \n");
OutputDebugString(strr);
// increment points
bullet->currentPoints += 10;
// increase the kill counter
bullet->killCounter += 1;
// TODO remove bodies
return 1.f;
}
BulletStuff* bullet;
};
ZombieBulletCallback zombieBulletCollision(this);
for (int i = 0; i < zombies.size(); i++) {
for (int j = 0; j < bullets.size(); j++) {
bt_dynamicsWorld->contactPairTest(zombies[i], bullets[j], zombieBulletCollision);
}
}
I want to remove the bodies after the collision is detected.
The struct has access to colObj0Wrap and colObj1Wrap (type const btCollisionObjectWrapper*) which, I assume, are the 2 bodies that collide. I have tried this:
bullet->bt_dynamicsWorld->removeCollisionObject(colObj0Wrap->getCollisionObject());
but this gives an error: argument of type const btCollisionObject* is incompatible with param of type btCollisionObject*
How do I remove those 2 bodies from the world?