Body::setDamping suggestions

bonjovi
Posts: 35
Joined: Mon Jul 20, 2009 12:58 pm

Body::setDamping suggestions

Post by bonjovi »

Hi,

I'm still porting our engine from ODE to Bullet and and i have suggestions from the setDamping functions:

1] it should be great to access linear and angular parts separately. in our case, a thread controls the linear part, a second the angular part and it is not coherent to share the data in order to call the unique void btRigidBody::setDamping(btScalar lin_damping, btScalar ang_damping)

2] the damping code is:

Code: Select all

m_linearVelocity *= btPow(btScalar(1)-m_linearDamping, timeStep);
m_angularVelocity *= btPow(btScalar(1)-m_angularDamping, timeStep);
Question: isn't it possible to choose the damping working mode ? in order to have the same behavior than ODE:

Code: Select all

dReal k1 = 1 - b->dampingp.angular_scale;
dReal k2 = 1 - b->dampingp.linear_scale;
b->avel*=k1
b->lvel*=k2
In our case, we adjust the angular damping according to a lot of events and then apply new values at each time step.

What do you think about these suggestions ?

Thanks
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Body::setDamping suggestions

Post by sparkprime »

That changes turns it from being 'proportion of velocity lost per second' to 'proportion of velocity lost per internal tick' which is a different and less reliable behaviour. In fact the current behaviour even is not perfect because it assumes a constant velocity

If you have specific damping needs you can always apply the damping yourself using an impulse every internal tick. This way you don't have to change the damping all the time. We do this in our project for more advanced damping models needed e.g. for aircraft and high velocity vehicles.

The main utility for bullet's internal damping is I think to help you keep the velocity of an object down, to prevent tunneling and such. For actually simulating real damping you need some custom model depending on your shape and your needs.
bonjovi
Posts: 35
Joined: Mon Jul 20, 2009 12:58 pm

Re: Body::setDamping suggestions

Post by bonjovi »

Thank you for your reply,

The problem is that appling forces/torques (impulses) at every time step seems to introduce instabilities in constraints.

Also, i've tested the fact to add forces/torques at every time step (for creating a virtual spring from 2 bodies) and i did not found any stable relation between SI units and timestep ... i suppose there is some things in low level layers that is working like damping functions 'assuming your action is a qantity that will be taken in account for 1 second'.

(i suppose it by looking at visual results but perhaps i did something wrong !!).

For exemple, a spring with a constant K and a damping KD does not respects the law Force=-Kx-VKD in Bullet (where x is the equilibrium position and V the current speed along an axis).
Applying the Force to body 1 and Body2 as expected by the law make the bodies to move very far (several centimeters) from expected equilibrium point.

So, that's why it should be good to allow user to chose how quantities are working : is it for 'several' time step cutted by pox(x,timestep) ? or is it for only '1' un-depending of time step ? (something that looks like a working mode).

-> for damping
-> for forces

I want to notice that our engine calls Bullet steper for only 1 step about 2 ms.

All i writed assumes i did not miss a basic Bullet programming prerequisite :) otherwise ... to be ignored :)

Thank you.
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Body::setDamping suggestions

Post by sparkprime »

There are time steps, which is the interval between calls to stepSimulation, and then there are internal timesteps which you don't see but can register a callback for. The former will execute enough of the latter to fill the time allocated. If you need stability it's probably best to do your work in internal timesteps. Unless the impulses you are applying are constant (which it doesn't sound like they are).