How can i detect which Objects (ID's) collide in Bullet??

Post Reply
dwells254lb43
Posts: 10
Joined: Wed Jan 21, 2009 12:27 am

How can i detect which Objects (ID's) collide in Bullet??

Post by dwells254lb43 »

Hello i have been using bullet for a decent amount of time now and i am currently wondering how i can detect which Objects / ID's collide. After a collision occured i want something simple to happen like it take damage etc. But i dont know which functions to call in order to check if a collision has occured, and how to manipulate the collided objects.

I have looked into the collision callbacks on : http://www.continuousphysics.com/mediaw ... d_Triggers

But i dont really understand the code to well, if anyone can help me i will appreciate it ^.^
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: How can i detect which Objects (ID's) collide in Bullet??

Post by Erwin Coumans »

The wiki link you provide tells that the best way to check for collisions between objects is
to iterate over all contact manifolds, and check if there are at least 1 contact point.

Have you tried that?
Thanks,
Erwin
dwells254lb43
Posts: 10
Joined: Wed Jan 21, 2009 12:27 am

Re: How can i detect which Objects (ID's) collide in Bullet??

Post by dwells254lb43 »

Yes i understood that it iterated through every object and then when it finds a point of collision it will do the code below, however how do i get the ID's of those bodies? Do i use the void pointer? I noticed there was a void pointer in there and i was thinkin i could set it up to return the Id's of the objects that collide, but i was just wondering is there another way?
thloh85
Posts: 26
Joined: Mon Feb 09, 2009 10:07 am

Re: How can i detect which Objects (ID's) collide in Bullet??

Post by thloh85 »

There is a function called setUserPointer in btRigidBody(or somewhere if it's not there, I couldn't recall) AFAIK, therefore, use setUserPointer with whatever that identifies your body, and getUserPointer to check them.

Hope this helps
Post Reply