Convert bullet physics damping values correctly for havok

credit

Model: YYB Hatsune Miku_10th

Motion: 【MMD刀剣乱舞】ピチカートドロップス【モーション配布】 再アップ固定 - ニコニコ動画

Hi, I loaded the rigid body joint parameters from a software using bullet physics and checked the results.

I ask because there is a big difference from the original program.

This is the original physics. recorded the MMD.

And this is what I implemented in babylon.js using havok physics(Pay attention to the movement of her hair).

This is the result of multiplying the linear damping by 10. It matched the original fairly well.

My question is, exactly what calculation do I need to do to convert the damping parameters in bullet physics to the correct damping values in havok physics?

Here is the code for two existing implementations that use bullet physics for my question.

Implementation using C++ and bullet physics:
https://github.com/benikabocha/saba/blob/master/src/Saba/Model/MMD/MMDPhysics.cpp#L600-L620

Implementation using javascript and ammo.js:
https://github.com/mrdoob/three.js/blob/dev/examples/jsm/animation/MMDPhysics.js#L910-L961

And this is the code I’m currently implementing.

https://github.com/noname0310/babylon-mmd/blob/main/src/Runtime/mmdPhysics.ts#L363-L399

1 Like

maybe @eoin would know ? or I am afraid you may need to wait for @Cedric or @carolhmj return from vacations

1 Like

So, not a Bullet expert, but it looks like Bullet uses:

(1 - damping)^timestep

While Havok uses:

1 - (damping * timestep)

It’s timestep dependent, obviously, so you’d need to recompute it every frame if you wanted it to match perfectly. Because of differences in the solvers, though, I don’t think you’re ever going to get both systems to match perfectly, so probably good enough to use a constant timestep?

4 Likes

@eoin
I wrote an expression based on what you said. Is this what you meant?

const timeStep = 1 / 60;
body.setLinearDamping((1 - (1 - rigidBody.linearDamping) ** timeStep) / timeStep);
body.setAngularDamping((1 - (1 - rigidBody.angularDamping) ** timeStep) / timeStep);

And one more question, does this also apply to the stiffness and damping of the constraint?