Page MenuHome

Refactor depsgraph to compute more accurate links for collision & force.
ClosedPublic

Authored by Alexander Gavrilov (angavrilov) on Aug 7 2016, 1:56 PM.

Details

Summary

Current implementation more or less indiscriminately links physics
objects to colliders and forces, ignoring precise details of layer
checks and collider groups. The new depsgraph seemed to lack some
such links at all. The relevant code in modifiers suffers from a
lot of duplication.

Different physics simulations use independent implementations of
collision and similar things, which results in a lot of variance:

  • Cloth collides with objects on same or visible layer with dupli.
  • Softbody collides with objects on same layer without dupli.
  • Non-hair particles collide on same layer with dupli.
  • Smoke uses same code as cloth, but needs different modifier.
  • Dynamic paint "collides" with brushes on any layer without dupli.

Force fields with absorption also imply dependency on colliders:

  • For most systems, colliders are selected from same layer as field.
  • For non-hair particles, it uses the same exact set as the particles.

As a special quirk, smoke ignores smoke flow force fields.

This introduces two utility functions each for old and new depsgraph
that are flexible enough to handle all these variations, and uses them
to handle particles, cloth, smoke, softbody and dynpaint.

One thing to watch out for is that depsgraph code shouldn't rely on
any properties that don't cause a graph rebuild when changed. This
was violated in the original code that was building force field links,
while taking zero field weights into account.

Diff Detail

Repository
rB Blender

Event Timeline

Alexander Gavrilov (angavrilov) retitled this revision from to Refactor depsgraph to compute more accurate links for collision & force..
Alexander Gavrilov (angavrilov) updated this object.

Add depsgraph resets to rna for collision group fields, and more dependencies on transforms for new depsgraph.

Here are some test files for collision and force field relations:

The relations in the old depsgraph mode look correct to me; new depsgraph is a bit difficult to check because graphviz crashes unless splines=ortho is removed, and doesn't fully lay out the graph even then.

Upon reflection, move the callback function handling to the depsgraph specific code to reduce changes in collision.c.
The amount of code duplication between new and old depsgraph that this causes is negligible.

@Sergey Sharybin (sergey) said that particles may actually be evaluated by the final ubereval, so add links to geometry when processing particle-emitted force fields just in case. Redundant links are less of a problem than missing ones.

This revision was automatically updated to reflect the committed changes.