Hi all,
I posted here a few weeks ago to get some pointers on my SAT collision detection implementation. The help I got was great, so I thought I'd pester this forum again with another question:
Best ways to handle 3D collision resolution? If anyone has any resources on the topic, I'd love to see them. I have looked over a few so far but sometimes I feel like I'm reading another language when looking into this topic. Having done some preliminary research, sequential impulses seems to be the way to go but I'm having trouble understanding it. The mathematics has me confused straight away.
Looking at Erin Catto's GDC slides on the subject it seems I need to calculate a normal impulse first to resolve penetration. I'm going to highlight my process so far cause I do not feel I have interpreted the calculations correctly, and hopefully I can get some pointers on where things may be going wrong.
First I calculate a relative velocity between the two objects:
relV = v2 + w2 x r2 - v1 - w1 x r1 (where v is the linear velocity, w is the angular velocity, and r is the contact point relative to the center of mass)
Then I need to compute that along the normal:
vn = relV . n (where n is the contact normal)
Then I need to calculate k:
kn = invM1 + invM2 + [invI1(r1 x n) x r1 + invI2(r2 x n) x r2] . n (where invM is the inverse mass and invI is the inverse inertia in world space)
Combining these calculations I get a normal impulse:
Pn = max(-vn / kn, 0)
Then I can get the magnitude of my normal impulse by multiplying with the contact normal:
P = Pn * n
This can be added/subtracted to my linear velocities by multiplying it against the inverse mass of the object:
linearVel += P * invM
And to the angular velocities by transforming the relative contact point
angularVel += invI(r x P)
The resulting velocities should be adjusted by a basic normal impulse to counteract any penetrations occurring between the colliding objects (not yet dealing with velocity correction), but currently I don't seem to be getting any impulse (Pn = 0). Maybe that's just the case since I haven't added any bias impulses yet?