There are roughly 2 different ways you can tackle the contact manifold generation: incrementally, or at once.
Basically you need a couple of things:
every collision step:
1) calculate a new closest point (vclip, or other algo like gjk)
2) check if this point is already in the contact cache.
2a) If you keep track of feature-id's, you can do this very efficient.y.
2b) Otherwise use the worldspace distance to check for equality (with a treshold).
3a) if the point exists do nothing
3b) if it is a new point, add it to the contact cache. preferably in local coordinates of both rigidbodies/shapes.
4) if the contact cache exceed some upper size, reduce.
4a) keep the point with the deepest penetration
4b) build some kind of heuristic to choose the points that approximate the 2d convex hull best.
5) after each integration, refresh the contact cache:
5a) calculate 2 new worldspace coordinates for each contact point, using the local coordinates in body A and body B, and the new transforms of each body.
5b) check if the contact is still valid, similar to using (2b).
You can see the sample implementation here:
http://www.continuousphysics.com/Bullet ... ource.html
There is some extra heuristic for step 4b and 5b in this implementation.
4b: quick appriximation by using triangle with biggest area
5b) take the projection onto the normal into account, so even when the distance between the two projections into worldspace exceed the maximum distance treshold, you keep it. This will allow to keep points that cause deeper penetrations. They still break on motion in the contact plane, orthogonal to the normal.
There is also a paper by Adam and Pierre from Novodex with some variations on this theme:
http://www.continuousphysics.com/ftp/pu ... draft9.doc
For 'at once', which only works if you got feature information like planes, vertices, edges (not for implicit shapes like sphere, cylinders etc).
I won't explain too much about this case. ODE uses this for box-box for example, but you can generalize this for convex-convex polyhedra.
You can find the two polygons that share the closest point, and that are most parallel (some heuristic here). Then clip all triangles from one polyhedron on this plane, and on the other polygons edges.