From Compliant to Rigid Contact Simulation: a Unified and Efficient Approach