I am rephrasing a previous question here in the hope of a response:
I am colliding a box with the 'floor' (inverseMass = 0) and am trying to get my collision response right. Currently I calculate the impulse for each contact, and apply it to that contact. The calculation for the impulse uses the standard forumula :
n is the contactNormal;
iitw is the inverseInertiaTensor in world coordinates of the box
r = relative position of contact point w.r.t centre of mass i.e (contactPoint - position of centre of mass)
e = restitution
numerator = -(1+e)relativeVelocity.Dot(n)
denominator = (n.Dot(n) * inverseMass) + ((iitw*r.Cross(n)).Cross(r)).Dot(n)
impulse = numerator/denominator;
I find that this works when the box is a cube (length = breadth = height ) and bouncing with its base parallel to the floor. If all dimensions are not equal - or the box is tilted a bit it is wrong.
Could somebody point out what I am doing wrong?
multiple contacts for a box hitting the ground
-
- Posts: 861
- Joined: Sun Jul 03, 2005 4:06 pm
- Location: Kirkland, WA
Re: multiple contacts for a box hitting the ground
Contacts are unilateral, that means they are only active if you have an approaching relative normal velocity at a contact point. You can just skip contact points with a separating relative normal velocity, what will work, but lead to jitter artifacts. A better approach is to clamp against an accumulated impulse. Using you notation below you would do:
last_impulse = accumulated_impulse;
accumulated_impulse= max( last_impulse + impulse, 0 );
impulse = accumulated_impulse - impulse;
So for each contact point you have an accumulated_impulse which you initialize to zero each frame.
last_impulse = accumulated_impulse;
accumulated_impulse= max( last_impulse + impulse, 0 );
impulse = accumulated_impulse - impulse;
So for each contact point you have an accumulated_impulse which you initialize to zero each frame.