Jump to content
  • Advertisement
Sign in to follow this  
Bow_vernon

Problem implementing soft collision contact (and impulse based spring)

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement

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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!