Sign in to follow this  
santiagopuentep

Rigid body simultaneous point collision solving

Recommended Posts

I am building a rigid body physics engine and I'm having a problem when a polygon collides with a surface generating two simultaneous contact points (two vertex of the same edge in this case). Since my engine calculates the impulse generated by one contact at a time, the bouncing polygon ends up having some angular velocity even if it didn't have any before collision. I will be trying to implementing Eric Catto's iterative collision solver later on but I am curious to know if this problem can be solved with simple math. I just couldn't do it myself. My engine uses Oliii's Polycolly SAT (without the swept collision part), Chris Hecker's rigid body articles and I'm looking at source from different engines like box2D, Chipmunk, Motor2 (actionscript3), Glaze (as3 also) and many others. The game programming community is amazing! Thanks in advance! SP.

Share this post


Link to post
Share on other sites
Why do you not instead apply an impulse at the mid-point? What i do in my own engine aswell, is that if the contact normal is close to the direction of gravity, and the polygon's velocity is under a certain threshold, i project the center of mass of the polygon onto the colliding polygon below when it is an edge collision in the direction of the normal, and use this point to apply an impulse so that no angular velocity is given.

Share this post


Link to post
Share on other sites
Thanks Luca for the fast reply!

The problem is that that is not correct because there would be no change in angular velocity.
Imagine the body is rotating in a way that it makes contact with the floor with a velocity of 2 at point A an a velocity of 0 at point B. This means that the linear and angular velocity at point A add up as v - w*R = 2 (v=1 and w*R=1) and at B is v + w*R = 0 (v=1, w*R=-1). The hole impulse is applied at A with a result of inverting the angular velocity (if restitution = 1) and inverting the linear velocity also. If I apply the impulse at the mid-point the angular velocity won't be inverted.
Maybe something to do with an LCP solver?

I also found that the friction model used in all the physics engines I've seen seems to be incomplete because it doesn't take into account the surface of the contact. A body touching the floor with one edge has the same friction applied to it as when the second vertex is also in contact (forming a surface between both vertex). Any suggestions?

I think the biggest doubt I have is if box2D-like engines ever solve simultaneous contacts or they always solve one at at time (with many iterations per frame).

SP.

Still loving the community!

Share this post


Link to post
Share on other sites
Solving several simultaneous contact points requires solving a linear complementary problem (LCP). You can do this using an iterative or direct solver. The impulse methods you are talking about here are practically iterative projected Gauss-Seidel (PGS) methods. Examples for direct methods are Danzig or Lemke. When using an iterative solver applying sequential impulses you can of course solve several contacts together as a block using some direct method for the "mini" sub LCP. So as instead of solving each contact point individually you now solve several contact points together assuming that this sub problem is actually always solvable. Erin does this in Box2D by solving two contact points between two shapes using a direct enumeration approach. This makes perfect sense in 2D since you now iteratively solve full contacts instead of individual contact points and e.g. don't add angular velocities into the system for some specific configurations as you noticed correctly. This helps a bit with stability. Erin also solves e.g. revolute joints together with a limit which is another example for this block solving approach.

In 3D things are not so obvious. Here you need to solve 4 contact points together which is already computational very expensive. Some people suggest solving diagonal contact points together, but this can lead to friction artifacts. In 3D I basically suggest only solving the spherical joints as a 3x3 linear system. This can be done efficiently. You can also solve the angular 3x3 block in a prismatic joint as a block. This actually helps with the stability of this joint.

Iterative methods are basically used in all major physic engines. There are different strategies to improve convergence, but the general idea of locally solving one constraint (contact) after each other in several iterations is everywhere the same. The devil is in the detail, like constraint formulation, drift stabilization, dealing with extreme stretching etc. So I suggest studying Box2D if you are interested in the topic. It is a great place to learn and full of gems.

HTH,
-Dirk

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this