Thursday, June 12, 2014

Using non-linear drag forces

I wanted to create a big ivy which could balance itself smoothly when the little girl was passing trough it. The best way, I think, for doing that was to create several segments of ivy. Each segment has a rigid body and a collision box associated to it, in order to deal with collisions with the little girl, and walls.



However, just by doing that the ivy behavior was shaky, even by trying to adjust the weights of each ivy segment to gain some inertial effects that could potentially solve the problem. It didn't help, so I decided to customize the dynamic integration system for the ivy, adding some friction to stabilize the system as mother Nature always does !

So I have just re-implemented the integrate function of each segment of the ivy, sharing the following gd script

You may realize that I didn't used linear drag forces, but non-linear, ie proportional to the norm of the velocity vector. This allows to stop fast motions faster than slow motions. You could even think of adjusting the friction parameter according to the velocity magnitude (for instance piecewise constant), but it's too many non-linearities for me today.

And here is the result...




1 comment: