in the dynamics rigid bodies a contact is defined but two parameters that can be consider
input to the simulations
-the relative contact speed.
-the contact penetration.
they come from the geometry of the problem.
the relative contact speed is used in the empirical law of restitution.
and that is accordance coulomb restitution.
restistionSpeed = -(1 + resCoeffiecnet) * relSpeed
the secund, contact penetration, is handled heuristically because there are not equations in the literature for how to deal with that, but contact penetrations are inevitable.
the way newton deal with that is that is as follows.
there is a penetration ramp. like the graph below.
- Untitled.png (2.59 KiB) Viewed 11492 times
basically, when bodies interpenetrate, the joint add some momentum proportional to the penetration until certain limit. In that sense, conservation of moment is broken for a period of time.
there are some logic that compare the restitution speed and the penetration recovering, and only the max of the two is used. In general, for relatively high speed, this works really well because the restitution is larger than the penetration speed.
the problems happens when you get contacts that move a low speed, but they generate penetration, in this case the recovering speed is larger and that create jittering problems.
I had that problem when trying to make a self-balancing gait. I could not get the foot to rest stable.
I tried to add an option that instead of using a ramp, it was a step ramp, allowing for the bodies to have some penetration. I called soft contact, maybe not a good name, but that really never worked to my satisfaction.
the problem is that a food in the grown receive force that change very violent, so the contact also reacts with very violent change of momentum.
you can find that code in the Contact joint class.
I abandoned that idea, and in the new version of the engine I am trying a different approach,
the behavior is more stable, but I ran into some other issues that I have with the forward and invers dynamics that I have to resolve first.
to summarize, the concept of softy contacts does not exist in rigid body simulation, and what I tried to do was to dissipate the contact violent changes of momentum but let it the contact penetrated more than the skin thickness of the contact solver, but that did not really work because it actually brings much bigger problems.