Page MenuHome

Sculpt: Mask filter and dirty mask generator

Authored by Pablo Dobarro (pablodp606) on Aug 15 2019, 9:22 PM.



Dirty mask was inside the mask filter in the sculpt branch, but it didn't make much sense. I split it into a different operator. It still misses some parameters from the vertex color operator that I can add later when we know how these operators are going to be used from the interface.

Diff Detail

rB Blender

Event Timeline

  • Update only modified nodes, fix warnings
  • Add mask filter pie menu
  • Use exec instead of invoke

This allows repeating the operator with Shift+R without opening the pie menu again

Sebastian Parborg (zeddb) requested changes to this revision.Thu, Sep 5, 2:37 PM

From just reading the changes, this seems fine to me.

However, this patch doesn't apply cleanly for me in the latest master. Could you update your patch?

This revision now requires changes to proceed.Thu, Sep 5, 2:37 PM
  • Rebase, fix unused warnings

Other than my comments below, I didn't really find any other issues.


Missing prototype warning. I'm guessing you want to have this be a static function?


I'm getting a "set but unused warning here". I think you can just remove this variable.


Same as with the other prop, just remove this.

Brecht Van Lommel (brecht) requested changes to this revision.Fri, Sep 6, 6:59 PM

The filter tool doesn't show an adjust operator settings panel, which I think would be useful to tweak the iterations? It's not immediately obvious from the code why it's not showing here though.


Mask edit -> Mask Edit


These operations should not only be in the pie menu, but also the Sculpt menu in the header.


Mask filter -> Mask Filter


Auto iteration count -> Auto Iteration Count


Weird indentation.


Change to:

float angle = max_ff(saacosf(dot), 0.0f);
return angle;

saacosf avoids NaN in some rare float precision cases.


Always use {} for if.


Move to utility function from other patches


Dirty mask -> Dirty Mask


Slightly faster to compute the vertex count once instead of for every iteration.

int num_verts = sculpt_vertex_count_get(ss);
or (int i = 0; i < num_verts; i++) {

This goes for all similar loops in this patch.


Maybe free nodes before undo push. Doesn't really better but has slightly slower memory peak then.


Dirty mask -> Dirty Mask

This revision now requires changes to proceed.Fri, Sep 6, 6:59 PM
Pablo Dobarro (pablodp606) marked 15 inline comments as done.Fri, Sep 6, 11:53 PM
Pablo Dobarro (pablodp606) updated this revision to Diff 17932.
  • Update for revision

I never get a sculpt mode operator to work with the redo panel. But even if it does, on a high poly mesh some filters need a high number of iterations to get a usable result. Adjusting the filter in the redo panel from the iteration 100 to the 101 will recalculate 101 iterations, so it is going to be faster running the filter again. I would like this to work similarly to the mesh filter, adjusting the iteration count in real time from a modal operator.

  • Add Dirty Mask to the menu
Brecht Van Lommel (brecht) added inline comments.

Slightly faster:

float mask = sculpt_vertex_mask_get(ss, index);
if (mask > max) {
  sculpt_vertex_mask_set(ss, index, max);
else if (mask < min) {
  sculpt_vertex_mask_set(ss, index, min);

Add ; after sculpt_vertex_neighbors_iter_end(ni) to solve weird indentation.


Add ; after sculpt_vertex_neighbors_iter_end(ni) to solve weird indentation.


Add ; after sculpt_vertex_neighbors_iter_end(ni) to solve weird indentation.

This revision is now accepted and ready to land.Sun, Sep 8, 11:48 AM
Pablo Dobarro (pablodp606) marked 3 inline comments as done.Mon, Sep 9, 4:29 PM
This revision was automatically updated to reflect the committed changes.