If you want to control what happens next after the contact, you need to customize your contact callbacks. There is already a tutorial on bullet wiki:
http://bulletphysics.org/mediawiki-1.5. ... d_Triggers
I will only talk about what it does not cover:
Many people would find that the DestroyedCallbacks cannot be called, but the AddedContactCallbacks can be. So check this post:
http://bulletphysics.org/Bullet/phpBB3/ ... f=9&t=2243
Please Follow what Bbilz said in the post to reproduce this "fancy"
The trick lies in userPersistentData, this pointer shouldn't be NULL, so you need to specify a value for it. And pay attention that it is a mutable variable. So set a value as you like:
Code: Select all
int gGlobalValue = 42;
static bool sContactDestroyedCallback( void* userData ) {
printf( "custom destroyed callback!\n");
btAssert( userPersistentData == &gGlobalValue );
return false;
}
static bool sContactAddedCallback( btManifoldPoint& cp, const btCollisionObject* colObj0,int partId0, int index0,const btCollisionObject* colObj1,int partId1,int index1 ) {
cp.m_userPersistentData = &gGlobalValue;
printf( "custom added callback!\n" );
return false;
}
Even though you make your callbacks working out, and you can control what happens next to collision. The CollisionObject with a custom Contact Callbacks are still possessing the dynamic collision properties as other collision objects, in other words, they are still colliding with each other and bouncing off. You can totally make this original collision disappear by
Code: Select all
Body->setCollisionFlags(mBody->getCollisionFlags() | btCollisionObject::CF_NO_CONTACT_RESPONSE))
Attached is a revised BasicDemo, so replace it with your original BasicDemo.cpp, then it should be able to make.