Refactor: Move and replace Face Set SCULPT_stroke_is_first_brush_step

* Shift call to the Draw Face Set brush implementation as it is
  irrelevant for other brushes.
* Instead of checking for the first brush step, check to see if the
  value is still `SCULPT_FACE_SET_NONE`.

Pull Request: https://projects.blender.org/blender/blender/pulls/138949
This commit is contained in:
Sean Kim
2025-05-15 23:03:42 +02:00
committed by Sean Kim
parent 0514789737
commit f831e211f4
3 changed files with 14 additions and 18 deletions

View File

@@ -20,6 +20,8 @@
#include "editors/sculpt_paint/sculpt_intern.hh"
#include "editors/sculpt_paint/sculpt_undo.hh"
#include "ED_sculpt.hh"
#include "bmesh.hh"
namespace blender::ed::sculpt_paint::brushes {
@@ -430,6 +432,17 @@ void do_draw_face_sets_brush(const Depsgraph &depsgraph,
{
const Brush &brush = *BKE_paint_brush_for_read(&sd.paint);
if (object.sculpt->cache->paint_face_set == SCULPT_FACE_SET_NONE) {
if (object.sculpt->cache->invert) {
/* When inverting the brush, pick the paint face mask ID from the mesh. */
object.sculpt->cache->paint_face_set = face_set::active_face_set_get(object);
}
else {
/* By default, create a new Face Sets. */
object.sculpt->cache->paint_face_set = face_set::find_next_available_id(object);
}
}
switch (bke::object::pbvh_get(object)->type()) {
case bke::pbvh::Type::Mesh:
do_draw_face_sets_brush_mesh(depsgraph, object, brush, node_mask);

View File

@@ -3217,23 +3217,6 @@ static void do_brush_action(const Depsgraph &depsgraph,
depsgraph, ob, brush, memory);
const IndexMask node_mask = cursor_sample_result.node_mask;
/* Draw Face Sets in draw mode makes a single undo push, in alt-smooth mode deforms the
* vertices and uses regular coords undo. */
/* It also assigns the paint_face_set here as it needs to be done regardless of the stroke type
* and the number of nodes under the brush influence. */
if (brush.sculpt_brush_type == SCULPT_BRUSH_TYPE_DRAW_FACE_SETS &&
SCULPT_stroke_is_first_brush_step(*ss.cache) && !ss.cache->alt_smooth)
{
if (ss.cache->invert) {
/* When inverting the brush, pick the paint face mask ID from the mesh. */
ss.cache->paint_face_set = face_set::active_face_set_get(ob);
}
else {
/* By default create a new Face Sets. */
ss.cache->paint_face_set = face_set::find_next_available_id(ob);
}
}
/* Only act if some verts are inside the brush area. */
if (node_mask.is_empty()) {
return;

View File

@@ -252,7 +252,7 @@ struct StrokeCache {
SculptRakeData rake_data;
/* The face set being painted. */
int paint_face_set = 0;
int paint_face_set = SCULPT_FACE_SET_NONE;
/**
* Symmetry index between 0 and 7 bit combo.