The difference that causes the incompatibility is the const qualifier of const btCollisionObject*
.
I never tried to remove objects during collision or whatever dispatching and I doubt, that it will work flawlessly.
Since you're doing manual contact tests, you could try to remove the collision object using the const_cast
operator: bullet->bt_dynamicsWorld->removeCollisionObject(const_cast<btCollisionObject*>(colObj0Wrap->getCollisionObject()));
but again, enforcing that might not work properly now, or after changes to the simulation steps.
Instead, I would collect the 'dead' zombies via ContactResultCallback
in another container defeatedZombies
for deferred removal from bt_dynamicsWorld
and zombies
(at the end of a simulation step, or your nested loops, respectively).