Page 1 of 1

Velocity damping

Posted: Sat Jun 15, 2019 2:20 pm
by lidgren
Hi! I'm trying to add a (very heavy) velocity damping to a constrained object; basically it's a door on a hinge and I don't want it to be so well oiled.
I guess it could be achieved by adding and every frame calculate values for a OneBodyLinearMotor; but that seems like a roundabout way to do it. I started creating a VelocityDampingMotor constraint but a lot of the concepts (presteps, projections, warmup) are kind of lost on me.
Are any of these ways a good idea or am I missing a much simpler solution perhaps?
--micahel

Re: Velocity damping

Posted: Sat Jun 15, 2019 5:50 pm
by Norbo
OneBodyAngularMotor with a target velocity of zero sounds like it would do the trick. Notably, the "softness" parameter in MotorSettings is equivalent to the inverse damping constant. For cases where the door is attached to another body and you want the damping forces to correctly propagate, the AngularMotor would serve the same purpose.

If most objects need some form of customizable damping without strong robustness requirements demanding solved constraints, using something like the DemoPoseIntegratorCallbacks that looks up per-body damping values could work too.

Re: Velocity damping

Posted: Mon Jun 17, 2019 12:26 pm
by lidgren
Works like a charm, thanks! General question - is it fair to say that a motor is something that a motor is something that applies force over time until a velocity is reached; and a servo is something that applies force until an absolute value (position/orientation) is reached?

Re: Velocity damping

Posted: Mon Jun 17, 2019 9:55 pm
by Norbo
Yup, that's exactly right.

Notably, the only distinction by convention between a 'normal' constraint like BallSocket (which has a position goal) and a 'servo' is that servo types tend to also have a ServoSettings value that offers more control. Constraints like BallSocket omit that parameter as an optimization given their most frequent use cases.

Re: Velocity damping

Posted: Thu Jun 20, 2019 5:00 pm
by Darkon76
Hi,

So if I have few objects that use velocity damping. Is it better to use an OneBodyLinearMotor for the damping that changing the PoseintegratorCallbacks-IntegrateVelocity?

Re: Velocity damping

Posted: Thu Jun 20, 2019 8:44 pm
by Norbo
Constraints are useful when you want a high level of robustness during interactions with other constraints and collisions. A heavy door with a very rusty hinge that requires a large amount of force to overcome is a good use case, since the hinge's resistance is large enough to meaningfully interact with collisions.

For very light damping, like basic aerodynamic drag simulation that only removes a fraction of momentum per second, the robustness offered by a constraint usually isn't necessary. For performance reasons, you might choose to then use a direct velocity modification (like a pose integrator damping implementation).

If very few objects have damping applied, then it doesn't make as much sense to use the pose integrator since it touches every single active body. It would be faster to directly modify the velocity of the handful of objects instead.