Page MenuHome

Sculpt: Cloth Brush/Filter Collisions
AcceptedPublic

Authored by Pablo Dobarro (pablodp606) on Sat, Jun 13, 6:46 PM.
Tags
None
Tokens
"Like" token, awarded by Quargzon."Dat Boi" token, awarded by shader."Burninate" token, awarded by ruthwikrao."Love" token, awarded by andruxa696."Love" token, awarded by Alrob."Love" token, awarded by RodDavis."Burninate" token, awarded by DiogoX2."Love" token, awarded by Dardranight."100" token, awarded by Frozen_Death_Knight."Love" token, awarded by kouza."Burninate" token, awarded by brilliant_ape."Burninate" token, awarded by ZohaibAli."Burninate" token, awarded by ostapblender.

Details

Summary

This implements collisions in the solver of the cloth brush/filter. It
uses the scene colliders as a regular physics simulation.

There are still some parameters (friction, distance to the surface...)
that can be exposed as properties in later patches.

To make it work it needs an object with a collider and a softbody
enabled. The softbody is needed because otherwise collisions relations
are not created and the solver can't get the colliders. I'm not sure if
there is currently a way to request the collisions relations from a
brush/tool.

Thanks to @Sebastian Parborg (zeddb) for helping me with the implementation.

Diff Detail

Repository
rB Blender
Branch
sculpt-cloth-collisions (branched from master)
Build Status
Buildable 8673
Build 8673: arc lint + arc unit

Event Timeline

Pablo Dobarro (pablodp606) requested review of this revision.Sat, Jun 13, 6:46 PM
Pablo Dobarro (pablodp606) created this revision.

From reading the code seems ok. But maybe @Sebastian Parborg (zeddb) wants to give a pass a swell.

This revision is now accepted and ready to land.Mon, Jun 15, 9:23 AM

@Sergey Sharybin (sergey) The thing that is missing here is that we have to tag the depsgraph someway that the cloth brush is going to use collisions.

When using modifiers, we can use DEG_add_collision_relations. But neither Pablo or I am sure how we should add this relation when using a tool/brush.

Now we hack around this by adding an other modifier to the mesh that adds this relation (so that the collision data is available). But this is not a good solution.
So we are wondering if you know any good way to do this.

Well, ok. Couple of things here:

  • There is no such thing as dependency to/from a brush, as the brush is not covered by the dependency graph (while it is internally an ID, it is considered a tool/interface).
  • You wouldn't want to add/remove relations on stroke begin/end, as rebuilding relations is not entirely cheap and you don't want any lag.

Easiest is probably to consider that brush is handled from an evaluated dependency graph state, which would mean that all colliders are at their final evaluated state. And then for the brush/sculpted object you "by-pass" dependency graph by providing explicit list of colliders (ideally ,without using temporary modifications to the object).

  • Use custom function to build the collider cache

As it is now, it works, but ss->bmain is not updated before each operation, so it crashes quite often. Is there a way to iterate over all objects without using bmain? Otherwise I'll need to include a big refactor in a lot of files to pass bmain to BKE_sculpt_update_object_for_edit