Page MenuHome

Make rigidbody simulation handle animated objects gracefully
ClosedPublic

Authored by Sebastian Parborg (zeddb) on Aug 31 2020, 5:06 PM.

Details

Summary

The animated objects was not updated for each internal substep for the rigidbody sim.

This would lead to unstable simulations or very annoying clipping artifacts.

I've updated the code to use explicit substeps and tie it to the scene frame rate.
(This is how it is done in the cloth sim for example)

We would also have issues with the simulated objects becoming "magnetic" and sticking together with other general simulation stability issues.

This was solved by updating the bullet library to the latest version and switching to double precision.

I've created pull a pull request for the custom bullet code that we had. So hopefully we can soon build blender with a upstream release.
https://github.com/bulletphysics/bullet3/pull/3018

This fixes: https://developer.blender.org/T47402

Diff Detail

Event Timeline

Sebastian Parborg (zeddb) requested review of this revision.Aug 31 2020, 5:06 PM
Sebastian Parborg (zeddb) created this revision.

Please make separate code reviews for the Bullet upgrade and Blender changes.

release/scripts/startup/bl_ui/properties_scene.py
388–389

This API change should be mentioned in the commit and release notes.

source/blender/blenkernel/intern/rigidbody.c
2217–2218

probably outdated comment

source/blender/blenloader/intern/versioning_290.c
532

Why not use /=?

source/blender/bmesh/operators/bmo_hull.c
31

Should the folder be in the include dirs?

Removed bullet upgrade.

Sebastian Parborg (zeddb) marked 2 inline comments as done.
Sebastian Parborg (zeddb) marked an inline comment as done.
release/scripts/startup/bl_ui/properties_scene.py
388–389

Right, I'll should only do that after this patch has been accepted though?

Jacques Lucke (JacquesLucke) added inline comments.
source/blender/blenkernel/intern/rigidbody.c
1936

LISTBASE_FOREACH

1938

snake case

2220

const

This revision is now accepted and ready to land.Sep 1 2020, 2:57 PM
source/blender/blenkernel/intern/rigidbody.c
1887–1890

Is there a reason scale is not interpolated for substeps, while position and rotation are?

Sebastian Parborg (zeddb) marked 3 inline comments as done.
Sebastian Parborg (zeddb) marked an inline comment as done.

Now also taking into account scale changes with additional checks to avoid recalculating collision shapes when scale doesn't change.

Updated the scale changed check to be a bit fuzzy so that we don't update the scale because of floating point precision issues.

source/blender/blenkernel/intern/rigidbody.c
1682–1684

Reminder: Only do this check at this point for non kinematic objects!

source/blender/blenlib/intern/math_vector_inline.c
1378 ↗(On Diff #28437)

Don't use an assert, make the code work for zero size:

for (int i = 0; i < 3; i++) {
  if (v2[i] == 0.0f) {
    if (v1[i] != v2[i]) {
      return false;
    }
  }
  else {
    if (fabsf(v1[i] / v2[i] - 1.0f) > limit) {
      return false;
    }
  }
}
Sebastian Parborg (zeddb) marked an inline comment as done.