Page 1 of 1

How to detect that which collider in collide...

Posted: Thu Nov 24, 2011 5:39 am
by sankalp
Hiii....
I am new in bullet physics. My project have a vehicle which collide with different colliders.
Is there any way to find out that vehicle is striking with which colliders for example colliding with road or colliding with side walls etc..

so please tell me how i find out that specific collider in bullet....

Thanks in advance..

Re: How to detect that which collider in collide...

Posted: Thu Nov 24, 2011 5:40 am
by majestik666
do a search for contacts callback on the forum
this has been answered many times before :)

Re: How to detect that which collider in collide...

Posted: Thu Nov 24, 2011 7:21 am
by sankalp
Thanks for reply ...
i already use contact call back method but it gives only information that body of car is hit with collider...either it side collider or road collider...

i want to optimize it that it gives information when it hits with only side collider not when it hits with road or other collider...
Hope you understand my problem well...

Re: How to detect that which collider in collide...

Posted: Thu Nov 24, 2011 10:39 am
by Dr.Shepherd

Code: Select all

btCollisionObject* obA = static_cast<btCollisionObject*>(contactManifold->getBody0());
btCollisionObject* obB = static_cast<btCollisionObject*>(contactManifold->getBody1());
What I do is to check which object it is.

I suppose "Custom collision filtering" is another possible solution, but I didn't try it out. Anyone explains it here ?

Re: How to detect that which collider in collide...

Posted: Thu Nov 24, 2011 8:22 pm
by majestik666
you could also use the collision mask/group (can't remember the exact name)
and use it to determine what object the collider is.
Or you can also attach a name to the rigid body and check the name...

Re: How to detect that which collider in collide...

Posted: Fri Nov 25, 2011 12:28 pm
by sankalp
Thanks for reply.....
i assign user pointer to 2 bodies and check their collision in contactcall-back function with help of their user pointer...
this method solve my problem.....
is this proper method or not..???