Page MenuHome

Sculpt: Insert Mesh Brush tool
Needs RevisionPublic

Authored by Pablo Dobarro (pablodp606) on Thu, Oct 29, 12:05 AM.
"Like" token, awarded by Regnas."Love" token, awarded by franMarz."100" token, awarded by NAS."100" token, awarded by Frozen_Death_Knight."Love" token, awarded by johnsyed."Love" token, awarded by Dardranight."Love" token, awarded by kouza."100" token, awarded by gilberto_rodrigues."100" token, awarded by tiagoffcruz."Dat Boi" token, awarded by Brandon777."Love" token, awarded by KINjO."100" token, awarded by leiserfg."Love" token, awarded by Kickflipkid687."Love" token, awarded by CobraA."Love" token, awarded by julperado."Dat Boi" token, awarded by ostapblender."Love" token, awarded by lopoIsaac."Love" token, awarded by Noss.



This implements the insert mesh tool. Brushes for that use the insert
mesh tool can have a reference to a mesh datablock. They insert that
mesh into the sculpt mesh, using the grab delta orientation and the
sculpt symmetry options.

The brush has 3 placement and 3 modes to initialize the Face Sets of
the new geometry:

Placement Modes:

Face Set creation modes:

This is a special case of brush that requires a PBVH rebuild during the
stroke and a SCULPT_UNDO_GEOMETRY push. If this is something we want to
support, I would like to have this functionality in place to take it
into account for upcoming refactors and optimizations.

As this is an example of tools that requires another datablock to be
referenced from a brush, it can be useful to have when designing the
brush management as well.

The tool is set to experimental for the following reasons:

  • Without brush management, supporting this tool does not make any sense as you need to setup the brushes with the insert meshes each time you want to use it.
  • This implementation won't work on high poly meshes. It requires a BMesh conversion per symmetry pass and a PBVH rebuild each time a stroke starts.
  • It also leaves the PBVH in a highly deformed state when the stroke ends, it probably needs an additional rebuild.
  • It does not work with dyntopo and multires (at least it should work with dyntopo when enabling all features after the optimization).
  • It does not have icon.

Diff Detail

rB Blender
sculpt-insert-tool (branched from master)
Build Status
Buildable 10980
Build 10980: arc lint + arc unit

Event Timeline

Pablo Dobarro (pablodp606) requested review of this revision.Thu, Oct 29, 12:05 AM
Pablo Dobarro (pablodp606) created this revision.

This does not work. What is the correct way to check if two datablocks are the same?

This is incredible! Any plans to make a negative option so geometry of the mesh would be subtracted?


Is there a way to do this same operation without converting everything to BMesh?

The library management code (ID remapping and its friends) are missing.

To me it is also not really clear what is the real world usecase for sculptors, other than having fun-looking demo video?
@Brecht Van Lommel (brecht), maybe you want to keep an eye here from the brush management point of view?


When is this handled? Who is responsible for this?
The naming is also weird. Comment says it forces PBVH update, but the naming suggests it is the evaluated mesh which will be updated.


Continuation of the comment from above: who and when is responsible for clearing the flag?
What if both update_mesh_eval and building_vp_handle are truth?


What is this matrix?


Please avoid ambiguous indirections. What "this" operation is?
You can not create bmesh from mesh (which is the operation which happens here) without using bmesh ;)

If you're asking whether it is possible to combine two meshes without going bmesh -- for simple cases yes, it should be possible. Quite sure Join operator does not create temporary bmesh. And there should be as much code shared with join as possible if the behavior is desired to be the same.

If some more elaborate modification is used (for example, welding, or boolean) I do not think it is possible to do it without bmesh.


The only reason why it might not work I can think of is that you're mixing original and evaluated domain.

Pablo Dobarro (pablodp606) marked 4 inline comments as done.
  • Review update
  • Implement placement modes
  • Implement Face Set creation modes
  • Now insert brushes load and save correctly
  • Fix insert mesh not visible after insert
  • Fix crash when inserting into itself
  • Fix crash on undo
Pablo Dobarro (pablodp606) added inline comments.

It just needs to join the geometry, no further mesh modifications for now. I would rather left this using BMesh for now and refactor the join operator code later if performance here is an issue.

@Sergey Sharybin (sergey) This is often use in combination with the voxel remesher for creating the base shape of an object. For example, if you are sculpting a head, you can have a brush with an ear shape and just drag it on the mesh with symmetry enabled and then remesh, instead of go to edit mode, add a cylinder, scale it, position it in place, add a mirror modifier, apply it, join to the other object and remesh. This is why I mentioned that this brush without a library of meshes to insert (like ears, hands, nails, buttons, horns...) is not that useful. If you just want to add simple primitives to sculpt another volume, then using this does not make much sense.

The other for a similar workflow would be brushes with vector displacement textures, but that requires much higher vertex counts and it requires remeshing afterwards. Even if we can also support that in the future, I prefer this solution.

  • This implementation won't work on high poly meshes. It requires a BMesh conversion per symmetry pass and a PBVH rebuild each time a stroke starts.
    • It also leaves the PBVH in a highly deformed state when the stroke ends, it probably needs an additional rebuild.
    • It does not work with dyntopo and multires (at least it should work with dyntopo when enabling all features after the optimization).

Perhaps we should have this tool outside of sculpt mode too, in object mode, that way you could avoid all of that? Since the high poly mesh doesn't actually require any changes it would avoid all of those performance hits.

Sergey Sharybin (sergey) requested changes to this revision.Fri, Oct 30, 11:14 AM

@Pablo Dobarro (pablodp606), Thanks for the explanation of the desired behavior. But I would suggest going back to the drawing board and get brush management design in place. This is a reoccurring topic, which I think is a high time to get addressed. The current design I do not find acceptable for master branch even as the experimental feature as it has implications outside of the tool's scope.

This revision now requires changes to proceed.Fri, Oct 30, 11:14 AM

"real world use case for sculptor" lol, it's a must have a lot of addon (and other sculpt apps )propose it now, but nothing like that, it's awesome.

Regarding brush/asset management.

  • Should the mesh link be stored in the brush or in the tool settings? Brush as in this patch makes sense to me, it lets you make multiple brushes each with their own mesh type if desired. And for (I guess) the more common case of a single default insert brush switching the meshes on that brush should also work fine.
  • How to easily tag and browse relevant meshes? Those meshes should be stored by the asset manager, with metadata indicating that they are suggested to be used for brushes. When choosing a mesh for the brush, it should be able to open a menu with mesh previews, default filtered to meshes with the appropriate metadata, and with an option to also show all meshes.

This whole issue is really the same for brush textures. You also want to be able to have a curated set of brush textures that you can easily select. And there's some questions about how such datablocks relate to datablocks in the local .blend file. So it's not a new problem in that sense, and the solution should be the same for both.

My idea is:

  • Brushes store the insert mesh and its options defining how it is going to be inserted (the "placement options" in this patch, but more can be added in the future)
  • In the asset browser, you don't search for meshes to be inserted, but for preconfigured brushes that contains both the mesh and the options that make sense for that mesh. I was thinking on adding an operator to the sculpt menu called something like "insert brush from sculpt mesh", that creates a new insert brush preset with default settings to make this process easier.

To me, this also make sense for textures. Switching only the texture of a brush is only useful in a limited set of use cases. When you switch the texture, you also want to change the strength, spacing and projection options that make sense for that particular texture. So, even if the asset browser exposes a full list of texture and meshes in the bled file, the intended way to use them from the painting modes will be by selecting the preconfigued brush that uses that asset, which also contains the options of how it should be applied.

That's fine with me too, and would simplify things. In that case it really becomes dependent on better brush management to handle the large number of brushes.