[Bf-blender-cvs] [4b41114f674] sculpt-dev: Sculpt-dev: fix brush test api bug

Joseph Eagar noreply at git.blender.org
Sun May 22 11:47:20 CEST 2022


Commit: 4b41114f674f6eb992c868ed605fbfbd5d69e1c7
Author: Joseph Eagar
Date:   Sun May 22 02:47:11 2022 -0700
Branches: sculpt-dev
https://developer.blender.org/rB4b41114f674f6eb992c868ed605fbfbd5d69e1c7

Sculpt-dev: fix brush test api bug

* Fixed two missing break statements.
  Amazing what a cascade of bugs this
  produced.
* Fixed small bug in BKE_brush_curve_strength_ex.
* The radius scale fix for original normal mode
  now applies to all sculpt brushes, not just
  the draw brush.

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

M	source/blender/blenkernel/BKE_pbvh.h
M	source/blender/blenkernel/intern/brush.c
M	source/blender/blenkernel/intern/paint.c
M	source/blender/blenkernel/intern/pbvh.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/sculpt_paint/sculpt.c

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

diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h
index 1ac14c8ab55..7f277908c07 100644
--- a/source/blender/blenkernel/BKE_pbvh.h
+++ b/source/blender/blenkernel/BKE_pbvh.h
@@ -357,7 +357,7 @@ void BKE_pbvh_update_sculpt_verts(PBVH *pbvh);
 
 /** update original data, only data whose r_** parameters are passed in will be updated*/
 bool BKE_pbvh_get_origvert(
-    PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color);
+    PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color);
 
 /**
 checks if original data needs to be updated for v, and if so updates it.  Stroke_id
diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c
index 0288d5e52ee..c724e279cb4 100644
--- a/source/blender/blenkernel/intern/brush.c
+++ b/source/blender/blenkernel/intern/brush.c
@@ -2816,13 +2816,13 @@ void BKE_brush_randomize_texture_coords(UnifiedPaintSettings *ups, bool mask)
   }
 }
 
-ATTR_NO_OPT float BKE_brush_curve_strength_ex(
+float BKE_brush_curve_strength_ex(
     int curve_preset, const CurveMapping *curve, float p, const float len, const bool invert)
 {
   float strength = 1.0f;
 
   if (p >= len) {
-    return 0;
+    return invert ? 0.0f : 1.0f;
   }
 
   p = p / len;
@@ -2876,12 +2876,8 @@ float BKE_brush_curve_strength(const Brush *br, float p, const float len)
     return 0.0f;
   }
 
-  /* Invert p to match behavior of master. */
-  if (br->curve_preset == BRUSH_CURVE_CUSTOM) {
-    p = len - p;
-  }
-
-  return BKE_brush_curve_strength_ex(br->curve_preset, br->curve, p, len, true);
+  return BKE_brush_curve_strength_ex(
+      br->curve_preset, br->curve, p, len, br->curve_preset != BRUSH_CURVE_CUSTOM);
 }
 
 float BKE_brush_curve_strength_clamped(const Brush *br, float p, const float len)
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 151dcf49227..34d6270bed3 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -2642,6 +2642,8 @@ static void init_mdyntopo_layer_faces(SculptSession *ss, PBVH *pbvh, int totvert
 
     SculptVertRef vertex = {.i = i};
 
+    copy_v3_v3(mv->origco, ss->mvert[i].co);
+
     BKE_pbvh_update_vert_boundary_faces(ss->face_sets,
                                         ss->mvert,
                                         ss->medge,
diff --git a/source/blender/blenkernel/intern/pbvh.c b/source/blender/blenkernel/intern/pbvh.c
index c5127250d36..88ed3f3c4da 100644
--- a/source/blender/blenkernel/intern/pbvh.c
+++ b/source/blender/blenkernel/intern/pbvh.c
@@ -5278,7 +5278,7 @@ void BKE_pbvh_ensure_node_loops(PBVH *pbvh)
 }
 
 bool BKE_pbvh_get_origvert(
-    PBVH *pbvh, SculptVertRef vertex, float **r_co, float **r_no, float **r_color)
+    PBVH *pbvh, SculptVertRef vertex, const float **r_co, float **r_no, float **r_color)
 {
   MSculptVert *mv;
 
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index a60a4db95d4..3c360f47dd3 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -1379,7 +1379,7 @@ static void version_liboverride_rnacollections_insertion_animdata(ID *id)
 }
 
 /* NOLINTNEXTLINE: readability-function-size */
-ATTR_NO_OPT void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
+void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
 {
   /* The #SCE_SNAP_SEQ flag has been removed in favor of the #SCE_SNAP which can be used for each
    * snap_flag member individually. */
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 4637ff4174f..e09ab310248 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3262,7 +3262,7 @@ SculptBrushTestFn SCULPT_brush_test_init_ex(const SculptSession *ss,
     switch (falloff_mode) {
       case PAINT_FALLOFF_SHAPE_SPHERE:
         sculpt_brush_test_sq_fn = SCULPT_brush_test_cube_sq;
-
+        break;
       case PAINT_FALLOFF_SHAPE_TUBE:
         if (ss->cache) {
           plane_from_point_normal_v3(test->plane_view, test->location, ss->cache->view_normal);
@@ -3281,7 +3281,7 @@ SculptBrushTestFn SCULPT_brush_test_init_ex(const SculptSession *ss,
     switch (falloff_mode) {
       case PAINT_FALLOFF_SHAPE_SPHERE:
         sculpt_brush_test_sq_fn = SCULPT_brush_test_sphere_sq;
-
+        break;
       case PAINT_FALLOFF_SHAPE_TUBE:
         if (ss->cache) {
           plane_from_point_normal_v3(test->plane_view, test->location, ss->cache->view_normal);
@@ -5332,6 +5332,7 @@ static void get_nodes_undo(Sculpt *sd,
   BrushCommand *cmd = data->cmd;
   SculptSession *ss = ob->sculpt;
   float start_radius = ss->cache->radius;
+
   float radius_scale = 1.0f;
   const bool use_original = sculpt_tool_needs_original(cmd->tool) ? true : ss->cache->original;
 
@@ -5350,7 +5351,7 @@ static void get_nodes_undo(Sculpt *sd,
   else {
     /* With these options enabled not all required nodes are inside the original brush radius,
      * so the brush can produce artifacts in some situations. */
-    if (tool == SCULPT_TOOL_DRAW && brush->flag & BRUSH_ORIGINAL_NORMAL) {
+    if (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);
@@ -5965,6 +5966,7 @@ static void SCULPT_run_commandlist(Sculpt *sd,
     do_symmetrical_brush_actions(sd, ob, SCULPT_run_command, ups, paint_mode_settings, &data);
 
     sculpt_combine_proxies(sd, ob);
+    BKE_pbvh_update_bounds(ss->pbvh, PBVH_UpdateOriginalBB | PBVH_UpdateBB);
   }
 
   /*
@@ -6965,6 +6967,7 @@ static void sculpt_update_cache_invariants(
   if (SCULPT_TOOL_HAS_ACCUMULATE(SCULPT_get_tool(ss, brush))) {
     if (!(BRUSHSET_GET_INT(channels, accumulate, &ss->cache->input_mapping))) {
       cache->original = true;
+
       if (SCULPT_get_tool(ss, brush) == SCULPT_TOOL_DRAW_SHARP) {
         cache->original = false;
       }
@@ -7902,7 +7905,7 @@ bool SCULPT_stroke_get_location(bContext *C, float out[3], const float mouse[2])
 
   ss = ob->sculpt;
   cache = ss->cache;
-  original = (cache) ? cache->original : false;
+  original = cache ? cache->original : false;
 
   const Brush *brush = BKE_paint_brush(BKE_paint_get_active_from_context(C));



More information about the Bf-blender-cvs mailing list