request for air friction feature

Hi
I'm trying to simulate a hanging rope using several small box segments attached with joints. I have used the Pendulum.h sample as start base, adding a large mass to the end of the rope, my problem is that the pendulum keeps bounding almost forever. Could a parameter like air friction help to better simulate a hanging rope, which bounces 3 or 4 times, but then keeps vertical?

Thanks in advance
Juan
I found the b2BodyDef::linearDamping is what I was looking for.

Juan
Be careful, the Box2D solver doesn't do very well when light objects support heavy objects. A ratio of more than 10:1 will require a smaller time step and/or more iterations.
I noticed that the velocity damping step implicitly assumes a fixed time step:
Code:
b->m_linearVelocity *= b->m_linearDamping;
b->m_angularVelocity *= b->m_angularDamping;


If the simulation rate changes for any reason, the strength of the damping will change proportionally. To make the calculation insensitive to time step, eliminate the one-minus-value preprocessing and do this:
Code:
b->m_linearVelocity *= b2Clamp(1.0f - step->dt * b->m_linearDamping, 0.0f, 1.0f);
b->m_angularVelocity *= b2Clamp(1.0f - step->dt * b->m_angularDamping, 0.0f, 1.0f);


The damping values will need to be multiplied by a factor proportional to the (fixed) simulation rate to get the same effect, and the calculation is somewhat more costly than before, but damping strength no longer varies with frame rate. Hurrah! 😀

This is a linear approximation of an exponential decay, and works fine so long as dt * damping is small, but starts to break down as the value increases (whether large time step or large damping). At that point, it needs to be replaced with the function it's emulating: expf(-dt * damping). At some values of damping, the calculation becomes sensitive to fluctuations in the simulation step, and causes visible "jittering".
Thanks for the tip. I've didn't use that formula for damping because there are other aspects of the engine that don't support variable time steps --- namely warm starting. I haven't decided if I should support variable time steps or not, because I want to encourage people to use fixed time steps to make the simulation deterministic.
It's good to add support for it if possible. That said, however, I just switched over my game to a fixed simulation rate with interpolation for rendering. It survived simulation rates as low as 15Hz with no visible simulation artifacts, which was somewhat unexpected given how fast many objects move (like bullets). It helps that the game lacks gravity, so it never generates a bunch of resting contacts.

Original thread: https://box2d.org/forum/viewtopic.php?t=88