# Problem implementing soft collision contact (and impulse based spring)

This topic is 675 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi people, so I'm trying to implement the impulse based spring (soft constraint in general). I read erin paper, where it talks about CFM (constraint force mixing) and ERP (error reduction parameter). I just cannot make sense out of it. I tried looking at the Box 2D source code, to no avail. Can anyone give some explanation? basically when solving for impulse P, the equation is divided into two parts, I call them the velocity solver part and the position error projection part. For example, here's how the collision impulse is calculated in my engine (inelastic collision):

impulseNormal = (-velocity . contactNormal + posError) * massNormal;

// velocity is velocity at contact point
// contactNormal is normal vector

// posError is the bias term (the penetration depth adjusted with small slop)
// massNormal is the effective mass along the normalDirection at contact point
// I call the (-velocity . contactNormal) the velocity solver part, and
// posError the position error projection part


Now my goal is to make the collision resolution "spongy" or soft. Basically in general I wanna make my engine capable of simulating soft constraint. But I just cannot fathom how the CFM and ERP affect the impulse calculation. Perhaps there's some good books that explain this in an easier way? perhaps a naked/stripped down implementation that I can take a look at? sorry if this is too much to asks. I've been losing sleeping over this things.

##### Share on other sites

Check the Box2D mouse joint for an example to compute ERP and CFM values. A good start is a frequency of 5.0 and damping ratio of 0.7

Then, when you have these values you need to add the CFM to your impulse mass and the delta impulse must account for the CFM as well like this:

SetupConstraints:

- Compute CFM/ERP

- impulseNormal += CFM;

SolveConstraint:

- impulseNormal = (-velocity . contactNormal + posError - CFM * accumulatedImpulse ) * massNormal;

Edited by Dirk Gregorius

1. 1
2. 2
Rutin
19
3. 3
khawk
18
4. 4
5. 5
A4L
11

• 9
• 12
• 16
• 26
• 10
• ### Forum Statistics

• Total Topics
633769
• Total Posts
3013755
×