[Bf-blender-cvs] [f6da6961e0c] sculpt-dev: Sculpt: fix anchored/drag dot brush modes

Joseph Eagar noreply at git.blender.org
Thu Sep 30 09:37:33 CEST 2021


Commit: f6da6961e0c7365135d8b36e70edfc64cfcad86c
Author: Joseph Eagar
Date:   Thu Sep 30 00:37:12 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rBf6da6961e0c7365135d8b36e70edfc64cfcad86c

Sculpt: fix anchored/drag dot brush modes

===================================================================

M	source/blender/blenkernel/BKE_brush_engine.h
M	source/blender/editors/sculpt_paint/sculpt.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_brush_engine.h b/source/blender/blenkernel/BKE_brush_engine.h
index 7f9ff3ad2f8..6160bcf8137 100644
--- a/source/blender/blenkernel/BKE_brush_engine.h
+++ b/source/blender/blenkernel/BKE_brush_engine.h
@@ -301,6 +301,8 @@ int BKE_brush_channelset_get_vector(BrushChannelSet *chset,
                                     float r_vec[4],
                                     BrushMappingData *mapdata);
 bool BKE_brush_channelset_set_vector(BrushChannelSet *chset, const char *idname, float vec[4]);
+extern void BKE_brush_channelset_to_unified_settings(BrushChannelSet *chset,
+                                                     struct UnifiedPaintSettings *ups);
 
 void BKE_brush_init_toolsettings(struct Sculpt *sd);
 void BKE_brush_builtin_create(struct Brush *brush, int tool);
@@ -310,6 +312,7 @@ BrushCommand *BKE_brush_commandlist_add(BrushCommandList *cl,
                                         BrushChannelSet *chset_template,
                                         bool auto_inherit);
 BrushCommand *BKE_brush_command_init(BrushCommand *command, int tool);
+
 void BKE_builtin_commandlist_create(struct Brush *brush,
                                     BrushChannelSet *chset,
                                     BrushCommandList *cl,
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index c3f6c352261..f8f44cc54a8 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -2940,15 +2940,18 @@ static void paint_mesh_restore_co_task_cb(void *__restrict userdata,
   SculptUndoType type = (data->brush->sculpt_tool == SCULPT_TOOL_MASK ? SCULPT_UNDO_MASK :
                                                                         SCULPT_UNDO_COORDS);
 
+  SculptUndoNode tmp = {0};
   if (ss->bm) {
-    unode = SCULPT_undo_push_node(data->ob, data->nodes[n], type);
+    unode = &tmp;
+    tmp.type = type;
+    // unode = SCULPT_undo_push_node(data->ob, data->nodes[n], type);
   }
   else {
     unode = SCULPT_undo_get_node(data->nodes[n], type);
-  }
 
-  if (!unode) {
-    return;
+    if (!unode) {
+      return;
+    }
   }
 
   PBVHVertexIter vd;
@@ -8675,6 +8678,8 @@ void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings
       break;
   }
 
+  ok = ok && !(brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT));
+
   if (ok) {
     if (SCULPT_stroke_is_first_brush_step(ss->cache)) {
       if (ss->cache->commandlist) {
@@ -8750,7 +8755,7 @@ void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings
     if (brush->sculpt_tool == SCULPT_TOOL_DRAW && brush->flag & BRUSH_ORIGINAL_NORMAL) {
       radius_scale = MAX2(radius_scale, 2.0f);
     }
-    nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale, &totnode);
+    nodes = sculpt_pbvh_gather_generic(ob, sd, brush, use_original, radius_scale * 1.2, &totnode);
   }
 
   /* Draw Face Sets in draw mode makes a single undo push, in alt-smooth mode deforms the
@@ -8775,6 +8780,19 @@ void do_brush_action(Sculpt *sd, Object *ob, Brush *brush, UnifiedPaintSettings
     }
   }
 
+  /*
+   * Check that original data is for anchored and drag dot modes
+   */
+  if (brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT)) {
+    for (int i = 0; i < totnode; i++) {
+      PBVHVertexIter vd;
+      BKE_pbvh_vertex_iter_begin (ss->pbvh, nodes[i], vd, PBVH_ITER_UNIQUE) {
+        SCULPT_vertex_check_origdata(ss, vd.vertex);
+      }
+      BKE_pbvh_vertex_iter_end;
+    }
+  }
+
   /* Initialize automasking cache. For anchored brushes with spherical falloff, we start off with
    * zero radius, thus we have no pbvh nodes on the first brush step. */
   if (totnode ||
@@ -11403,10 +11421,12 @@ static void sculpt_restore_mesh(Sculpt *sd, Object *ob)
        BKE_brush_use_size_pressure(brush)) ||
       (brush->flag & BRUSH_DRAG_DOT)) {
 
-    SculptUndoNode *unode = SCULPT_undo_get_first_node();
-    if (unode && unode->type == SCULPT_UNDO_FACE_SETS) {
-      for (int i = 0; i < ss->totfaces; i++) {
-        ss->face_sets[i] = unode->face_sets[i];
+    if (BKE_pbvh_type(ss->pbvh) != PBVH_BMESH) {
+      SculptUndoNode *unode = SCULPT_undo_get_first_node();
+      if (unode && unode->type == SCULPT_UNDO_FACE_SETS) {
+        for (int i = 0; i < ss->totfaces; i++) {
+          ss->face_sets[i] = unode->face_sets[i];
+        }
       }
     }
 
@@ -11613,8 +11633,6 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
     SculptSession *ss = ob->sculpt;
     Sculpt *sd = CTX_data_tool_settings(C)->sculpt;
 
-    ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C));
-
     // increment stroke_id to flag origdata update
     ss->stroke_id++;
 
@@ -11622,6 +11640,8 @@ static bool sculpt_stroke_test_start(bContext *C, struct wmOperator *op, const f
       BKE_pbvh_set_stroke_id(ss->pbvh, ss->stroke_id);
     }
 
+    ED_view3d_init_mats_rv3d(ob, CTX_wm_region_view3d(C));
+
     sculpt_update_cache_invariants(C, sd, ss, op, mouse);
 
     SculptCursorGeometryInfo sgi;
@@ -11648,8 +11668,6 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
   SculptSession *ss = ob->sculpt;
   Brush *brush = BKE_paint_brush(&sd->paint);
 
-  extern void BKE_brush_channelset_to_unified_settings(BrushChannelSet * chset,
-                                                       UnifiedPaintSettings * ups);
   if (ss->cache->channels_final) {
     BKE_brush_channelset_free(ss->cache->channels_final);
   }
@@ -11693,7 +11711,10 @@ void sculpt_stroke_update_step(bContext *C, struct PaintStroke *stroke, PointerR
 
   // load settings into brush and unified paint settings
   BKE_brush_channelset_compat_load(ss->cache->channels_final, brush, false);
-  BKE_brush_channelset_to_unified_settings(ss->cache->channels_final, ups);
+
+  if (!(brush->flag & (BRUSH_ANCHORED | BRUSH_DRAG_DOT))) {
+    BKE_brush_channelset_to_unified_settings(ss->cache->channels_final, ups);
+  }
 
   ss->cache->bstrength = brush_strength(sd, ss->cache, calc_symmetry_feather(sd, ss->cache), ups);



More information about the Bf-blender-cvs mailing list