Question about damping

BLK Dragon
Posts: 8
Joined: Fri Sep 03, 2010 9:03 am

Question about damping

Post by BLK Dragon »

According to docs/code, damping in Bullet is value in range 0-1 which means fraction of velocity lost per second.

Since value of damping can't be higher that 1, that means it takes at least one second for rigid-body to stop (with no any forces/torques applied).

But what if I need to stop rigid-body faster?
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Question about damping

Post by Dr.Shepherd »

apply the force/torque backwards? or more straightforward setLinearVelocity/setAngularVelocity ?

This is the simplest way I can come up with.

Cheers
BLK Dragon
Posts: 8
Joined: Fri Sep 03, 2010 9:03 am

Re: Question about damping

Post by BLK Dragon »

Dr.Shepherd wrote:apply the force/torque backwards? or more straightforward setLinearVelocity/setAngularVelocity ?
Well, applying additional force/torque may cause movement in opposite direction, and tweaking that will be a bit complicated (compared to tweaking single number of damping).

What I really need is ability to specify damping as "time amount needed for rigid-body to stop motion completely (in absence of applied forces/torques)", it's more intuitive IMO. Looks like I just have to implement such version of damping.
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Question about damping

Post by dphil »

If you don't take an object's current velocity into account, how would you produce an intuitive result? Ie stating that an object should come to rest after 1 second, regardless of whether it's traveling 0.1m/s or 10000m/s, doesn't seem like it would give an intuitive result. But obviously if you do need something like this for your own purposes anyway, then you can of course implement it.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Question about damping

Post by Dr.Shepherd »

Yeah, setting the velocity directly to 0 would result in a sudden stop. I don't know if there is existing methods to stop it continuously to zero.

Force and torque is a bit tricky, I guess, perhaps we should develop some function to do this continuous stop.
BLK Dragon
Posts: 8
Joined: Fri Sep 03, 2010 9:03 am

Re: Question about damping

Post by BLK Dragon »

dphil wrote:If you don't take an object's current velocity into account, how would you produce an intuitive result? Ie stating that an object should come to rest after 1 second, regardless of whether it's traveling 0.1m/s or 10000m/s, doesn't seem like it would give an intuitive result. But obviously if you do need something like this for your own purposes anyway, then you can of course implement it.
Well, I won't argue that my 'definition' of damping is more intuitive (or it's even need to work that way).
I just need (in certain cases) linear/angular velocity to be damped 'harder' than it does with damping set to 0.999 in current Bullet implementation.

for example doing

Code: Select all

    
m_angularVelocity *= k * btPow(btScalar(1)-m_angularDamping, timeStep);
in btRigidBody::applyDamping (with k hardcoded to 0.2 for quick-test) gives exactly what I want -- with large enough torque movement starts fast and stops fast;
Perhaps I should just add some 'extra-damping-scale' parameter to my rigid-body and set it to 1.0f by default.
User avatar
Dr.Shepherd
Posts: 168
Joined: Tue Jan 04, 2011 11:47 pm

Re: Question about damping

Post by Dr.Shepherd »

BLK Dragon wrote:
dphil wrote:If you don't take an object's current velocity into account, how would you produce an intuitive result? Ie stating that an object should come to rest after 1 second, regardless of whether it's traveling 0.1m/s or 10000m/s, doesn't seem like it would give an intuitive result. But obviously if you do need something like this for your own purposes anyway, then you can of course implement it.
Well, I won't argue that my 'definition' of damping is more intuitive (or it's even need to work that way).
I just need (in certain cases) linear/angular velocity to be damped 'harder' than it does with damping set to 0.999 in current Bullet implementation.

for example doing

Code: Select all

    
m_angularVelocity *= k * btPow(btScalar(1)-m_angularDamping, timeStep);
in btRigidBody::applyDamping (with k hardcoded to 0.2 for quick-test) gives exactly what I want -- with large enough torque movement starts fast and stops fast;
Perhaps I should just add some 'extra-damping-scale' parameter to my rigid-body and set it to 1.0f by default.
Yes, that's a simple solution to re-implement the damping method. Straightforward and efficient !