Using Bullet physics engine to find the moment of object contact before penetration
Posted
by
MooMoo
on Game Development
See other posts from Game Development
or by MooMoo
Published on 2014-05-30T05:12:19Z
Indexed on
2014/05/30
9:39 UTC
Read the original article
Hit count: 200
I would like to use Bullet Physics engine to simulate the objects in 3D world.
One of the objects in the world will move using the position from 3D mouse control. I will call it "Mouse Object" and any object in the world as "Object A"
I define the time before "mouse object" and "Object A" collide as t-1 The time "mouse object" penetrate "Object A" as t
Now there is a problem about rendering the scene because when I move the mouse very fast, "Mouse object" will reside in "Object A" before "Object A" start to move. I would like the "Mouse Object" to stop right away attach to the "Object A". Also If the "Object A" move, the "Mouse object" should move following (attach) the "Object A" without stop at the first collision take place.
This is what i did
I find the position of the "Mouse Object" at time t-1 and time t. I will name it as pos(t-1) and pos(t)
The contact time will be sometime between t-1 to t, which the time of contact I name it as t_contact, therefore the contact position (without penetration) between "Mouse object" and "Object A" will be pos(t_contact)
then I create multiple "Mouse object"s using this equation
pos[n] = pos(t-1) * C * ( pos(t) - pos(t-1) ) where 0 <= C <= 1
if I choose C = 0.1, 0.2, 0.3,0.4..... 1.0, I will get pos[n] for 10 values Then I test collision for all of these 10 "Mouse Objects" and choose the one that seperate between "no collision" and "collision".
I feel this method is super non-efficient. I am not sure the way other people find the time-of-contact or the position-of-contact when "Object A" can move.
© Game Development or respective owner