While I am currently trying to handle this kid of issue with physics, where an object (blue) is moving on the ground (green left) and get stopped by an other ground (green right) object on the same level.
But I figured out that the issue persist. My (blue) object still stop around (0,0,0) when moving on the x axis because of the decollision.
Is it supposed to be the normal behavior ? I would have expected the decollision to happen on the whole mesh level, not on a per triangle level.
Edit 1 : This is more easily reproductible by creating a plane with a Physics Shape whose Shape Type is set to mesh
Edit 2 : I observe the same behavior with compound colliders
In continuous collision detection (predictive physics) prediction works on a leaf shape level. This means for collision against mesh you can collide with any of the triangles withing motion range and in case of compound you can collide with any underlying shape within motion range. So colliding against any triangle is expected.
For information, for the moment, we tacled the problem by doing the 2 following steps:
1- We override the normals in the ModifiableContactHeader by the normal of the triangle, instead of the normal of the contact. This leads, for a MeshCollider representing a plane, to all normals pointing in the same direction.
2- As we had issues moving along edges (i.e. MeshCollider representing a cube), we disabled contacts where the contact normal was not going in the same way as the triangle normal.
if (math.dot(manifold.Normal, WorldNormal) < 0.90f) // We only keep alive contacts with triangles whose normal is oriented in the same way as the contact point normal
manifold.JacobianFlags = JacobianFlags.Disabled;
Glad to help. Regarding your step 1 that is the most performant way to deal with most of the welding issues. It works perfectly for flat meshes and for concave sections of the mesh. Once you start hitting convex parts of the mesh “rotating” the normal can result in object initially penetrating new separation plane.
For the step 2 my advise is to use the most specialized collider you can. What I mean by that for your cube you should use BoxCollider. If specialized collider doesn’t exist than you should check the Convex flag on MeshCollider every time you are dealing with the “general” convex body. Mesh Collider with Convex flag checked will provide single contact, no matter how much faces your convex mesh collider has. That way you wouldn’t have to disable any contact and your perf would be better because physics will have less work to do.