Page MenuHome

Sculpt persistent mesh state management
Needs Triage, NormalPublicDESIGN

Description

The Layer Brush has a "Set Persistent Base" operator that stores a copy of the mesh coordinates and normals using the sculpt API. This is needed for that brush to be usable, but it has some problems:

  • The coordinates and normals copy is freed with the PBVH. This means that any operation that needs a PBVH rebuild will delete the persistent state. These rebuilds happen in situations where the topology does not change so that data will be still valid, like switching objects, but may also happen in random situations like tweaking brush settings, undo or saving the file (which seems like a bug).
  • There is no info in the UI if a persistent base is available

Furthermore, this same concept is needed in other tools to fix some important limitations:

  • The cloth brush could use a persistent base to always create the constraints from the same state. This way the brush will behave more like a regular cloth simulation instead of accumulating the deformation effect on each stroke. This is needed to create some effects with the cloth brush and filter
  • The Pose Brush with affect loose part options could use a persistent base state with the model in T pose to calculate the fake neighbor information. With the current implementation, if you move an arm close to the body you won't be able to separate it again as it will calculate fake neighbors between the body and the arm.

As this is a concept similar to shape keys which will probably be similar to sculpt layers, there are still a lot of design decisions to be made to have a final solution for this:

  • It is not clear what shape keys, layers and persistent base should do in the sculpting system as all of them are a similar implementation of the same concept. It needs to be decided which system (or systems) are we going to use. Without this, it is hard to start working on a more clear design and UI proposal. If we decide to have a unified system to manage mesh states, it will need to be carefully designed as it needs to support a lot of different use cases (all the ones mentioned, for layering details in high poly meshes, for they Keymesh project to partially reset deformed models to the default pose...)
  • There is no support for shape keys or layers in grids data. We also don't know if they need to be stored per level or only in the higher level and use propagation
  • This should also support vertex colors and vertex colors in multires as it will be required for some tools

Proposal

As having a workaround for this could improve a lot some of the tools, the sculpt API could implement a SCULPT_vertex_get_persistent_co function. The function will use the same implementation as the current layer brush, so it will return the data stored in the persistent base if available. This will mean than tools like the cloth brush and the pose brush will have a "persistent" and "set persistent base" properties and operators available. Once a more polished management system is in place, it should only be necessary to change the implementation of that function to return the data from the current persistent base wherever it is stored.

Event Timeline

To me it seems persistent base as used by the layer brush should be a temporary state in sculpt mode, that you can create or discard as easily as a mask. Maybe sculpt layers can eventually replace it, if it's convenient enough to create and sculpt on a temporary layer that you then merge into the layer below.

I wouldn't go in the direction of using persistent base for something like a T pose or undeformed mesh shape. For that I think shape keys or sculpt layers are the correct solution.