Page MenuHome

Move rigidbody update into substep loop for force calculations.
ClosedPublic

Authored by Lukas Tönne (lukastoenne) on Jun 11 2022, 12:11 PM.

Details

Summary

Fixes T98272

The substep loop for rigid bodies causes unequal effects of force fields depedending on the substep setting, larger
substep counts cause a diminishing effect of force fields.
This is because the force to apply on a body is reset in Bullet after each step and needs to be recomputed. Without this
the body will just coast with constant velocity after the first substep. Since the per-step impulse with larger substep
counts is smaller, the effect is that more substeps cause a smaller total impulse.

The fix is to move the rigidbody_update_simulation call into the substep loop and compute forces for each substep.

Note that this may be considered a breaking change, because the breaking commit rB1aa54d4921c2 has been in master for
a long time and after this fix force fields will generally have a much larger effect on rigid bodies (10x for the
default setting of 10 substeps).

Diff Detail

Repository
rB Blender
Branch
fix_t98272 (branched from master)
Build Status
Buildable 22593
Build 22593: arc lint + arc unit

Event Timeline

Lukas Tönne (lukastoenne) requested review of this revision.Jun 11 2022, 12:11 PM
Lukas Tönne (lukastoenne) created this revision.

This change seems a bit heavy handed to me.

By moving rigidbody_update_simulation into the sub step loop, we are now validating the constraints and updating collision shapes of all objects on every substep.
So a lot of things besides the intended effector update is updated on each substep now.
I don't think much of that data changes either, so this leads to a lot of unnecessary updates.

Wouldn't it be better to create a new function with the effector specific logic from rigidbody_update_sim_ob and state that forces not inherent to the rigid body simulation need to be re applied on each sub step?

Yes this was hasty fix, thanks. I'll look into splitting this up.

More efficient substep updates only including external force calculation.

I was considering a versioning fix that scales down existing forces to compensate for the increased "effective strength" and avoid breaking existing setups. But effectors are used in other simulations too of course where forces were not affected by substeps, so trying to adjust user data like that would probably do more harm than good.

This revision is now accepted and ready to land.Jun 20 2022, 3:07 PM