[Bf-blender-cvs] [08960bcda67] sculpt-dev: Sculpt: Split the brushes from sculpt.c into sculpt_brushes.c.

Joseph Eagar noreply at git.blender.org
Mon Oct 18 00:45:48 CEST 2021


Commit: 08960bcda6712de1c96910499ae5965dff6978bc
Author: Joseph Eagar
Date:   Sun Oct 17 15:45:05 2021 -0700
Branches: sculpt-dev
https://developer.blender.org/rB08960bcda6712de1c96910499ae5965dff6978bc

Sculpt: Split the brushes from sculpt.c into sculpt_brushes.c.

* Also killed the warnings in sculpt_boundary.c

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

M	source/blender/editors/sculpt_paint/CMakeLists.txt
M	source/blender/editors/sculpt_paint/paint_intern.h
M	source/blender/editors/sculpt_paint/sculpt.c
M	source/blender/editors/sculpt_paint/sculpt_boundary.c
A	source/blender/editors/sculpt_paint/sculpt_brushes.c
M	source/blender/editors/sculpt_paint/sculpt_intern.h

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

diff --git a/source/blender/editors/sculpt_paint/CMakeLists.txt b/source/blender/editors/sculpt_paint/CMakeLists.txt
index bb0d903317a..cc6705ce986 100644
--- a/source/blender/editors/sculpt_paint/CMakeLists.txt
+++ b/source/blender/editors/sculpt_paint/CMakeLists.txt
@@ -61,8 +61,11 @@ set(SRC
   sculpt_curvature.c
   sculpt_automasking.c
   sculpt_boundary.c
+  sculpt_brushes.c
   sculpt_cloth.c
   sculpt_detail.c
+  sculpt_displacement.c
+  sculpt_displacement.h
   sculpt_dyntopo.c
   sculpt_expand.c
   sculpt_face_set.c
@@ -78,14 +81,12 @@ set(SRC
   sculpt_paint_color.c
   sculpt_pose.c
   sculpt_poly_loop.c
+  sculpt_replay.c
   sculpt_symmetrize.c
   sculpt_smooth.c
   sculpt_transform.c
   sculpt_undo.c
   sculpt_uv.c
-  sculpt_displacement.c
-  sculpt_displacement.h
-  sculpt_replay.c
 
   sculpt.cc
   sculpt.hh
diff --git a/source/blender/editors/sculpt_paint/paint_intern.h b/source/blender/editors/sculpt_paint/paint_intern.h
index 11e70af2fec..f6951b5b525 100644
--- a/source/blender/editors/sculpt_paint/paint_intern.h
+++ b/source/blender/editors/sculpt_paint/paint_intern.h
@@ -397,6 +397,8 @@ bool paint_curve_poll(struct bContext *C);
 bool facemask_paint_poll(struct bContext *C);
 void flip_v3_v3(float out[3], const float in[3], const enum ePaintSymmetryFlags symm);
 void flip_qt_qt(float out[4], const float in[4], const enum ePaintSymmetryFlags symm);
+void flip_qt(float quat[4], const ePaintSymmetryFlags symm);
+void flip_v3(float v[3], const ePaintSymmetryFlags symm);
 
 /* stroke operator */
 typedef enum BrushStrokeMode {
diff --git a/source/blender/editors/sculpt_paint/sculpt.c b/source/blender/editors/sculpt_paint/sculpt.c
index 2e78f41c616..8fcf91c9e79 100644
--- a/source/blender/editors/sculpt_paint/sculpt.c
+++ b/source/blender/editors/sculpt_paint/sculpt.c
@@ -3067,112 +3067,6 @@ void SCULPT_orig_vert_data_update(SculptOrigVertData *orig_data, SculptVertRef v
   }
 }
 
-static void sculpt_rake_data_update(struct SculptRakeData *srd, const float co[3])
-{
-  float rake_dist = len_v3v3(srd->follow_co, co);
-  if (rake_dist > srd->follow_dist) {
-    interp_v3_v3v3(srd->follow_co, srd->follow_co, co, rake_dist - srd->follow_dist);
-  }
-}
-
-static void sculpt_rake_rotate(const SculptSession *ss,
-                               const float sculpt_co[3],
-                               const float v_co[3],
-                               float factor,
-                               float r_delta[3])
-{
-  float vec_rot[3];
-
-#if 0
-  /* lerp */
-  sub_v3_v3v3(vec_rot, v_co, sculpt_co);
-  mul_qt_v3(ss->cache->rake_rotation_symmetry, vec_rot);
-  add_v3_v3(vec_rot, sculpt_co);
-  sub_v3_v3v3(r_delta, vec_rot, v_co);
-  mul_v3_fl(r_delta, factor);
-#else
-  /* slerp */
-  float q_interp[4];
-  sub_v3_v3v3(vec_rot, v_co, sculpt_co);
-
-  copy_qt_qt(q_interp, ss->cache->rake_rotation_symmetry);
-  pow_qt_fl_normalized(q_interp, factor);
-  mul_qt_v3(q_interp, vec_rot);
-
-  add_v3_v3(vec_rot, sculpt_co);
-  sub_v3_v3v3(r_delta, vec_rot, v_co);
-#endif
-}
-
-/**
- * Align the grab delta to the brush normal.
- *
- * \param grab_delta: Typically from `ss->cache->grab_delta_symmetry`.
- */
-static void sculpt_project_v3_normal_align(SculptSession *ss,
-                                           const float normal_weight,
-                                           float grab_delta[3])
-{
-  /* Signed to support grabbing in (to make a hole) as well as out. */
-  const float len_signed = dot_v3v3(ss->cache->sculpt_normal_symm, grab_delta);
-
-  /* This scale effectively projects the offset so dragging follows the cursor,
-   * as the normal points towards the view, the scale increases. */
-  float len_view_scale;
-  {
-    float view_aligned_normal[3];
-    project_plane_v3_v3v3(
-        view_aligned_normal, ss->cache->sculpt_normal_symm, ss->cache->view_normal);
-    len_view_scale = fabsf(dot_v3v3(view_aligned_normal, ss->cache->sculpt_normal_symm));
-    len_view_scale = (len_view_scale > FLT_EPSILON) ? 1.0f / len_view_scale : 1.0f;
-  }
-
-  mul_v3_fl(grab_delta, 1.0f - normal_weight);
-  madd_v3_v3fl(
-      grab_delta, ss->cache->sculpt_normal_symm, (len_signed * normal_weight) * len_view_scale);
-}
-
-/* -------------------------------------------------------------------- */
-/** \name SculptProjectVector
- *
- * Fast-path for #project_plane_v3_v3v3
- *
- * \{ */
-
-typedef struct SculptProjectVector {
-  float plane[3];
-  float len_sq;
-  float len_sq_inv_neg;
-  bool is_valid;
-
-} SculptProjectVector;
-
-/**
- * \param plane: Direction, can be any length.
- */
-static void sculpt_project_v3_cache_init(SculptProjectVector *spvc, const float plane[3])
-{
-  copy_v3_v3(spvc->plane, plane);
-  spvc->len_sq = len_squared_v3(spvc->plane);
-  spvc->is_valid = (spvc->len_sq > FLT_EPSILON);
-  spvc->len_sq_inv_neg = (spvc->is_valid) ? -1.0f / spvc->len_sq : 0.0f;
-}
-
-/**
- * Calculate the projection.
- */
-static void sculpt_project_v3(const SculptProjectVector *spvc, const float vec[3], float r_vec[3])
-{
-#if 0
-  project_plane_v3_v3v3(r_vec, vec, spvc->plane);
-#else
-  /* inline the projection, cache `-1.0 / dot_v3_v3(v_proj, v_proj)` */
-  madd_v3_v3fl(r_vec, spvc->plane, dot_v3v3(vec, spvc->plane) * spvc->len_sq_inv_neg);
-#endif
-}
-
-/** \} */
-
 /**********************************************************************/
 
 /* Returns true if the stroke will use dynamic topology, false
@@ -3598,12 +3492,12 @@ static bool sculpt_brush_test_cyl(SculptBrushTest *test,
 
 /* ===== Sculpting =====
  */
-static void flip_v3(float v[3], const ePaintSymmetryFlags symm)
+void flip_v3(float v[3], const ePaintSymmetryFlags symm)
 {
   flip_v3_v3(v, v, symm);
 }
 
-static void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
+void flip_qt(float quat[4], const ePaintSymmetryFlags symm)
 {
   flip_qt_qt(quat, quat, symm);
 }
@@ -3901,7 +3795,7 @@ static void calc_area_normal_and_center_reduce(const void *__restrict UNUSED(use
   add_v2_v2_int(join->count_co, anctd->count_co);
 }
 
-static void calc_area_center(
+void SCULPT_calc_area_center(
     Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_co[3])
 {
   SculptSession *ss = ob->sculpt;
@@ -4003,7 +3897,7 @@ bool SCULPT_pbvh_calc_area_normal(const Brush *brush,
 
 /* This calculates flatten center and area normal together,
  * amortizing the memory bandwidth and loop overhead to calculate both at the same time. */
-static void calc_area_normal_and_center(
+void SCULPT_calc_area_normal_and_center(
     Sculpt *sd, Object *ob, PBVHNode **nodes, int totnode, float r_area_no[3], float r_area_co[3])
 {
   SculptSession *ss = ob->sculpt;
@@ -4652,4077 +4546,197 @@ typedef struct {
   int hit_count;
   bool back_hit;
   float depth;
-  bool original;
-
-  /* Depth of the second raycast hit. */
-  float back_depth;
-
-  /* When the back depth is not needed, this can be set to false to avoid traversing unnecesary
-   * nodes. */
-  bool use_back_depth;
-
-  SculptVertRef active_vertex_index;
-  float *face_normal;
-
-  SculptFaceRef active_face_grid_index;
-
-  struct IsectRayPrecalc isect_precalc;
-} SculptRaycastData;
-
-typedef struct {
-  SculptSession *ss;
-  const float *ray_start, *ray_normal;
-  bool hit;
-  float depth;
-  float dist_sq_to_ray;
-  bool original;
-} SculptFindNearestToRayData;
-
-static void do_topology_rake_bmesh_task_cb_ex(void *__restrict userdata,
-                                              const int n,
-                                              const TaskParallelTLS *__restrict tls)
-{
-  SculptThreadedTaskData *data = userdata;
-  SculptSession *ss = data->ob->sculpt;
-  Sculpt *sd = data->sd;
-  const Brush *brush = data->brush;
-  PBVHNode *node = data->nodes[n];
-
-  bool do_reproject = SCULPT_need_reproject(ss);
-
-  float direction[3];
-  copy_v3_v3(direction, ss->cache->grab_delta_symmetry);
-
-  float tmp[3];
-  mul_v3_v3fl(
-      tmp, ss->cache->sculpt_normal_symm, dot_v3v3(ss->cache->sculpt_normal_symm, direction));
-  sub_v3_v3(direction, tmp);
-  normalize_v3(direction);
-
-  /* Cancel if there's no grab data. */
-  if (is_zero_v3(direction)) {
-    return;
-  }
-
-  const float bstrength = clamp_f(data->strength, 0.0f, 1.0f);
-
-  SculptBrushTest test;
-  SculptBrushTestFn sculpt_brush_test_sq_fn = SCULPT_brush_test_init_with_falloff_shape(
-      ss, &test, data->brush->falloff_shape);
-  const int thread_id = BLI_task_parallel_thread_id(tls);
-
-  const bool use_curvature = data->use_curvature;
-  int check_fsets = ss->cache->brush->flag2 & BRUSH_SMOOTH_PRESERVE_FACE_SETS;
-  check_fsets = check_fsets ? SCULPT_BOUNDARY_FACE_SET : 0;
-
-  if (use_curvature) {
-    SCULPT_curvature_begin(ss, node, false);
-  }
-
-  const bool weighted = ss->cache->brush->flag2 & BRUSH_SMOOTH_USE_AREA_WEIGHT;
-  if (weighted || ss->cache->brush->boundary_smooth_factor > 0.0f) {
-    BKE_pbvh_check_tri_areas(ss->pbvh, data->nodes[n]);
-  }
-
-  PBVHVertexIter vd;
-  BKE_pbvh_vertex_iter_begin (ss->pbvh, node, vd, PBVH_ITER_UNIQUE) {
-    if (!sculpt_brush_test_sq_fn(&test, vd.co)) {
-      continue;
-    }
-
-/* ignore boundary verts
-  might want to call normal smooth with
-  rake's projection in this case, I'm not entirely sure
-  - joeedh
-*/
-#if 0
-    if (have_bmesh) {
-      BMVert *v = (BMVert *)vd.vertex.i;
-      MSculptVert *mv = BKE_PBVH_SCULPTVERT(ss->cd_sculpt_vert, v);
-
-       if (mv->flag & (SCULPTVERT_BOUNDARY | SCULPTVERT_FSET_BOUNDARY)) {
-        continue;
-      }
-    }
-#endif
-
-    float direction2[3];
-    const float fade =
-        bstrength *
-        SCULPT_brush_strength_factor(
-            ss, brush, vd.co, sqrtf(test.dist), vd.no, vd.fno, *vd.mask, vd.vertex, thread_id);
-
-    float avg[3], val[3];
-
-    if (use_curvature) {
-      SCULPT_curvature_dir_get(ss, vd.vertex, direction2, false);
-    }
-    else {
-      copy_v3_v3(direction2, direction);
-    }
-
-#if 0
-    if (SCULPT_vertex_is_boundary(
-            ss, vd.vertex, SCULPT_BOUNDARY_SHARP | SCULPT_BOUNDARY_MESH | check_fsets)) {
-      continue;
-    }
-
-    MSculptVert *mv = BKE_PBVH_SCULPTVERT(ss->cd_sculpt_vert, vd.bm_vert);
-    if (check_fsets && (mv->flag & (SCULPTVERT_FSET_CORNER))) {
-      continue;
-    }
-
-    if (mv->flag & 

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list