Page MenuHome

Fixed rigidbodies with effectors not being simulated as rigidbodies
Needs ReviewPublic

Authored by Ben Crulis (BenCrulis) on Tue, Jun 16, 8:45 PM.

Details

Summary

This patch fix a bug where a rigidbody being also an effector is not updated as other rigidbodies. The UI allows to set both rigidbodies and effectors, so this fix should cause the simulated objects to behave as expected.

Another update loop has to be created in order to avoid simulation instabilities due to rigidbody positions being updated in the same loop as the force computation of effectors in the previous code.

Here is a simulation of rigidbodies that won't move before applying the patch:

Here is a video recorded with the patch: https://www.youtube.com/watch?v=1t2aVjuIURQ

Limitations:
The fix doesn't enable the use of all effectors type with rigidbodies, it only work with some of them. The one that I tested and works are Force, Wind, Magnetic, Harmonic, Turbulence and Vortex.
The ones that were tested and won't work are Boids and Charge. Charge is particularly problematic since it prevents the creation of magnet simulations. Boids are probably failing because there is no way to change the boids specific settings with the UI like for particles.

**update: I fixed the charge effector, here is a video of magnets in Blender using this effector: https://www.youtube.com/watch?v=KsyGjv6OWZI

The code still might need some flags update to take into account effectors moving because of the rigidbody simulation. This is probably the cause for some graphical glitches. Try with a wind force, the arrow is not updated while it is simulating and the lighting is a bit off but the simulation works correctly.

Diff Detail

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

Event Timeline

Ben Crulis (BenCrulis) requested review of this revision.Tue, Jun 16, 8:45 PM
Ben Crulis (BenCrulis) created this revision.
Ben Crulis (BenCrulis) updated this revision to Diff 26014.EditedWed, Jun 17, 6:44 PM

Removed ellipses

Ben Crulis (BenCrulis) retitled this revision from Fix rigidbodies with effectors not being simulated as rigidbodies to Removed ellipses from comment.Wed, Jun 17, 6:51 PM
Ben Crulis (BenCrulis) edited the summary of this revision. (Show Details)
Ben Crulis (BenCrulis) retitled this revision from Removed ellipses from comment to Fixed rigidbodies with effectors not being simulated as rigidbodies.Wed, Jun 17, 6:55 PM
Ben Crulis (BenCrulis) edited the summary of this revision. (Show Details)
Ben Crulis (BenCrulis) edited the summary of this revision. (Show Details)Wed, Jun 17, 6:59 PM
  • Removed unused function arguments to prevent warnings
Ben Crulis (BenCrulis) edited the summary of this revision. (Show Details)Thu, Jun 18, 2:08 PM

Added support for charged rigidbodies, allowing to create magnets.

The charge is determined by the sign of the charged effector's strength on the rigidbody.

Ben Crulis (BenCrulis) edited the summary of this revision. (Show Details)Fri, Jun 19, 6:30 PM

The rigid bodies do not conserve energy if the strength of two charge effector rigid bodies is different (like -10 and 100). The strength should really represent the charge of the rigid body.

It would be nice if you would update the comment in "BKE_effect.h" to match the new behaviour. Previously only particles had charge, now rigid bodies also have charge so something like

...
  float vel_to_sec;
  float charge;

  /* only for particles */
  float size;
...
source/blender/blenkernel/intern/rigidbody.c
1655

epoint.charge = ob->pd ? ob->pd->f_strength : 0; works perfectly

Fixed energy conservation using rigidbodies of different charges, updated comment about charge being particle specific

Fix suggested by Henrik Dick (weasel), thanks!