Would it make sense to make linearDamping a b2Vec2? I know I personally only want horizontal dampening; by making it a b2Vec2 we could apply horizontal and vertical dampening separately.
Request: linearDamping -> b2Vec2
Bugs, Requests, and FeedbackAs well as having global linear damping, it could be useful to have per-body local linear damping (relative to the body's angle) for top down physics. (Eg. a left/right and forward/back damping or friction setting)
This stuff falls under what I like to call application specific. 🙂
The way to achieve these effects is easy. Either apply forces or scale the velocity.
The way to achieve these effects is easy. Either apply forces or scale the velocity.
I'd still like it if the damping constants were applied as an exponential decay (e.g. velocity *= expf(-damping * timestep)), as that makes damping values independent of time step and tolerant of arbitrarily-large (positive) damping values. I keep having to add that whenever I get a new version of Box2D. 😀
kdmiller3: yeah, I think that will happen.
The main drawback to switching over is that everyone will need to multiply their damping factors by the simulation rate to get the same degree of damping.
Well... I know it's easy to implement, but why bother having at all then? I just figured since it was there, you might as well make it slightly more useful. But anyways, doesn't matter. Only took a few lines of code.
Often people will try to use a force proportional to velocity to achieve damping. However, for large damping coefficients this can lead to integrator instabilities. The way Box2D implements damping does not lead to instabilities. So the reason for implementing it in Box2D is to provide a simple and stable damping facility and also to provide an example of how to achieve stable damping in your own application.
Original thread: https://box2d.org/forum/viewtopic.php?t=295