Way for reusing bullets collision lib for different purpose?

Post Reply
Narutachi
Posts: 5
Joined: Tue Nov 24, 2009 3:58 pm

Way for reusing bullets collision lib for different purpose?

Post by Narutachi »

Hi,
i am currently working on a simulation of a rotating can with one ball in it. The can is build from box shapes using a compound shape. I need to register the moment of the ball leaving the can. My question is: Does somebody has any idea of how to reuse bullets collision lib in order to tell when the ball leaves the can?
I thought of using a box B having the same size of the can whose orientation/motionstate is set to the can's orientation/motionstate for each time step. Then maybe using collision detection between the box B and the ball to detect if no collision is triggered, concluding that the ball has left the can. Would this be possible?

Thanks for helping me.
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Way for reusing bullets collision lib for different purpose?

Post by mako90 »

Hi,
hope, this is going to help you: http://bulletphysics.org/mediawiki-1.5. ... d_Triggers
Narutachi
Posts: 5
Joined: Tue Nov 24, 2009 3:58 pm

Re: Way for reusing bullets collision lib for different purpose?

Post by Narutachi »

Thanks mako90,
i already know the link but what i am really after is an advise from someone how to solve the problem with bullets collision library or if it's even possible to solve it with the collision lib. Do you think that my suggested solution can work?
mako90
Posts: 28
Joined: Tue Jan 05, 2010 12:41 pm

Re: Way for reusing bullets collision lib for different purpose?

Post by mako90 »

Hi,
I thought that
<pre>gContactDestroyedCallback

This is called immediately after the contact point is destroyed.

typedef bool (*ContactDestroyedCallback)(
void* userPersistentData);</pre>
is the solition. If I'm correct, this is the function called when the collision is destroyed. Does the ball touches the can?
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA
Contact:

Re: Way for reusing bullets collision lib for different purpose?

Post by Erwin Coumans »

when the ball leaves the can
What is your definition of 'leaves the can'? Is the ball leaving the can if it has no contacts (but it can be inside)? Or do you want to measure if the ball is still overlapping with convex hull of the can? If so, you can use a convex hull shape and perform collision detection with that.

Thanks,
Erwin
Narutachi
Posts: 5
Joined: Tue Nov 24, 2009 3:58 pm

Re: Way for reusing bullets collision lib for different purpose?

Post by Narutachi »

Thanks Erwin,
yes i want to measure if the ball is still overlapping with the convex hull of the can. Can i use two collision shapes for one and the same rigid body, one for real collision detection and one for only detecting if the ball is completely outside the can? If yes can you give me some example or any link?


Thanks,
Thomas
Post Reply